Jump to content
  • 0

Random chance pvp rewards?


Question

Posted

I'm looking for a guide that could help me add random chance a player can get an item reward for a pvp kill. Example would be something like

Player 1 Kills Player 2:

10% chance of getting gold bar.

25% chance of getting AA

 

I would like to have a few items that have a random chance to get or maybe add all those items to a custom compressed pack that has a random chance to open into 1 of those items.

8 answers to this question

Recommended Posts

  • 0
Posted
if (Rnd.get(100) > 50)

{

      //give reward

}

 

Chance - 50%

 

About reward after pvp, its already shared, use search.

  • 0
Posted

int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP;

addItem("Loot", 5139, itemReward, this, true);

                        if (Rnd.get(100) > 50)

                        {

                          //give reward

                        }

would that be correct?

  • 0
Posted

                        if (Rnd.get(100) > 50)

                        {

                          addItem("Loot", 5139, itemReward, this, true);

                        }

that would be probably correct(i dont remember all parameters of addItem method, so i am not sure about that)

  • 0
Posted

int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP;

addItem("Loot", 5139, itemReward, this, true);

                        if (Rnd.get(100) > 50)

                        {

                          //give reward

                        }

would that be correct?

 

Did that work id like to try to make something like this for my server?

  • 0
Posted

I added

int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP;

        if (Rnd.get(100) > 50)

        addItem("Loot", 5139, itemReward, this, true);

                       {

                        }

 

still gives me 5139 100%

  • 0
Posted

Using brain doesn't hurt.

 

         int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP;

         if (Rnd.get(100) > 50)
         {
                addItem("Loot", 5139, itemReward, this, true);
         }

  • 0
Posted

Using brain doesn't hurt.

 

        int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP;

        if (Rnd.get(100) > 50)
        {
               addItem("Loot", 5139, itemReward, this, true);
        }

I typed the code in my post wrong, The only thing different from what you posted and what I had was there was no space between

int itemReward = Config.MOD_GVE_AMOUNT_PACK_BY_PVP; and

if (Rnd.get(100) >50)

 

but adding the space between the 2 made it work, so thank you.

  • 0
Posted

Simply right method wasn't in if check body.

 

Anyway as I can see problem solved, so topic locked.

Guest
This topic is now closed to further replies.


×
×
  • Create New...