05.09.2013, 19:10
PHP код:
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(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "It is pointless to pay yourself..");
else
{
if(GetPlayerMoney(playerid) < cash) SendClientMessage(playerid, COLOR_RED, "You don't have that much!");
else if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "That PlayerID is not connected!");
else
{
GivePlayerMoney(playerid, -cash);
GetPlayerName(otherid,names,sizeof(namez));
format(string,sizeof(string),"You gave $%d to %s",cash,names);
SendClientMessage(otherid,COLOR_BLUE,string);
}
{
GivePlayerMoney(otherid, cash);
GetPlayerName(playerid,namez,sizeof(namez));
format(string,sizeof(string),"%s gave you $%d",cash,namez);
SendClientMessage(otherid,COLOR_BLUE,string);
}
}
return 1;
}