Jump to content

explain paano kinocompute % ng rand(#)==#


Recommended Posts


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.01
  • Content Count:  21
  • Reputation:   0
  • Joined:  05/15/21
  • Last Seen:  

mga lodi paki explain naman paano kinocompute ung percentage ng rand function?

salamat po

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  374
  • Reputation:   46
  • Joined:  03/27/13
  • Last Seen:  

18 hours ago, macmac88 said:

mga lodi paki explain naman paano kinocompute ung percentage ng rand function?

salamat po

Technically it's not percentage.

rand(7) = random between 0,1,2,3,4,5,6

rand(3) = random between 0,1,2

rand (1,5) = random between 1,2,3,4,5

rand function will always pick one random number depending on what you specified

So example:

if (rand(5) == 1){
mes "Number 1 was picked via rand!";
} else {
mes "Either 0, 2, 3 or 4 was picked.";
}

 

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.01
  • Content Count:  21
  • Reputation:   0
  • Joined:  05/15/21
  • Last Seen:  

1 hour ago, Scylla said:

Technically it's not percentage.

rand(7) = random between 0,1,2,3,4,5,6

rand(3) = random between 0,1,2

rand (1,5) = random between 1,2,3,4,5

rand function will always pick one random number depending on what you specified

So example:


if (rand(5) == 1){
mes "Number 1 was picked via rand!";
} else {
mes "Either 0, 2, 3 or 4 was picked.";
}

 

thank you very much... i thought it was a percentage value where  1% you get the rare item and 100% you get the junk items or none.

what function in mind best describe my example, where 1% you get rare and 100% you get junk or vice versa?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  374
  • Reputation:   46
  • Joined:  03/27/13
  • Last Seen:  

27 minutes ago, macmac88 said:

thank you very much... i thought it was a percentage value where  1% you get the rare item and 100% you get the junk items or none.

what function in mind best describe my example, where 1% you get rare and 100% you get junk or vice versa?

You can basically still use rand for this.

You can do like this if you want it only 1%:

if (rand(1,100) == 1){
  mes "Congratulations! You won!";
  getitem 1161,1; // 1161 = Balmung
  } else {
  mes "Sorry, you lose";
  getitem 909,1; // 909 = Jellopy
}

 

Or if example you want to have 25% chance of getting a good item, you can do it this way:

if (rand(1,100) <= 25){ // If it picks numbers 1 - 25 = success else fail
                      

There should be better ways to do this than the method above. Just search in the forums / google it ?

  • Love 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.01
  • Content Count:  21
  • Reputation:   0
  • Joined:  05/15/21
  • Last Seen:  

thank you very much... i get the idea now

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.

Guest
Reply to this topic...

×   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...