SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/04/2013, 10:42 AM   #1
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Question /givecash Help

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 Code:
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
Areax is offline   Reply With Quote
Old 14/04/2013, 10:44 AM   #2
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,179
Reputation: 311
Default Re: /givecash Help

pawn Code:
if(sscanf(params, "ui", targetid, cash))
RajatPawar is offline   Reply With Quote
Old 14/04/2013, 10:45 AM   #3
[MG]Dimi
High-roller
 
[MG]Dimi's Avatar
 
Join Date: Mar 2011
Location: Serbia
Posts: 1,239
Reputation: 144
Default Re: /givecash Help

pawn Code:
if(sscanf(params, "ui", targetid, cash)) return
__________________
Scripting Admin/Account/VIP Systems for $$$ using ZCMD,dcmd, Dini, MySQL and sscanf.Scripting IRC Systems with all possible functions. (Echo channels, Chat channels, Admin channels...)Long time Experience with IRC Systems.For both offers PM me
Mini Games ServerServer IP:178.238.236.62:7777
[MG]Dimi is offline   Reply With Quote
Old 14/04/2013, 10:46 AM   #4
M3mPHi$_S3
Gangsta
 
M3mPHi$_S3's Avatar
 
Join Date: Jun 2012
Location: Quetta, pk
Posts: 642
Reputation: 35
Default Re: /givecash Help

PHP Code:
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

__________________
~Stats|" Fully ACtive now "~
~********|" мυ∂υℓ ******** "~
~Tutorial|" How to port forword [PICS & VEDIOS] "~

Code:
public OnPlayerAskHelp(playerid, help[])
{
    SetReplyForPlayer(playerid, I Wont Help you :D ");
[/CENTER]
M3mPHi$_S3 is offline   Reply With Quote
Old 14/04/2013, 10:52 AM   #5
[MG]Dimi
High-roller
 
[MG]Dimi's Avatar
 
Join Date: Mar 2011
Location: Serbia
Posts: 1,239
Reputation: 144
Default Re: /givecash Help

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 Code:
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;
}
__________________
Scripting Admin/Account/VIP Systems for $$$ using ZCMD,dcmd, Dini, MySQL and sscanf.Scripting IRC Systems with all possible functions. (Echo channels, Chat channels, Admin channels...)Long time Experience with IRC Systems.For both offers PM me
Mini Games ServerServer IP:178.238.236.62:7777
[MG]Dimi is offline   Reply With Quote
Old 14/04/2013, 10:55 AM   #6
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: /givecash Help

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.
Isolated is offline   Reply With Quote
Old 14/04/2013, 11:01 AM   #7
Areax
Huge Clucker
 
Areax's Avatar
 
Join Date: Mar 2013
Location: Slovenia
Posts: 464
Reputation: 14
Default Re: /givecash Help

Thanks guys
Areax is offline   Reply With Quote
Old 14/04/2013, 07:42 PM   #8
[MG]Dimi
High-roller
 
[MG]Dimi's Avatar
 
Join Date: Mar 2011
Location: Serbia
Posts: 1,239
Reputation: 144
Default Re: /givecash Help

Also to point out, make sure you check is cash > 0
__________________
Scripting Admin/Account/VIP Systems for $$$ using ZCMD,dcmd, Dini, MySQL and sscanf.Scripting IRC Systems with all possible functions. (Echo channels, Chat channels, Admin channels...)Long time Experience with IRC Systems.For both offers PM me
Mini Games ServerServer IP:178.238.236.62:7777
[MG]Dimi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help /givecash [MKD]Max Help Archive 1 30/07/2011 11:47 AM
Givecash bug [LSB]TheGame Help Archive 1 22/04/2011 06:09 PM
Givecash thimo Help Archive 6 04/02/2011 09:30 PM
/givecash 02manchestera Help Archive 3 14/03/2010 03:51 PM
/givecash amrour Help Archive 5 15/02/2009 04:55 PM


All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.