how to /givertoken
#1

ok i have a rewards system and i need a cmd like /givertoken PLAYERID AMOUNT and then it will tell the player that he has sucessfully receive AMOUNT tokens, and it will tlel the admin then you have successfully given ID AMOUNT tokens

i use [pAdmin]
and [pRewards] please help
Reply
#2

Use This its very helpful:
pawn Код:
// ------ givecash -----------------------------------------------------------------
dcmd_givecash(playerid, cmdtext[]) {
    new tmp[256],idx,giveplayerid,moneys,playermoney;
    tmp = strtok(cmdtext, idx);

    if(!strlen(tmp)) {
        SendClientMessageLang(playerid, COLOR_WHITE,"USAGE: /givecash [playerid] [amount]","WPISZ: /givecash [playerid] [kasa]");
        return 1;
    }
   
    giveplayerid = strval(tmp);
    tmp = strtok(cmdtext, idx);
   
    if(!strlen(tmp)) {
        SendClientMessageLang(playerid, COLOR_WHITE,"USAGE: /givecash [playerid] [amount]","WPISZ: /givecash [playerid] [kasa]");
        return 1;
    }
   
    moneys = strval(tmp);
   
    if (IsPlayerConnected(giveplayerid)) {
        playermoney = GetPlayerMoney(playerid);
        if (moneys > 0 && playermoney >= moneys) {
            GivePlayerMoney(playerid, (0 - moneys));
            GivePlayerMoney(giveplayerid, moneys);
            SendClientMessageLang(playerid, COLOR_YELLOW, "You have sent %s (id: %d), $%d.","Wysіaіeœ do %s (id: %d), $%d.", Player(giveplayerid),giveplayerid, moneys);
            SendClientMessageLang(giveplayerid, COLOR_YELLOW, "You have recieved from %s (id: %d) cash $%d.","Dostaіeœ od %s (id: %d) kase $%d.", Player(playerid), playerid,moneys);
        }
        else {
            SendClientMessageLang(playerid,COLOR_YELLOW,"Invalid transaction amount.","Zіa waluta.");
        }
    }
    else {
        SendClientMessageLang(playerid, COLOR_WARN,"Is not an active player.","To nie jest aktywny gracz.");
    }
    return 1;
}
Dont forget to add at the top:
pawn Код:
#include <a_samp>
#include <dudb>
Reply
#3

Not tested
pawn Код:
CMD:givetoken(playerid,params[])
{
    new id, name[24],name2[24],str[128],ammount;
    if(pInfo[playerid][pAdmin] >= 1) // change pInfo[playerid] to your own admin variable and 1 is the admin level. change it if you want to.
    {
        if(sscanf(params,"dd",id,ammount)) return SendClientMessage(playerid,-1,"USAGE: /givetoken [ID] [Ammount]");
        pInfo[playerid][pRewards] = ammount;
        GetPlayerName(playerid,name,24);
        GetPlayerName(id,name2,24);
        format(str,sizeof(str),"* Admin %s(%d) has gave you %d token(s)",name,playerid,ammount);
        SendClientMessage(id,-1,str);
        format(str,sizeof(str),"* You have gave %s(%d) %d token(s)",name2,id,ammount);
        SendClientMessage(playerid,-1,str);
     }
     else return SendClientMessage(playerid,-1,"You are not authorized to use this command!");
     return 1;
}
You need sscanf and zcmd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)