Givecash with SSCANF2
#1

Givecash with SSCANF2

I NEED A GOOD GIVECASH COMMAND!

pls help!
Reply
#2

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
Reply
#3

a better command?
Reply
#4

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??
Reply
#5

solved thx
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)