SA-MP Forums Archive
/gm-givemoney - 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: /gm-givemoney (/showthread.php?tid=588601)



/gm-givemoney - Alcag - 10.09.2015

hello why when i write /gm 0(id) 5000(cash) -give me 0 dollars ? plz help



Re: /gm-givemoney - saffierr - 10.09.2015

It gives you $0 because the sscanf is not used correctly.
Your code is kinda wrong/fucked up.
You use sscanf 2 times, 1 time is enough.
PHP код:
CMD:gm(playerid, params[])
{
        if(!
IsPlayerAdmin(playerid)) return 0;
        new 
targetplayer, amount;
        if(
sscanf(params, "ui", targetplayer, amount))
        return 
SendClientMessage(playerid, COLOR_ORANGE, "Usage: /gm [ID] [amount]");
        if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
        new 
string[100], pName[MAX_PLAYER_NAME];
        
GivePlayerMoney(targetplayer, amount);
        
format(string, sizeof string, "An Admin has transferred $%i to you!", amount);
        
SendClientMessage(targetplayer, COLOR_GREEN, string);
        
GetPlayerName(targetplayer, pName, MAX_PLAYER_NAME);
        
format(string, sizeof string, "You have transferred $%i to %s.", amount, pName);
        
SendClientMessage(playerid, COLOR_WHITE, string);
        return 
1;
} 
Try this