Raised This Month: $51 Target: $400
 12% 

Check access flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 12-27-2022 , 15:18   Check access flags
Reply With Quote #1

Hello, im trying to check for access flags which flags a player have, and display it on hudmessage on his screen, but somehow this script is giving me errors.

PHP Code:
#include <amxmodx>

new const FLAG_NAMES[][] =
{
    
"a""Admin",
    
"b""Moderator",
    
"c""Helper",
    
"d""VIP",
    
"e""Custom Flag 1",
    
"f""Custom Flag 2",
    
"g""Custom Flag 3"
};

public 
client_putinserver(id)
{
    new 
flags[32], num_flagsi;
    
get_user_flags(idflags[], num_flags);

    new 
message[128];
    
format(messagesizeof(message), "Your access flags: ");

    for (
0num_flagsi++)
    {
        if (
0)
        {
            
strcat(message", ");
        }

        new 
flag_name[32];
        
get_access_name(flags[i],flag_namesizeof(flag_name));
        
strcat(messageflag_name);
    }

    
show_hudmessage(id, -10.50.50xFF00FF00message);
}

stock get_access_name(const flag[], name[], len)
{
    for (new 
0sizeof(FLAG_NAMES); += 2)
    {
        if (
equali(flagFLAG_NAMES[i]))
        {
            
strcopy(nameFLAG_NAMES[1], len);
            return 
1;
        }
    }
    return 
0;

WARNING [37]: symbol is never used: "len"
ERROR [17]: invalid expression, assumed zero
ERROR [26]: number of arguments does not match definition
ERROR [31]: number of arguments does not match definition
ERROR [34]: argument type mismatch (argument 2)
ERROR [43]: undefined symbol "strcopy"

Would anyone help me fix these? thanks
HowToRuski is offline
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
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-28-2022 , 17:41   Re: Check access flags
Reply With Quote #3

You've misunderstanding of how flags do work..., while ranks are totally different from flags, flags have more possibilities than ranks do, each player can have many flags while ranks a player can have only one, so the proper way is also to add weight to the ranks so higher the rank with a heavy weight will be set to the player.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-28-2022 at 17:46.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



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 10:17.


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