AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to "switch strings" ? (https://forums.alliedmods.net/showthread.php?t=120247)

dFF 03-02-2010 11:42

How to "switch strings" ?
 
Code:
PHP Code:

#include <amxmodx>

public test(id)
{
    new 
flags get_user_flags(id)
    
    switch(
flags)
    {
        case 
"abcd":
        {
            
//..
        
}
        case 
"abcdef":
        {
            
//...
        
}
    }


Any help ?

SnoW 03-02-2010 11:43

Re: How to "switch strings" ?
 
Can't do, go with ifs. Your flags seem pretty weird I must say.

ConnorMcLeod 03-02-2010 11:49

Re: How to "switch strings" ?
 
PHP Code:

#include <amxmodx>

const abcd ADMIN_IMMUNITY|ADMIN_RESERVATION|ADMIN_KICK|ADMIN_BAN
const abcdef abcd|ADMIN_SLAY|ADMIN_MAP

public test(id)
{
    switch( 
get_user_flags(id) )
    {
        case 
abcd:
        {
            
//..
        
}
        case 
abcdef:
        {
            
//...
        
}
    }


case abcdef won't match if user have another flag like flag "g" for example, so this is a really bad idea to use this.

Use rather has_flags or has_all_flags stocks from amxmisc + if / else statements.


All times are GMT -4. The time now is 08:40.

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