SA-MP Forums Archive
Givecash with SSCANF2 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Givecash with SSCANF2 (/showthread.php?tid=171661)



Givecash with SSCANF2 - LZLo - 27.08.2010

Givecash with SSCANF2

I NEED A GOOD GIVECASH COMMAND!

pls help!


Re: Givecash with SSCANF2 - Claude - 27.08.2010

pawn Code:
dcmd_givecash(playerid, params[])
{
    new giveplayerid, cash;
    if(sscanf("ud", giveplayerid, cash)) SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /givecash [id] [amount]");
    else if(GetPlayerMoney(playerid) < cash)) return SendClientMessage(playerid, 0xFFFFFFFF,"You have not enough cash!");
    else
    {
        GivePlayerMoney(giveplayerid, cash);
        GivePlayerMoney(playerid, -cash);
    }
    return 1;
}
There you go


Re: Givecash with SSCANF2 - LZLo - 27.08.2010

a better command?


Re: Givecash with SSCANF2 - LZLo - 27.08.2010

PHP Code:
dcmd_givecash(playerid,params[])
{
     new 
ID,Ammount;
     if(
sscanf(params,"dd",ID,Ammount)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /Givecash < Player ID > < Ammount >");
     if(!
IsPlayerConnected(playerid)) return SendClientMessage(playerid,COLOR_RED,"Invalid User!");
     
GivePlayerMoney(ID,Ammount);
     
GivePlayerMoney(playerid,-Ammount);
     new 
Msg[128];
     
format(Msg,sizeof(Msg),"%s has sent you %d",ReturnPlayerName(ID),Ammount);
     
SendClientMessage(ID,COLOR_GREEN,Msg);
     
format(Msg,sizeof(Msg),"$%d sent to %s",Ammount,ReturnPlayerName(ID));
     
SendClientMessage(playerid,COLOR_GREEN,Msg);
     return 
1;

is it good??


Re: Givecash with SSCANF2 - LZLo - 27.08.2010

solved thx


Re: Givecash with SSCANF2 - Bumbis - 27.08.2010

I just looked at my includes and i saw that the INVALID_PLAYER_ID is a color, its strange that almost all scripters use that to check if the player is valid. in a_samp.inc it looks like this
#define INVALID_PLAYER_ID (0xFFFF)

and it defines color.. It's strange, do someone can explain me why? And sorry about offtopic, don't want to make another topic.