/givemoney
#1

How to make a Command to give a Player anything Money? And that only Admins can use it?
Reply
#2

pawn Код:
if(strcmp(cmd, "/givemoney", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "{00A1FF}USAGE{FFFFFF}: /givemoney [playerid/PartOfName] [money]");
                return 1;
            }
            new playa;
            new money;
            playa = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            money = strval(tmp);
            if (PlayerInfo[playerid][pAdmin] >= 4)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        ConsumingMoney[playa] = 1;
                        GivePlayerMoney(playa, money);
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, 128, "AdmWarning: %s has admin given %d to %s.", sendername,money,giveplayer);
                        ABroadCast(COLOR_YELLOW,string,1);
                        AdminLog(string);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "Nu esti autorizat sa folosesti aceasta comanda!");
            }
        }
        return 1;
    }
You must update the admin variable to yours.
P.S. Sorry cause it's strcmp, but it's from my gm, I don't have time to make it with ycmd right now...
Reply
#3

I use ZCMD and sscanf, but thx.
Reply
#4

Here it is with zcmd and sscanf
pawn Код:
CMD:givemoney(playerid, params[])
{
    new targetid, amount;
    if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, -1, "usage - /givemoney <playerid/part of name> <amount>");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player is not connected");
GivePlayerMoney(targetid, amount);
return 1;
}
Reply
#5

What about if a player types "/givemoney 0 999999999"? Will it give 999 millions to that player even if he doesn't have them? lol
pawn Код:
CMD:givemoney( playerid, params[ ] )
{
    new
        id,
        money
    ;
    if( sscanf( params, "ud", id, money ) ) return SendClientMessage( playerid, -1, "Usage: /givemoney <id> <money>" );
    if( !IsPlayerConnected( id ) && id == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Invalid Player!" );
    if( GetPlayerMoney( playerid ) < money ) return SendClientMessage( playerid, -1, "You don't have that money" );
    GivePlayerMoney( playerid, money );
    return 1;
}
Reply
#6

@Ryder Works, thx.

And Dwane i mean that Admins can give to Players random Money. lol
Reply
#7

For that you will have to use the Random() function.
Reply
#8

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
For that you will have to use the Random() function.
by random he aint mean the random function. it is a way of expressing. i will gvie u random money haah
it doesnt mean i will take out my wallet, pick up some cash and hand it to you without knowing how much they are....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)