26.03.2011, 22:25
does any1 have a simple dcmd_givecash the one off wiki is pretty lame and i need one thanks
public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(givecash, 8, cmdtext); return 0; } dcmd_givecash(playerid, params[]) { new giveplayerid, amount; if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]"); else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds"); else { GivePlayerMoney(giveplayerid, amount); GivePlayerMoney(playerid, 0 - amount); SendClientMessage(playerid, 0x00FF00AA, "Money sent"); SendClientMessage(giveplayerid, 0x00FF00AA, "Money received"); } return 1; }
dcmd_givecash(playerid, params[])
{
new id, amount, name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME], string[128];
if (sscanf(params, "ud", id, amount)) SendClientMessage(playerid, -1, "Usage: /givecash <playerid/name> <amount of cash>");
if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, "This player is not connected");
if(id == playerid) SendClientMessage(playerid, -1, "You can't give money to yourself");
if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, -1, "You don't have enough money");
if(amount < 1) SendClientMessage(playerid, -1, "You can not give less than 1 dollar");
else
{
GetPlayerName(id, name, sizeof(name));
GetPlayerName(playerid, name2, sizeof(name2));
GivePlayerMoney(id, amount);
GivePlayerMoney(playerid, 0 - amount);
format(string, sizeof(string), "You gave $%d to %s",amount, name);
format(string, sizeof(string), "You recived $%d from %s",amount, name2);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string);
}
return 1;
}
pawn Код:
|