06.09.2013, 08:01
I still see some minor mistakes:
Dusk and AaronKillz already gave you a solution, but here is the final code:
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...
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;
}