Givemoney command issue
#2

First of all you should make your commands like that because it's easier to read (you don't need to, but it looks better in my opinion):
Код:
if (!...)
     return...

if (!...)
     return...

...all good, rest of the command here
Second use "u" specifier for toplayerid. "u" specifier is meant for players, you can either type in the id of the player or their name. Also check if the specified player is invalid like that:
Код:
if (toplayerid == INVALID_PLAYER_ID)
But if for some reason you still want to use "i" or "d" then you can check if the player is invalid like that:
Код:
if (!IsPlayerConnected(toplayerid))
So the command should look like that:
Код:
COMMAND:givemoney(playerid, params[])
{
	if (!IsPlayerAdmin(playerid))
		return SendClientMessage(playerid, 0xFF0000FF, "Only admins can use this command!");

	new toplayerid, amount;

	if (sscanf(params, "ui", toplayerid, amount))
		return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /givemoney <playerid> <amount>");

        if (toplayerid == INVALID_PLAYER_ID)
                return SendClientMessage(playerid, -1, "Invalid player.");

        GivePlayerMoney(toplayerid, amount);
	format(message, sizeof(message), "You got $%d from admin!", amount);
	SendClientMessage(toplayerid, 0x00FF00FF, message);
	return 1;
}
Reply


Messages In This Thread
Givemoney command issue - by matje - 04.12.2016, 17:23
Re: Givemoney command issue - by GoldenLion - 04.12.2016, 17:50
Re: Givemoney command issue - by matje - 04.12.2016, 18:14
Re: Givemoney command issue - by AnthonyDaBestt - 04.12.2016, 18:18
Re: Givemoney command issue - by iLearner - 04.12.2016, 18:19
Re: Givemoney command issue - by RyderX - 04.12.2016, 18:26
Re: Givemoney command issue - by matje - 04.12.2016, 18:30
Re: Givemoney command issue - by RyderX - 04.12.2016, 18:32
Re: Givemoney command issue - by AnthonyDaBestt - 04.12.2016, 18:33

Forum Jump:


Users browsing this thread: 8 Guest(s)