Jump to content
  • 0

Need help with Java code


Question

Posted

Hello, i want  to make one thing, but i don't really know how.

 

I want to make PVP reward by chance, not to always give reward, but like 20%, how is it possible?

How should code look like?

 

here the code that i use:

addItem("Loot", 57, 10000000, this, true);

sendMessage("You won 10kk for PVP kill!");

3 answers to this question

Recommended Posts

  • 0
Posted

Simple sample random:

 

if (Rnd.get(100) > 90)

{

      addItem("Loot", 57, 10000000, this, true);

      sendMessage("You won 10kk for PVP kill!");

}

 

Self-explanatory.

  • 0
Posted

Use your brain, and You will understand it.

 

We are getting random number (max 100)

 

So lets say, it will give random number 95

 

95 is > 90 so code from brackets will be executed (when rnd will return random 91,92,93,94,95,96,97,98,99,100)

 

- ten bumbers, so guess what? Chance in this case is ...10%

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock