Problem with my command
#1

Код:
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?
Reply
#2

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
Reply
#3

Thank you so much!
Reply
#4

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)