Jump to content
  • 0

random item


cozzy09

Question


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

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?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

its not by 100% percent, but per-total

1/16 chance get prize3

5/16 chance get prize2

10/16 chance get prize1

16 is the total of 1+5+10

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

yup but can't I just put 16 in there hahaha XD

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  53
  • Reputation:   0
  • Joined:  01/30/12
  • Last Seen:  

ok thank you so much for enlightening me hahahaha

topic closed ^_^

Link to comment
Share on other sites

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.

×
×
  • Create New...