SA-MP Forums Archive
House sell problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House sell problem (/showthread.php?tid=626273)



House sell problem - ThatFag - 12.01.2017

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;
	}



Re: House sell problem - darkdrago - 13.01.2017

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...