Raised This Month: $ Target: $400
 0% 

how does get_user_flags(id) work?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 06-24-2009 , 15:43   how does get_user_flags(id) work?
Reply With Quote #1

please dont link me to this i know how it works in the coding sence, i want to know how it really works

Lets start with a snippet:
PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("flags test""1.0""Stewie!");
    
register_clcmd("say /myflags""myflags", -1"Handles the /myflags command");
}

public 
myflags(id)
{
    if(
get_user_flags(id) & ADMIN_ADMIN)
    {
         
client_print(idprint_chat"You are an admin!");
    }
    else
    {
         
client_print(idprint_chat"You are not an admin!");
    }

So clearly, ADMIN_ADMIN and all the other flags are defined as:
PHP Code:
#define ADMIN_ADMIN 1
#define ADMIN_IMMUNITY 2
#define ADMIN_BAN 4
#define ADMIN_KICK 8
etc
when get_user_flags(id) is called, the function loops through the users.ini file to see if the steamID of who called the func matches an entry
something like this:
PHP Code:
get_user_flags(id)
{
    if(
file_exists(gUsersIni))
    {
        new 
TextLine[33];
        new 
NoOfChars;
        new 
szPlayerAuth[33];
        new 
Lines file_size(gUsersIni1);
        new 
szParse[2][33];
        new 
iValue 0;
        
        for(new 
LineToReadLineToRead LinesLineToRead++)
        {
            
read_file(gUsersIniLineToReadTextLine32NoOfChars);
            
            if(!
TextLine[0] || TextLine[0] == ';' || TextLine[0] == '/' && TextLine[1] == '/')
            {
                continue;
            }
            
            
get_user_authid(idszPlayerAuth32);
            
parse(TextLineszParse[0], 32szParse[1], 32);
            
            if(
equali(szPlayerAuthszParse[0]))
            {
                if(
containi(szParse[1], "a"))
                {
                    return 
ADMIN_IMMUNITY//This line
                
}
            }
        }
    }
    return 
0;

but what happens on the lines that ive commented?
Clearly you cannot return more than 1 value so doing this wouldnt work
PHP Code:
if((containi(szParse[1], "a")) && (containi(szParse[1], "b")))
{
    return 
ADMIN_IMMUNITY && ADMIN_BAN;

any1 know how it works properly?
__________________
minimiller is offline
Send a message via MSN to minimiller
 



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 15:26.


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