Buged Createitem function

Codes already submitted by people of the forums.
Post Reply
marleythe9
Loyal fan
Posts: 391
Joined: Sat Mar 26, 2005 12:41 am

Post by marleythe9 »

well if u didnt know. but i found this bug.

if u do /createitem ItemName.

and the gm typed an item name that is bigger then 21 chars it crashes becouse the name dosnt suport more then 21 chars heres fix.

goto

Code: Select all

CGame::AdminOrder_CreateItem
and find

Code: Select all

	token = pStrTok->pGet();
	token = pStrTok->pGet();
then replace all whats under it tell

Code: Select all

pItem = new class CItem;
with this

Code: Select all

	// if the token is something it is an item name
	if (token != NULL) {
  if(strlen(token) > 21) return;
  ZeroMemory(cItemName, sizeof(cItemName));
  strcpy(cItemName, token);
	} // close if (token != NULL) {

	// if the 2nd token is true it is the item attribute
	ZeroMemory(cAttribute, sizeof(cAttribute));
	token = pStrTok->pGet();
	if (token != NULL) {
  if(strlen(token) > 256) return;
  ZeroMemory(cAttribute, sizeof(cAttribute));
  strcpy(cAttribute, token);
	} // close if (token != NULL) {

	// if the 3rd token is true it is the item value
	ZeroMemory(cValue, sizeof(cValue));
	iValue = 0;
	token = pStrTok->pGet();
	if (token != NULL) {
  if(strlen(token) > 256) return;
  ZeroMemory(cValue, sizeof(cValue));
  strcpy(cValue, token);
  iValue = atoi(cValue);
	} // close if (token != NULL) {
<img src='http://freewebs.com/trickro/70s.png' border='0' alt='user posted image' /><img src='http://freewebs.com/trickro/70s2.jpg' border='0' alt='user posted image' />
bone-you
Spamtastic
Posts: 1310
Joined: Wed Mar 16, 2005 3:12 am

Post by bone-you »

OR, you can just do StringCbCopy(cItemName, 20, token); so it will never copy more than 20 characters.
<img src='http://www.helbreathx.net/sig/sig.jpeg' border='0' alt='user posted image' /><br><a href='http://mafia.cheats4us.org/index.php?x=231030' target='_blank'>#1 on Mafia :D</a><br><!--QuoteBegin-Slipknight+--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (Slipknight)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin-->100mb Internet, burstable too 10GB oc192<br>his speed can go up too 10gbs<br>...<br>Yes my car can have a top speed of 1000mph<!--QuoteEnd--></td></tr></table><div class='signature'><!--QuoteEEnd--><br>^^ I wonder where the retard went to.
Post Reply