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

## Recommended Posts

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

salamat po

##### Share on other sites
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.";
}```

##### Share on other sites
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?

##### Share on other sites
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

##### Share on other sites

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

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
• Forums