31.10.2015, 13:54
Hello guys,
I made a /givecash command for my script. I want this:
/givecash Player1 100
If I send a player money I see in the chat:
* You sent $100 to player1
and the player see in the chat:
* You have received $100 from player2
If I dont have amount money:
* Sorry, invalid transaction... you dont have $100.
If I try to give myself money:
* Sorry, you cannot give cash to yourself!
If I typed the command wrong:
** Usage: /givecash <PlayerID/PlayerName> <MoneyAmount>
* Gives the specified amount of your money to the player specified.
My Command:
There is only a problem with the SendClientMessages.
I made a /givecash command for my script. I want this:
/givecash Player1 100
If I send a player money I see in the chat:
* You sent $100 to player1
and the player see in the chat:
* You have received $100 from player2
If I dont have amount money:
* Sorry, invalid transaction... you dont have $100.
If I try to give myself money:
* Sorry, you cannot give cash to yourself!
If I typed the command wrong:
** Usage: /givecash <PlayerID/PlayerName> <MoneyAmount>
* Gives the specified amount of your money to the player specified.
My Command:
Код:
CMD:givecash(playerid, params[]) { new player, amount,name1[24], name2[24], string[128]; if(!sscanf(params, "ui",player,amount)) { if(playerid != player) { if(GetPlayerMoney(playerid) >= amount) { GetPlayerName(playerid, name1, 24); GetPlayerName(player, name2, 24); format(string, sizeof(string), "* You send $%d to %s",amount,name2); SendClientMessage(playerid, COLOR_GREY2, string); format(string, sizeof(string), "* You have received $%d from %s", amount, name1); SendClientMessage(player, COLOR_GREY2, string); GivePlayerMoney(playerid, -amount); GivePlayerMoney(player, amount); } else return format(string, sizeof(string), "* Sorry, invalid transaction... you dont have $%d!",amount); SendClientMessage(playerid, COLOR_ERROR_YELLOW, string); } else return SendClientMessage(playerid, COLOR_ERROR_YELLOW,"* Sorry, you cannot give cash to yourself!"); } else return SendClientMessage(playerid, COLOR_ERROR_YELLOW,"** Usage: /givecash <PlayerID/PlayerName> <MoneyAmount>"); SendClientMessage(playerid, COLOR_ERROR_YELLOW,"* Gives the specified amount of your money to the player specified."); return 1; }