Can't get IF statement to work properly
#1

So I'm trying to make this command:

Код:
COMMAND:savemats(playerid, params[])
{
	new amount;

	if (sscanf(params, "i", amount))
		return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /savemats <amount>");
		
	if (amount <= PlayerInfo[playerid][Mats])
	    return SendClientMessage(playerid, 0xFFFFFFFF, "You don't have that much mats.");
    if (amount <= 0)
	    return SendClientMessage(playerid, 0xFFFFFFFF, "You can't save 0 or less mats.");

    new message[40];
	PlayerInfo[playerid][Mats] = PlayerInfo[playerid][Mats] - amount;
	format(message, sizeof(message), "You saved %d mats to the team safe.", amount);
	SendClientMessage(playerid, 0x00FF00FF, message);
	return 1;
}
So In game I give myself 200 mats and try /savemats 50, but it always responds with "You don't have that much mats." I'm sure I made a dumb mistake but I just can't find it.
Reply


Messages In This Thread
Can't get IF statement to work properly - by matje - 05.12.2016, 18:28
Re: Can't get IF statement to work properly - by Konstantinos - 05.12.2016, 18:43
Re: Can't get IF statement to work properly - by matje - 05.12.2016, 22:36

Forum Jump:


Users browsing this thread: 1 Guest(s)