Raised This Month: $ Target: $400
 0% 

Help with random choose...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KaPaTeJIb
Member
Join Date: Oct 2012
Location: Tbilisi
Old 08-31-2013 , 08:14   Help with random choose...
Reply With Quote #1

Hi all again, I have a plugin, this is math games, each round is a competiton and if someone answers right, he'll win something. I want to include prize's random choice...Please help, thanks =)
Attached Files
File Type: sma Get Plugin or Get Source (MathematicsGame.sma - 519 views - 4.0 KB)

Last edited by KaPaTeJIb; 08-31-2013 at 08:17. Reason: Forgot sma...
KaPaTeJIb is offline
Send a message via Skype™ to KaPaTeJIb
Old 08-31-2013, 08:15
KaPaTeJIb
This message has been deleted by KaPaTeJIb.
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-31-2013 , 09:23   Re: Help with random choose...
Reply With Quote #2

Equal chance:
Code:
switch( random(4) ) {     case 0: // Do something     case 1: // Do something     case 2: // Do something     case 3: // Do something }
Percentages:
Code:
switch( random_num(1, 100) ) {     case 1 .. 5: // Do something, 5%     case 6 .. 49: // Do something, 44%     case 50: // Do something, 1%     case 51 .. 100: // Do something, 50% }
__________________

Last edited by Black Rose; 08-31-2013 at 11:42. Reason: Sorry about that.
Black Rose is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 08-31-2013 , 09:36   Re: Help with random choose...
Reply With Quote #3

random_prize = random_num( minimum_prize, maximum_prize )

??
akcaliberg is offline
KaPaTeJIb
Member
Join Date: Oct 2012
Location: Tbilisi
Old 08-31-2013 , 09:47   Re: Help with random choose...
Reply With Quote #4

Quote:
Originally Posted by Black Rose View Post
Equal chance:
Code:
switch( random(3) ) {     case 0: // Do something     case 1: // Do something     case 2: // Do something     case 3: // Do something }
your method is better, thank you
KaPaTeJIb is offline
Send a message via Skype™ to KaPaTeJIb
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-31-2013 , 10:00   Re: Help with random choose...
Reply With Quote #5

Pay attention there is no case 3 in random(3)

random(3) is same as random_num(0, 2)

code can't generate errors but case 3 gonna never be called.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-31-2013 , 11:43   Re: Help with random choose...
Reply With Quote #6

Sorry about that. I edited my post to avoid confusion.
__________________
Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode