Raised This Month: $ Target: $400
 0% 

Check admin flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ashwink7
Junior Member
Join Date: Feb 2014
Old 07-27-2014 , 02:14   Check admin flags
Reply With Quote #1

hi this is my code basically what i want is that to get the acces flags via cvar and check whether the user has that flags and execute som codes according to it hers my code

PHP Code:
new flag;
new 
aflags[5];
public 
plugin_init() 
{
             
flag register_cvar("acces_flag","a");
             
register_clcmd("say /lol","check_flags");
}
public 
check_flags(id)
{
                        
get_pcvar_string(flag,aflags,charsmax(aflags));
                        if(
get_user_flags(id) && read_flags(aflags)); 
                           {
                                    
// my code 
                           
}


here i want to check whether user has a ie immunity flag or not but this code is not working please help

Last edited by ashwink7; 07-27-2014 at 02:15.
ashwink7 is offline
Old 07-27-2014, 02:31
Eagle07
This message has been deleted by Eagle07.
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-27-2014 , 03:12   Re: Check admin flags
Reply With Quote #3

Use & instead of &&
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
ashwink7
Junior Member
Join Date: Feb 2014
Old 07-27-2014 , 05:51   Re: Check admin flags
Reply With Quote #4

Quote:
Originally Posted by YamiKaitou View Post
Use & instead of &&
CAn you please xplain me why it wont work for && nd what is the difference between & and && ?
ashwink7 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-27-2014 , 06:18   Re: Check admin flags
Reply With Quote #5

&& is the logic boolean 'and'-operator while & is the bitwise 'and'-operator. There is a good tutorial in the tutorials section about that.
mottzi is offline
Send a message via MSN to mottzi
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2014 , 17:06   Re: Check admin flags
Reply With Quote #6

If you ever use a cvar (or any variable) that holds more than 1 flag, your code will still return true when the player has only 1 of the flags, any combination of, or all flags.

Here's an example, see my comments.
PHP Code:
public check_flags(id)
{
    new 
iFlags;
    
iFlags read_flagsget_pcvar_stringflag aflags charsmaxaflags ) ) );

    
//True only if player has ALL flags contained in aflags cvar.
    
if( ( get_user_flagsid ) & iFlags ) == iFlags ); 
    {
        
// my code 
    
}

    
//True if player has AT LEAST ONE (or some, or all) of the flags contained in aflags cvar.
    
if( get_user_flagsid ) & iFlags ); 
    {
        
// my code 
    
}

__________________

Last edited by Bugsy; 07-27-2014 at 17:06.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 13:12.


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