21.08.2013, 14:11
pawn Код:
if (strcmp("/givemoney", cmdtext, true, 10) == 0)
{
new tmp[128], tmp2[128], Index;
tmp = strtok(cmdtext,Index);
tmp2 = strtok(cmdtext,Index);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "Usage: /givemoney {FF0000}[Player ID] [Amount]");
if(!strlen(tmp2)) return SendClientMessage(playerid, -1, "Usage: /givemoney [Player ID] {FF0000}[Amount]");
new player1, cash, string[256];
player1 = strval(tmp);
cash = strval(tmp2);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
if(player1 == playerid) return SendClientMessage(playerid, -1, "ERROR: You can't give money to yourself!");
if(cash > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "ERROR: Insufficent funds!");
if(cash < 1) return SendClientMessage(playerid, -1, "ERROR: Invalid amount (Negative or zero)");
new name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], string[256];
GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(player1, name1, sizeof(name1));
format(string, sizeof(string), "You have given %s (%d) $%d.", name1, player1, cash);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "%s (%d) has given you $%d.", name, playerid, cash);
SendClientMessage(playerid, -1, string);
GivePlayerMoney(playerid, -cash);
GivePlayerMoney(player1, cash);
}
else return SendClientMessage(playerid, -1, "ERROR: This player is not connected!");
}