Raised This Month: $ Target: $400
 0% 

Switch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-18-2011 , 09:44   Switch
Reply With Quote #1

That is optimized?
PHP Code:
    switch (random_num(03))
    {
        case 
0: ...
        case 
1: ...
        case 
2: ...
        case 
3: ...
    } 
Or
PHP Code:
    new random_num(03)
    switch (
i)
    {
        case 
0: ...
        case 
1: ...
        case 
2: ...
        case 
3: ...
    } 

Last edited by PRoSToTeM@; 03-18-2011 at 09:55.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-18-2011 , 09:50   Re: Switch
Reply With Quote #2

Format the string.

Code:
server_cmd("say %d", random_num(0, 3))

If you are only asking which method is efficient of switching a variable or a return value, they should be the same.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-18-2011 , 09:51   Re: Switch
Reply With Quote #3

server_cmd( "say %i", random( 4 ) );
__________________
Arkshine is offline
Old 03-18-2011, 09:53
Flipper_SPb
This message has been deleted by Flipper_SPb.
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-18-2011 , 09:55   Re: Switch
Reply With Quote #4

Post edited
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-18-2011 , 10:02   Re: Switch
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
they should be the same.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 14:32.


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