help with /pay cmd
#5

I still see some minor mistakes:
pawn Код:
GetPlayerName(otherid, names, sizeof(namez)); // Name is assigned to "names" and sizeof is taken from "namez"...

format(string, sizeof(string), "%s gave you $%d", cash, namez); // "%s" assigned for cash and "$%d" assigned to the name...
Dusk and AaronKillz already gave you a solution, but here is the final code:
pawn Код:
CMD:pay(playerid, params[])
{
    new otherid, cash, string[128], namez[MAX_PLAYER_NAME], names[MAX_PLAYER_NAME];

    if (sscanf(params, "dd", otherid, cash)) SendClientMessage(playerid, COLOR_RED, "Usage: /pay [ID] [Cash]");

    if(!IsPlayerConnected(otherid)) return SendClientMessage(playerid, COLOR_RED, "That PlayerID is not connected!");  
    if(otherid == playerid) return SendClientMessage(playerid, COLOR_RED, "It is pointless to pay yourself..");
    if(GetPlayerMoney(playerid) < cash) return SendClientMessage(playerid, COLOR_RED, "You don't have that much!");

    GivePlayerMoney(playerid, -cash);
    GetPlayerName(otherid, names, sizeof(names));
    format(string, sizeof(string), "You gave $%d to %s", cash, names);
    SendClientMessage(playerid, COLOR_BLUE, string);  

    GivePlayerMoney(otherid, cash);
    GetPlayerName(playerid, namez, sizeof(namez));
    format(string, sizeof(string), "%s gave you $%d", namez, cash);
    SendClientMessage(otherid, COLOR_BLUE, string);
    return 1;
}
Reply


Messages In This Thread
help with /pay cmd - by bustern - 05.09.2013, 19:10
Re: help with /pay cmd - by bustern - 06.09.2013, 07:37
Re: help with /pay cmd - by dusk - 06.09.2013, 07:40
Re: help with /pay cmd - by AaronKillz - 06.09.2013, 07:51
Re: help with /pay cmd - by Dragonsaurus - 06.09.2013, 08:01
Re: help with /pay cmd - by bustern - 06.09.2013, 08:13
Re: help with /pay cmd - by Dragonsaurus - 06.09.2013, 08:14
Re: help with /pay cmd - by bustern - 06.09.2013, 08:16
Re: help with /pay cmd - by Dragonsaurus - 06.09.2013, 08:22
Re: help with /pay cmd - by AaronKillz - 06.09.2013, 08:24

Forum Jump:


Users browsing this thread: 2 Guest(s)