Jump to content
  • 0

Need help with Java code


DarkCore

Question

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!");

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Simple sample random:

 

if (Rnd.get(100) > 90)

{

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

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

}

 

Self-explanatory.

Link to comment
Share on other sites

  • 0

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%

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...