Eross Posted May 12, 2020 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: Monday at 11:47 AM Share Posted May 12, 2020 Hi ! Is it possible to make my random box have a chance of lower than 1% ? like .5% chance to get a certain jackpot item ? .. I have this script I dont remember who gave this to me .. setarray .i1[0],19824,40227,40239; // 1st Prize 5% set .i1random,rand(0,2); // Randomize Common Items; just change max amount if you add items set .chance, rand(100); if (.chance >= 1 && .chance <= 5){ getitem .i1[.i1random],1; announce "[Lucky Draw Machine]: ["+strcharinfo(0)+"] obtained 1x ["+getitemname(.i1[.i1random])+"] (5%).",0; announce "[Lucky Draw Machine]: Try your luck and Win Special Prizes.",0; specialeffect2 699; end; As you can see this script gives you a chance of 1 to 5% .. How can I make it a chance of lower than 1% ? thanks Quote Link to comment Share on other sites More sharing options...
0 Cretino Posted May 12, 2020 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 50 Reputation: 39 Joined: 01/13/12 Last Seen: April 19, 2023 Share Posted May 12, 2020 46 minutes ago, erjsanmiguel said: Hi ! Is it possible to make my random box have a chance of lower than 1% ? like .5% chance to get a certain jackpot item ? .. I have this script I dont remember who gave this to me .. setarray .i1[0],19824,40227,40239; // 1st Prize 5% set .i1random,rand(0,2); // Randomize Common Items; just change max amount if you add items set .chance, rand(100); if (.chance >= 1 && .chance <= 5){ getitem .i1[.i1random],1; announce "[Lucky Draw Machine]: ["+strcharinfo(0)+"] obtained 1x ["+getitemname(.i1[.i1random])+"] (5%).",0; announce "[Lucky Draw Machine]: Try your luck and Win Special Prizes.",0; specialeffect2 699; end; As you can see this script gives you a chance of 1 to 5% .. How can I make it a chance of lower than 1% ? thanks Yes, just change the 'range of rand' and you got it. Like this: Spoiler setarray .i1[0],19824,40227,40239; // 1st Prize 5% set .i1random,rand(0,2); // Randomize Common Items; just change max amount if you add items // Rate (1 = 0.01%, 10 = 0.10%, 100 = 1.00%, 1000 = 10.00%, 10000 = 100.00%) set .chance, 500; // 500 = 5.00% if (rand(10000) < .chance) { getitem .i1[.i1random],1; announce "[Lucky Draw Machine]: ["+strcharinfo(0)+"] obtained 1x ["+getitemname(.i1[.i1random])+"] (5%).",0; announce "[Lucky Draw Machine]: Try your luck and Win Special Prizes.",0; specialeffect2 699; end; } Quote Link to comment Share on other sites More sharing options...
0 Eross Posted May 12, 2020 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: Monday at 11:47 AM Author Share Posted May 12, 2020 33 minutes ago, Cretino said: Yes, just change the 'range of rand' and you got it. Like this: Reveal hidden contents setarray .i1[0],19824,40227,40239; // 1st Prize 5% set .i1random,rand(0,2); // Randomize Common Items; just change max amount if you add items // Rate (1 = 0.01%, 10 = 0.10%, 100 = 1.00%, 1000 = 10.00%, 10000 = 100.00%) set .chance, 500; // 500 = 5.00% if (rand(10000) < .chance) { getitem .i1[.i1random],1; announce "[Lucky Draw Machine]: ["+strcharinfo(0)+"] obtained 1x ["+getitemname(.i1[.i1random])+"] (5%).",0; announce "[Lucky Draw Machine]: Try your luck and Win Special Prizes.",0; specialeffect2 699; end; } Hi sir ! you mean from set .chance, rand(100); to what ? sorry hehe ^_^ Quote Link to comment Share on other sites More sharing options...
0 Patskie Posted May 12, 2020 Group: Members Topic Count: 50 Topics Per Day: 0.01 Content Count: 1702 Reputation: 241 Joined: 09/05/12 Last Seen: 2 hours ago Share Posted May 12, 2020 You can only use integer values when creating scripts so you have to adjust your rand() to achieve 0.5% chance if (rand(1000) < 5) means 0.5% if (rand(1000) < 1) means 0.1% if (rand(1000) < 10) means 1% 1 Quote Link to comment Share on other sites More sharing options...
0 Eross Posted May 12, 2020 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: Monday at 11:47 AM Author Share Posted May 12, 2020 8 minutes ago, Patskie said: You can only use integer values when creating scripts so you have to adjust your rand() to achieve 0.5% chance if (rand(1000) < 5) means 0.5% if (rand(1000) < 1) means 0.1% if (rand(1000) < 10) means 1% Okay sir thankyou sir @Patskie ^_^ Quote Link to comment Share on other sites More sharing options...
0 Cretino Posted May 12, 2020 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 50 Reputation: 39 Joined: 01/13/12 Last Seen: April 19, 2023 Share Posted May 12, 2020 (edited) 6 hours ago, erjsanmiguel said: Hi sir ! you mean from set .chance, rand(100); to what ? sorry hehe ^_^ Look the content in the spoiler in my first post here. There has a solution with an example how to use it... You'll need change the range of rand from '100' to '10000'. Rate (1 = 0.01%, 10 = 0.10%, 100 = 1.00%, 1000 = 10.00%, 10000 = 100.00%) And change the 'if' from: if (.chance >= 1 && .chance <= 5){ To: if (rand(10000) < .chance){ And change the value of variable '.chance' to the rate you want: From: set .chance, rand(100); To: set .chance, 500; // 500 = 5.00% Edited May 12, 2020 by Cretino 1 Quote Link to comment Share on other sites More sharing options...
0 Eross Posted May 12, 2020 Group: Members Topic Count: 166 Topics Per Day: 0.09 Content Count: 377 Reputation: 12 Joined: 04/05/20 Last Seen: Monday at 11:47 AM Author Share Posted May 12, 2020 1 hour ago, Cretino said: Look the content in the spoiler in my first post here. There has a solution with an example how to use it... You'll need change the range of rand from '100' to '10000'. Rate (1 = 0.01%, 10 = 0.10%, 100 = 1.00%, 1000 = 10.00%, 10000 = 100.00%) And change the 'if' from: if (.chance >= 1 && .chance <= 5){ To: if (rand(10000) < .chance){ And change the value of variable '.chance' to the rate you want: From: set .chance, rand(100); To: set .chance, 500; // 500 = 5.00% I get it clearly sir thankyou for the explanation ..I learned a lot Quote Link to comment Share on other sites More sharing options...
Question
Eross
Hi ! Is it possible to make my random box have a chance of lower than 1% ? like .5% chance to get a certain jackpot item ? ..
I have this script I dont remember who gave this to me ..
setarray .i1[0],19824,40227,40239; // 1st Prize 5% set .i1random,rand(0,2); // Randomize Common Items; just change max amount if you add items set .chance, rand(100); if (.chance >= 1 && .chance <= 5){ getitem .i1[.i1random],1; announce "[Lucky Draw Machine]: ["+strcharinfo(0)+"] obtained 1x ["+getitemname(.i1[.i1random])+"] (5%).",0; announce "[Lucky Draw Machine]: Try your luck and Win Special Prizes.",0; specialeffect2 699; end;
As you can see this script gives you a chance of 1 to 5% .. How can I make it a chance of lower than 1% ? thanks
Link to comment
Share on other sites
6 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.