/GIVECASH PROBLEM
#1

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:

Код:
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;
}
There is only a problem with the SendClientMessages.
Reply
#2

Код:
        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;
Is it allowed to write 2 SendClientMessage under else return `?
Reply
#3

PHP код:
ReturnName(playeridunderscore=1// by Emmet_
{
    static
        
name[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridnamesizeof(name));
    if (!
underscore) {
        for (new 
0len strlen(name); len++) {
            if (
name[i] == '_'name[i] = ' ';
        }
    }
    return 
name;
}
CMD:givecash(playeridparams[])
{
    new 
useridamountstr[128];
    if (!
sscanf(params"ui"useridarmount))
        return 
SendClientMessage(playerid, -1"usage: /givecash [playerid/name] [amount]");
        
    if (
userid == playerid || !IsPlayerConnected(userid) || !IsPlayerConnected(playerid))
        return 
SendClientMessage(playerid, -1"error: You have entered an invalid playerid/name!");
        
    if (
amount || amount GetPlayerMoney(playerid))
        return 
SendClientMessage(playerid, -1"error: You have entered an invalid amount!");
        
    
GivePlayerMoney(playerid, -amount);
    
GivePlayerMoney(useridamount);
    
    
format(strsizeof(str), "info: You have received $%i from %s."amountReturnName(playerid0));
    
SendClientMessage(userid, -1str);
    
    
format(strsizeof(str), "info: You have given $%i from %s."amountReturnName(userid0));
    
SendClientMessage(playerid, -1str);
    
retrun 1;

Reply
#4

No, my Command is working but he shows all SendClientMessages.

Reply
#5

PHP код:
CMD:givecash(playeridparams[])
{
    new 
playeramount,name1[24], name2[24], string[128];
    if(!
sscanf(params"ui",player,amount))
    {
        if(
playerid != player)
        {
            if(
GetPlayerMoney(playerid) >= amount)
            {
                
GetPlayerName(playeridname124);
                
GetPlayerName(playername224);
                
format(stringsizeof(string), "* You send $%d to %s",amount,name2);
                
SendClientMessage(playeridCOLOR_GREY2string);
                
format(stringsizeof(string), "* You have received $%d from %s"amountname1);
                
SendClientMessage(playerCOLOR_GREY2string);
                
GivePlayerMoney(playerid, -amount);
                
GivePlayerMoney(playeramount);
                                return 
1;
            }
            else {
            
format(stringsizeof(string), "* Sorry, invalid transaction... you dont have $%d!",amount);
        return 
SendClientMessage(playeridCOLOR_ERROR_YELLOWstring);}
        }
        else return 
SendClientMessage(playeridCOLOR_ERROR_YELLOW,"* Sorry, you cannot give cash to yourself!");
    }
    else {
    
SendClientMessage(playeridCOLOR_ERROR_YELLOW,"** Usage: /givecash <PlayerID/PlayerName> <MoneyAmount>");
     return 
SendClientMessage(playeridCOLOR_ERROR_YELLOW,"* Gives the specified amount of your money to the player specified.");}

Reply
#6

Finally, it's perfect. Thank you so much
(REP+)
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)