/givecash Help
#1

Hello!

I have a new command /givecash for players, so players can do /givecash [playerid] [amount] to give his cash to someone...But it doesn't work -.-

Can someone fix it?

Code:

PHP код:
CMD:givecash(playeridparams[])
{
    new 
targetidcashstring[160];
    if(
sscanf(params"u"targetidcash))return SendClientMessage(playerid, -1"Usage: /givecash [playerid] [amount]");
    if(!
IsPlayerConnected(targetid))return SendClientMessage(playerid, -1"ERROR: This Player is Not Connected.");
    
GivePlayerMoney(targetidcash);
    if(
GetPlayerMoney(playerid) <= cash )return SendClientMessage(playerid, -1"ERROR: You Don't Have Enough Money");
    
format(stringsizeof(string), "[INFO]: %s Has Given $%d Cash To %s"GetName(playerid), cashGetName(targetid));
    
SendClientMessageToAll(-1string);
    return 
1;

I get no errors or warnings...Thanks for your help
Reply
#2

pawn Код:
if(sscanf(params, "ui", targetid, cash))
Reply
#3

pawn Код:
if(sscanf(params, "ui", targetid, cash)) return
Reply
#4

PHP код:
CMD:givecash(playeridparams[]) 

    new 
targetidcashstring[160]; 
    if(
sscanf(params"ui"targetidcash))return SendClientMessage(playerid, -1"Usage: /givecash [playerid] [amount]"); 
    if(!
IsPlayerConnected(targetid))return SendClientMessage(playerid, -1"ERROR: This Player is Not Connected."); 
    
GivePlayerMoney(targetidcash); 
    if(
GetPlayerMoney(playerid) <= cash )return SendClientMessage(playerid, -1"ERROR: You Don't Have Enough Money"); 
    
format(stringsizeof(string), "[INFO]: %s Has Given $%d Cash To %s"GetName(playerid), cashGetName(targetid)); 
    
SendClientMessageToAll(-1string); 
    return 
1

Reply
#5

I just realized your command doesn't make sense. First you give money and then you check does he actually have that amount & you never take money from him.

pawn Код:
CMD:givecash(playerid, params[])
{
    new targetid, cash, string[160];
    if(sscanf(params, "ui", targetid, cash)) return SendClientMessage(playerid, -1, "Usage: /givecash [playerid] [amount]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "ERROR: This Player is Not Connected.");
    if(GetPlayerMoney(playerid) < cash ) return SendClientMessage(playerid, -1, "ERROR: You Don't Have Enough Money");
    GivePlayerMoney(playerid, -cash);
    GivePlayerMoney(targetid, cash);
    format(string, sizeof(string), "[INFO]: %s Has Given $%d Cash To %s", GetName(playerid), cash, GetName(targetid));
    SendClientMessageToAll(-1, string);
    return 1;
}
Reply
#6

Also, adding onto what Dimi is saying, do you know how much spam you will receive from people giving out 1$ at a time? It'll be constant.
Reply
#7

Thanks guys
Reply
#8

Also to point out, make sure you check is cash > 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)