SA-MP Forums Archive
Problem with my command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with my command (/showthread.php?tid=178719)



Problem with my command - PixeledNinja - 23.09.2010

Код:
CMD:fine(playerid, params[])
{
	new
	    finedid,
	    amount,
	    reason;
	if (PlayerInfo[playerid][pAdmin] >= 1)
	{
 		if (!sscanf(params, "ii", finedid, amount, reason))
        {
			if (finedid != INVALID_PLAYER_ID)
			{
  			new
			  message[128];
			new name[MAX_PLAYER_NAME];
			GetPlayerName(playerid, name, sizeof(name));
			new finedname[MAX_PLAYER_NAME];
			GetPlayerName(finedid, finedname, sizeof(name));
			new tempcash;
			GetPlayerMoney(finedid);
			GivePlayerMoney(finedid, tempcash-amount);
        	format(message, sizeof(message), "%s was fined $%d. Reason: %s ", finedname, amount, reason);
        	SendClientMessageToAll(COLOR_ANNOUNCE, message);
        	}
        	else SendClientMessage(playerid, COLOR_SYSTEM, "[SYSTEM] That player is not connected");
		}
  		else SendClientMessage(playerid, COLOR_SYSTEM, "[SYSTEM] /fine [id] [amount] [reason]");
	}
	else SendClientMessage(playerid, COLOR_SYSTEM, "[SYSTEM] Your not authorized to use this command! ");
	return 1;
}
It fines the correct amount and displays the message as:
PlayerName(example) was fined $1,000(example). Reason: (blank,nothing)

Can anyone tell me why the first 2 display correctly but my reason doesn't?



Re: Problem with my command - Mike_Peterson - 23.09.2010

because you only have put ii at sscanf :P
i started using sscanf and used /su (playerid) (reason) and only playerid and no reason now the fix was i only had u i thought and i replaced with uz replace ii with iiz and it should work
https://sampwiki.blast.hk/wiki/Fast_Commands
scroll down till u see sscanf


Re: Problem with my command - PixeledNinja - 23.09.2010

Thank you so much!


Re: Problem with my command - The_Moddler - 23.09.2010

Just change this:
pawn Код:
if (!sscanf(params, "ii", finedid, amount, reason))
To this..
pawn Код:
if (!sscanf(params, "iis", finedid, amount, reason))



Re: Problem with my command - Mike_Peterson - 23.09.2010

s = a string and z = a optional string mostly used for reasons so dont use iis but iiz
and
no problem