30.08.2009, 15:30
Here you go, a working code. Fixed also a couple of other small errors.
pawn Код:
dcmd_givecash(playerid,params[])
{
new
targetid,
amount;
if(sscanf(params, "ui", targetid, amount))
{
SendClientMessage(playerid, COLOUR_RED, "Use: /givecash [playerid] [amount]");
return true;
}
if(!IsPlayerConnected(targetid))
{
SendClientMessage(playerid, COLOUR_RED, "Incorrect playerid.");
return true;
}
if(amount < 1)
{
SendClientMessage(playerid, COLOUR_RED, "Invalid transaction amount");
return 1;
}
new
string[128],
pname[MAX_PLAYER_NAME],
pname2[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(targetid, pname2, sizeof(pname2));
format(string, sizeof(string), "%s sent you $%d", pname, amount);
SendClientMessage(targetid,COLOUR_GREEN, string);
format(string, sizeof(string), "You sent %s, $%d", pname2, amount);
SendClientMessage(playerid,COLOUR_GREEN, string);
GivePlayerMoney(targetid, amount);
GivePlayerMoney(playerid, -amount);
return true;
}

