House sell problem
#1

hello, currently i made a sellhouse command and it work okay but when a player puts wat to mutch numbers on it , it can crash the server
crashdetect
Код HTML:
[12:15:06] [debug] AMX backtrace:
[12:15:06] [debug] #0 00000075 in public cmd_house () at C:\Users\stefa_000\Desktop\updated\pawno\include\float.inc:112
[12:15:06] [debug] #1 native CallLocalFunction () from sampsvr-port_7575
[12:15:06] [debug] #2 00002f6c in public OnPlayerCommandText (playerid=0, cmdtext[]=@069cce0c "/house sell 10000000000000000000000000000000000000000000000000000") at C:\Users\stefa_000\Desktop\updated\pawno\include\zcmd.inc:98
command
Код HTML:
else if(strcmp(iChoice,"sell",true)==0)
	{
		if(tmpid == -1 && PlayerTemp[playerid][tmphouse] != -1) tmpid = PlayerTemp[playerid][tmphouse];
		if(tmpid == -1) return SendClientError(playerid, "You're not at any house!");
		if(strcmp(HouseInfo[tmpid][hOwner], PlayerName(playerid), false) && PlayerInfo[playerid][power] < 10) return SendClientError(playerid, "You don't own this house!");
		if(!strlen(iChoice2) || !IsNumeric(iChoice2)) return SCP(playerid, "sell [Price]");
		new iPrice = strval(iChoice2);
		if(iPrice < MIN_H_SELL || iPrice > MAX_H_SELL)
		{
			new iStrr[128];
			format(iStrr, sizeof(iStrr), "Invalid sell price, please keep between $%s - $%s.", number_format(MIN_H_SELL), number_format(MAX_H_SELL));
			SendClientError(playerid, iStrr);
			return 1;
		}
		SendClientMSG(playerid, COLOR_GREEN, "[HOUSE] Your house ID %d is now on sale for $%s.", tmpid, number_format(iPrice));
		HouseInfo[tmpid][hBuyable] = true;
		HouseInfo[tmpid][hSellprice] = iPrice;
		SaveHouse(tmpid);
		UpdateHouse(tmpid);
	    return 1;
	}
Reply
#2

I would suggest to use the sscanf, it would be better and faster, also those problems would never happen.
And if there's some problems with the lenght you could check it with strlen...
Btw those methods are rudimentary, sscanf would be even easier to use...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)