AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switch (https://forums.alliedmods.net/showthread.php?t=153082)

PRoSToTeM@ 03-18-2011 09:44

Switch
 
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: ...
    } 


Exolent[jNr] 03-18-2011 09:50

Re: Switch
 
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.

Arkshine 03-18-2011 09:51

Re: Switch
 
server_cmd( "say %i", random( 4 ) );

PRoSToTeM@ 03-18-2011 09:55

Re: Switch
 
Post edited

Exolent[jNr] 03-18-2011 10:02

Re: Switch
 
Quote:

Originally Posted by Exolent[jNr] (Post 1435272)
they should be the same.



All times are GMT -4. The time now is 14:32.

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