Raised This Month: $ Target: $400
 0% 

Random number


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 11-26-2010 , 18:54   Random number
Reply With Quote #1

So I want to pick a random number and do different things for every pick.

PHP Code:
    new randomr random_num(1,10);
    if(
equal(randomr"1"){
           
set_task30.0"somefunc")
}
    if(
equal(randomr"2"){
          
client_print(0print_chat"The picked number is 2.")

}
    if(
equal(randomr"3"){
          
server_cmd("sv_restartround 5")
}

// and so on 
But it gives an error. What am I doing wrong?

Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-26-2010 , 18:57   Re: Random number
Reply With Quote #2

You may want to learn the difference between strings and integers.

PHP Code:
new iRand random_num(1,10)
switch(
iRand)
{
    case 
1:
    {
        
set_task30.0"somefunc")
    }
    case 
2:
    {
        
client_print(0print_chat"The picked number is 2.")
    }
    case 
3:
    {
        
server_cmd("sv_restartround 5")
    }

__________________
fysiks is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 11-26-2010 , 19:01   Re: Random number
Reply With Quote #3

I will. Thanks .
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
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 11:26.


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