View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-27-2022 , 18:48   Re: Check access flags
Reply With Quote #2

You're not using several functions in this plugin correctly (including your own custom function) and one function that doesn't exist in AMX Mod X. If you are not familiar with how a function works, you should first look up how it's defined and what it does in the API documentation. Then, if it's still not clear, you should look to see how other plugins use the function so you can see how it is supposed to be used in a real plugin (presumably a plugin that is fully working).

While I was writing up a more detailed response, I came across a function that will make your plugin much simpler for you to write. AMX Mod X has a function called has_flag() which will make it super easy to simply loop through your flag list (FLAG_NAMES) and check if the user has that flag, if so, you can use the corresponding flag name. I'd also recommend using a 3-dimension array so that the data is more organized allowing you to not have to do non-sequential indexes in your loop.


PHP Code:

#include <amxmisc>

// Define the flags to check with corresponding name
new const FLAG_NAMES[][][] =
{
    {
"a""Admin"},
    {
"b""Moderator"}
}

// In your function:
    
for( new 0sizeof FLAG_NAMESi++ )
    {
        if( 
has_flag(idFLAG_NAMES[i][0]) )
        {
            
server_print("User has flag '%s' with name '%s'"FLAG_NAMES[i][0], FLAG_NAMES[i][1])
        }
    } 
You'll need to make sure this occurs after client_authorized() and client_putinserver() have been executed and give some time for the user to even be able to see it (client_putinserver() happens when they won't be able to see anything on the screen anyways).

Your attempt at showing a HUD message is completely wrong, so you should look up how to do that.

Also, finally, note that these flags that you're using already have special meaning in AMX Mod X so if you use them for what you're naming your flags in FLAG_NAMES then you'll probably get some really weird behavior. For example, "a" is immunity, "b" is reservation, "c" is for the amx_kick command, "d" is for the amx_ban command, etc.
__________________
fysiks is offline