ADMSarah Posted January 30 Group: Members Topic Count: 18 Topics Per Day: 0.03 Content Count: 144 Reputation: 10 Joined: 08/19/23 Last Seen: Yesterday at 07:17 AM Share Posted January 30 Can someone help me to modify this function? Quote function script AROCG { .@amt = rand(1,100); getitem 50007,.@amt; announce "["+strcharinfo(0)+"] got [ "+.@amt+"x "+getitemname(50007)+"] from AsurielRO Coins Bag.",0; end; } I want the following: 1 to 10 = 99% 11 to 20 = 80% 21 to 30 = 75% 31 to 50 = 50% 51 to 100 = 1% The announcement also includes what are the percentage of each category. Quote Link to comment Share on other sites More sharing options...
0 rokimoki Posted January 30 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 75 Reputation: 11 Joined: 12/16/11 Last Seen: Thursday at 06:51 PM Share Posted January 30 5 hours ago, Questune said: Can someone help me to modify this function? I want the following: 1 to 10 = 99% 11 to 20 = 80% 21 to 30 = 75% 31 to 50 = 50% 51 to 100 = 1% The announcement also includes what are the percentage of each category. Hello, I think there is a mistake in % thinking... all % must be 100, you can't calculate 99% 1 to 10 or 50% 11 to 20, must be something like: 49% -> 1 to 10 coins 25% -> 11 to 20 coins 15% -> 21 to 30 coins 5% -> 31 to 50 coins 1% -> 51 to 100 coins function script AROCG { set .@luckyRate, rand(100); set .@amount, rand(51, 100); // 1% chance set .@chance$, "1%"; if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance set .@amount, rand(1, 10); set .@chance$, "50%"; } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance set .@amount, rand(11, 20); set .@chance$, "25%"; } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 15% chance set .@amount, rand(21, 30); set .@chance$, "15%"; } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 5% chance set .@amount, rand(31, 50); set .@chance$, "5%"; } getitem 50007, .@amount; announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0; end; } Test before going production, I could not test, but I'm pretty sure this works 100%. 1 Quote Link to comment Share on other sites More sharing options...
0 ADMSarah Posted January 31 Group: Members Topic Count: 18 Topics Per Day: 0.03 Content Count: 144 Reputation: 10 Joined: 08/19/23 Last Seen: Yesterday at 07:17 AM Author Share Posted January 31 Thank you! works perfectly! Quote Link to comment Share on other sites More sharing options...
0 rokimoki Posted January 31 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 75 Reputation: 11 Joined: 12/16/11 Last Seen: Thursday at 06:51 PM Share Posted January 31 Sorry I did a mistake copying paste, this is the proper version corresponding to the % configured. function script AROCG { set .@luckyRate, rand(100); set .@amount, rand(51, 100); // 1% chance set .@chance$, "1%"; if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance set .@amount, rand(1, 10); set .@chance$, "50%"; } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance set .@amount, rand(11, 20); set .@chance$, "25%"; } else if (.@luckyRate >= 74 && .@luckyRate < 89) { // 15% chance set .@amount, rand(21, 30); set .@chance$, "15%"; } else if (.@luckyRate >= 89 && .@luckyRate < 94) { // 5% chance set .@amount, rand(31, 50); set .@chance$, "5%"; } getitem 50007, .@amount; announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0; end; } 1 Quote Link to comment Share on other sites More sharing options...
0 ADMSarah Posted January 31 Group: Members Topic Count: 18 Topics Per Day: 0.03 Content Count: 144 Reputation: 10 Joined: 08/19/23 Last Seen: Yesterday at 07:17 AM Author Share Posted January 31 12 minutes ago, rokimoki said: Sorry I did a mistake copying paste, this is the proper version corresponding to the % configured. function script AROCG { set .@luckyRate, rand(100); set .@amount, rand(51, 100); // 1% chance set .@chance$, "1%"; if (.@luckyRate >= 0 && .@luckyRate < 49) {// 49% chance set .@amount, rand(1, 10); set .@chance$, "50%"; } else if (.@luckyRate >= 49 && .@luckyRate < 74) { // 25% chance set .@amount, rand(11, 20); set .@chance$, "25%"; } else if (.@luckyRate >= 74 && .@luckyRate < 89) { // 15% chance set .@amount, rand(21, 30); set .@chance$, "15%"; } else if (.@luckyRate >= 89 && .@luckyRate < 94) { // 5% chance set .@amount, rand(31, 50); set .@chance$, "5%"; } getitem 50007, .@amount; announce "[" + strcharinfo(0) + "]: got [" + .@amount + "x " + getitemname(50007) + "] at " + .@chance$ + "% chance, from AsurielRO Coins Bag.", 0; end; } Thanks Mate! Quote Link to comment Share on other sites More sharing options...
Question
ADMSarah
Can someone help me to modify this function?
I want the following:
The announcement also includes what are the percentage of each category.
Link to comment
Share on other sites
4 answers to this question
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.