/setbounty, something new
#1

pawn Код:
if(strcmp(cmd, "/givebounty", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "{00A1FF}USAGE{FFFFFF}: /givebounty [playerid/PartOfName] [points]");
                return 1;
            }
            new playa;
            new money;
            playa = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            money = strval(tmp);
            if (PlayerInfo[playerid][pClubLeader] == 1)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GiveBounty(playa, money);
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "%s a primit %d Bounty Points de la %s.", giveplayer,money,sendername);
                        SendClubMessage(1, COLOR_LIGHTBLUE, string);
                    }
                }
            }
            else if (PlayerInfo[playerid][pClubLeader] == 2)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GiveBounty(playa, money);
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string, sizeof(string), "%s a primit %d Bounty Points de la %s.", giveplayer,money,sendername);
                        SendClubMessage(2, COLOR_LIGHTBLUE, string);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "Nu esti autorizat sa folosesti aceasta comanda!");
            }
        }
        return 1;
    }
This is the a command that gives bounty(Points required for Club Members to rank-up).
I want to create a command that sets the bounty.
Reply
#2

Can you share the GiveBounty function to know the variables or functions used?
Then you may get help.
Reply
#3

Show this function:
Quote:

GiveBounty(playa, money);

Because in this function you're adding some value. You can't add you must use equal symbol (=) to SET not add something (i suppose its: += 'NameOfParameter' in your function stock)
Reply
#4

pawn Код:
forward GiveBounty(playerid, value);
public GiveBounty(playerid, value)
{
    if(PlayerInfo[playerid][pClubLeader] == 1 || PlayerInfo[playerid][pClubMember] == 1)
    {
        PlayerInfo[playerid][pBounty] = PlayerInfo[playerid][pBounty] + value;
        new string[128];
        format(string, sizeof(string), "[NFS Club] Ai castigat %d Bounty Points", value);
        SendClientMessage(playerid, COLOR_GREEN, string);
    }
    else if(PlayerInfo[playerid][pClubLeader] == 2 || PlayerInfo[playerid][pClubMember] == 2)
    {
        PlayerInfo[playerid][pBounty] = PlayerInfo[playerid][pBounty] + value;
        new string[128];
        format(string, sizeof(string), "[NRG Club] Ai castigat %d Bounty Points", value);
        SendClientMessage(playerid, COLOR_GREEN, string);
    }
}
pawn Код:
if( strcmp( key , "Bounty" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBounty] = strval( val ); }
pawn Код:
PlayerInfo[playerid][pBounty] = 0;
pawn Код:
new bounty = PlayerInfo[targetid][pBounty];
format(var, 128, "Bounty=%d\n",PlayerInfo[playerid][pBounty]);fwrite(hFile, var);
format(var, 32, "Bounty=%d\n",PlayerInfo[playerid][pBounty]);fwrite(hFile, var);
Heres kinda everything about Bounty
Reply
#5

pawn Код:
PlayerInfo[playerid][pBounty] = PlayerInfo[playerid][pBounty] + value;
This line "GIVING" some value to the bounty multi-dimension array. So you should do something like that to SET some value than add.

pawn Код:
PlayerInfo[playerid][pBounty] = value;
But make a separate stock function with other name i.e. SetBounty(playerid, value);
Reply
#6

pawn Код:
stock SetPlayerBounty(playerid,bounty)
{
   return PlayerInfo[playerid][pBounty] = bounty;
}
Not tested.


Example
pawn Код:
CMD:setbounty(playerid,params[])
{
   if(PlayerInfo[playerid][pClubLeader] >= 1 || PlayerInfo[playerid][pClubMember] >= 1)
   {
     new bid;
     new bountyvalue;
     if(sscanf(params,"ui",bid,bountyvalue)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /setbounty [playerid] [bounty]");
    SetPlayerBounty(bid,bountyvalue);
   //Other message functions here.
  }
  else
  {
    SendClientMessage(playerid, 0xFF0000FF, "Your error message here");
   }
   return 1;
}
Reply
#7

I'm using strcmp btw.
Thanks a alot!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)