Jump to content
  • 0

Question

Posted

guys can you tell me if I have the right idea about this script

set $@prize, rand(1,100);
if ( $@prize <= 5 ) {
getitem ???, 1;
   announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize1",0;

}

if ( $@prize <= 1 ) {
getitem ???, 1; // Cool FB Hat
   announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize2",0;

}

if ( $@prize <= 10 ) {
getitem ???, 1;
getitem ???, 1;
   announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize3",0;
}

does this make it that if the random rolls to 5 which is <=5 also <= 10 will I get both items? or just the <= 5 item only?

8 answers to this question

Recommended Posts

Posted

prontera,155,180,5	script	test item reward#2	100,{
.@rand = rand( 17 + 33 + 50 ); // total 100
if ( .@rand < 17 ) { // /17/100 ... about 1/6 * 100%
	getitem 503, 1;
	getitem 504, 1;
	announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize3",0;
}
else if ( .@rand < 33 ) { // 33/100 ... about 1/3 * 100%
	getitem 501, 1;
	announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize2",0;
}
else { // the rest is 50/100, which is 1/2 * 100%
	getitem 502, 1; // Cool FB Hat
	announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize1",0;
}
end;
}

if you want make it 100%, then make the variable total up to 100 ...

Posted (edited)

If you want to get only 1 item at once, use 'end;'

Otherwise, it will give you multiple items at once.

prontera,161,182,4 script test123 110,{
set .@prize, rand(1,100);
if ( .@prize <= 1 ) {
 getitem 502, 1; // Cool FB Hat
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize1",0;
 end;
}

if ( .@prize <= 5 ) {
 getitem 501, 1;
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize2",0;
 end;
}

if ( .@prize <= 10 ) {
 getitem 503, 1;
 getitem 504, 1;
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize3",0;
}
end;
}

Edited by nanakiwurtz
Posted (edited)

If you want to get only 1 item at once, use 'end;'

Otherwise, it will give you multiple items at once.

prontera,161,182,4 script test123 110,{
set .@prize, rand(1,100);
if ( .@prize <= 1 ) {
 getitem 502, 1; // Cool FB Hat
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize1",0;
 end;
}

if ( .@prize <= 5 ) {
 getitem 501, 1;
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize2",0;
 end;
}

if ( .@prize <= 10 ) {
 getitem 503, 1;
 getitem 504, 1;
 announce "Poring Catcher : We have a winner, "+.@name$+". - won a prize3",0;
}
end;
}

ok thanks alot ^_^

now the chance for item 1 = 1% then item 2 is 4% right? since its 2-5 only?

Edited by cozzy09
Posted

ok ... just made a pinned topic

prontera,155,180,5    script    test item reward#2    100,{
   .@rand = rand( 1 + 5 + 10 ); // total 16
   if ( .@rand < 1 ) { // 1/16
       getitem 503, 1;
       getitem 504, 1;
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize3",0;
   }
   else if ( .@rand < 1+5 ) { // 5/16
       getitem 501, 1;
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize2",0;
   }
   else { // the rest
       getitem 502, 1; // Cool FB Hat
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize1",0;
   }
   end;
}

Posted

ok ... just made a pinned topic

prontera,155,180,5    script    test item reward#2    100,{
   .@rand = rand( 1 + 5 + 10 ); // total 16
   if ( .@rand < 1 ) { // 1/16
       getitem 503, 1;
       getitem 504, 1;
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize3",0;
   }
   else if ( .@rand < 1+5 ) { // 5/16
       getitem 501, 1;
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize2",0;
   }
   else { // the rest
       getitem 502, 1; // Cool FB Hat
       announce "Poring Catcher : We have a winner, "+ strcharinfo(0) +". - won a prize1",0;
   }
   end;
}

I'm a little bit confused about your code XD

if will give me a 1/16 % chance of getting the item and the else only will give me all the remaining chances but what about the else if? is it 2% or a total of 6% chance of getting the item?

Join the conversation

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

Guest
Answer this question...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...