macmac88 Posted June 4, 2021 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 21 Reputation: 0 Joined: 05/15/21 Last Seen: August 30, 2021 Share Posted June 4, 2021 mga lodi paki explain naman paano kinocompute ung percentage ng rand function? salamat po Quote Link to comment Share on other sites More sharing options...
Scylla Posted June 5, 2021 Group: Members Topic Count: 47 Topics Per Day: 0.01 Content Count: 374 Reputation: 47 Joined: 03/27/13 Last Seen: Monday at 11:23 PM Share Posted June 5, 2021 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."; } 1 Quote Link to comment Share on other sites More sharing options...
macmac88 Posted June 5, 2021 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 21 Reputation: 0 Joined: 05/15/21 Last Seen: August 30, 2021 Author Share Posted June 5, 2021 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? Quote Link to comment Share on other sites More sharing options...
Scylla Posted June 5, 2021 Group: Members Topic Count: 47 Topics Per Day: 0.01 Content Count: 374 Reputation: 47 Joined: 03/27/13 Last Seen: Monday at 11:23 PM Share Posted June 5, 2021 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 1 Quote Link to comment Share on other sites More sharing options...
macmac88 Posted June 7, 2021 Group: Members Topic Count: 6 Topics Per Day: 0.00 Content Count: 21 Reputation: 0 Joined: 05/15/21 Last Seen: August 30, 2021 Author Share Posted June 7, 2021 thank you very much... i get the idea now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.