Raised This Month: $ Target: $400
 0% 

Preventing the names from repeating


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-21-2016 , 18:17   Preventing the names from repeating
Reply With Quote #1

I have an admin_who plugin. I changed the check to include the flags, instead of equaling them. Why? Because the VIP flag is ADMIN_LEVEL_H, so if I add the t flag to an admin, he won't be shown in the admin list anymore. This way he would. The problem is that a founder will appear in all admin cathegories, as he fits them all, having full access. How could I add a check to prevent him from repeating? I mean placing him in the highest rank his flags allow him, but no lower.

Here's my code:
PHP Code:
#include < amxmodx >
#include < amxmisc >

#pragma semicolon 1

#define MAX_GROUPS 9

new g_groupNames[MAX_GROUPS][] = 
{
    
"Founder",
    
"Owner",
    
"Co-Owner",
    
"God",
    
"Super-Moderator",
    
"Moderator",
    
"Administrator",
    
"Helper",
    
"Slot"
};

new 
g_groupFlags[MAX_GROUPS][] = 
{
    
"abcdefghijklmnopqrsuv",    // Founder
    
"abcdefghijkmnopqrsu",        // Owner
    
"abcdefijmnopqrsu",            // Co-Owner
    
"abcdefijmnopqrs",            // God
    
"abcdefijmnopqr",            // Super-Moderator
    
"abcdefijmnopq",            // Moderator
    
"abcdefijmno",                // Administrator
    
"abceijmno",                // Helper
    
"ab"                        // Slot
};

new 
g_groupFlagsValue[MAX_GROUPS];

public 
plugin_init()
{
    
register_plugin("admin_who""1.0""rock!");
    
    
register_concmd("admin_who""cmdWho"0);
    
    
register_clcmd("say who""cmdSayWho");
    
register_clcmd("say /who""cmdSayWho");
    
register_clcmd("say admin""cmdSayWho");
    
register_clcmd("say /admin""cmdSayWho");
    
    for(new 
0MAX_GROUPSi++)
        
g_groupFlagsValue[i] = read_flags(g_groupFlags[i]);
}

public 
cmdWho(id)
{
    new 
players[32], inumplayername[32];
    
    
get_players(playersinum);
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    for(new 
0MAX_GROUPSi++)
    {
        
console_print(id"-----[%d]%s-----"i+1g_groupNames[i]);
        
        for(new 
0inum; ++a)
        {
            
player players[a];
            
            
get_user_name(playername31);
            
            if((
get_user_flags(player) & g_groupFlagsValue[i]) == g_groupFlagsValue[i])
                
console_print(id"%s"name);
        }
    }
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    return 
PLUGIN_HANDLED;
}

public 
cmdSayWho(id)
{
    
chat_color(id"!t[!g!t] !nCheck your console!");
    
    
cmdWho(id);
}

stock chat_color(const id, const input[], any:...)
{
    new 
iCount 1;
    new 
iPlayers[32];
    
    static 
sMsg[191];
    
    
vformat(sMsg190input3);
    
    
replace_all(sMsg190"!g""^4");
    
replace_all(sMsg190"!n""^1");
    
replace_all(sMsg190"!t""^3");
    
    if(
id)
        
iPlayers[0] = id;
    
    else
        
get_players(iPlayersiCount"ch");
    
    for(new 
0iCounti++)
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _iPlayers[i]);
            
write_byte(iPlayers[i]);
            
write_string(sMsg);
            
message_end();
        }

__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 05-21-2016 at 18:18.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-21-2016 , 18:49   Re: Preventing the names from repeating
Reply With Quote #2

Switch the two for-loops. Put the groups loop inside the player loop, then check if the player has the flags, and if he does, simply add "break" in the groups loop, so the other groups below it don't get checked. Also, don't get the player's name before making sure that he has the flags.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-21-2016 , 19:38   Re: Preventing the names from repeating
Reply With Quote #3

The flags that you added at this plugin, you need to add the same flags in users.ini, if not it does not appear.
Example:

"VIP"

Flags:

"Abcdefh"

You will add at users.ini

"EFFx" "fuckingpassword" "abcdefh" "a"

Do you already tryed it?
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-21-2016 at 19:43.
EFFx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-21-2016 , 20:11   Re: Preventing the names from repeating
Reply With Quote #4

Did you even read the question?
OciXCrom is offline
Send a message via Skype™ to OciXCrom
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-21-2016 , 20:40   Re: Preventing the names from repeating
Reply With Quote #5

Quote:
Originally Posted by EFFx View Post
The flags that you added at this plugin, you need to add the same flags in users.ini, if not it does not appear.
Example:

"VIP"

Flags:

"Abcdefh"

You will add at users.ini

"EFFx" "fuckingpassword" "abcdefh" "a"

Do you already tryed it?
You're watching a different movie, my friend.


Quote:
Originally Posted by OciXCrom View Post
Switch the two for-loops. Put the groups loop inside the player loop, then check if the player has the flags, and if he does, simply add "break" in the groups loop, so the other groups below it don't get checked. Also, don't get the player's name before making sure that he has the flags.
I'll do it right away. Thank you, Ocixcrom!



Apparently, I messed it up again. It didn't double anything, that's a relief. I guess I scrambled the loops doe, as I tested it and it showed a founder as a helper and an owner as a slot. Then it kept showing different combinations. Please end my pain...
__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 05-21-2016 at 21:41.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-22-2016 , 07:00   Re: Preventing the names from repeating
Reply With Quote #6

Check flag t remove it and then do equal , it's so hard?

PHP Code:
for(new 0inum; ++a)
        {
            
player players[a];
            new 
flags get_user_flags(player)
            if(
flags ADMIN_LEVEL_H)
                 
flags &= ~(ADMIN_LEVEL_H)
            if(
flags == g_groupFlagsValue[i]){
                  
get_user_name(player,name,31)
                
console_print(id"%s"name);
            }
        } 
And don't use get user name before checking flags, you are wasting memory ....

Last edited by siriusmd99; 05-22-2016 at 07:01.
siriusmd99 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-22-2016 , 09:08   Re: Preventing the names from repeating
Reply With Quote #7

I changed the way the plugin works by assigning the player group when the player connects. The who command will then match the players group with the list of groups as you loop through the groups. I also added a 'Player' group that will display players who do not match any of the defined groups. You can disable this group using the cvar aw_displayplayers. Let me know if this does what you want.

PHP Code:
#include < amxmodx >
#include < amxmisc >

#pragma semicolon 1

#define MAX_PLAYERS 32

enum Groups
{
    
Founder,
    
Owner,
    
CoOwner,
    
God,
    
SuperModerator,
    
Moderator,
    
Administrator,
    
Helper,
    
Slot,
    
Player
}

new 
g_groupNamesGroups ][] = 
{
    
"Founder",
    
"Owner",
    
"Co-Owner",
    
"God",
    
"Super-Moderator",
    
"Moderator",
    
"Administrator",
    
"Helper",
    
"Slot",
    
"Player"
};

new 
g_groupFlagsGroups ][] = 
{
    
"abcdefghijklmnopqrsuv",    // Founder
    
"abcdefghijkmnopqrsu",        // Owner
    
"abcdefijmnopqrsu",            // Co-Owner
    
"abcdefijmnopqrs",            // God
    
"abcdefijmnopqr",            // Super-Moderator
    
"abcdefijmnopq",            // Moderator
    
"abcdefijmno",                // Administrator
    
"abceijmno",                // Helper
    
"ab",                    // Slot
    
"z"                    //Player
};

new 
g_groupFlagsValue[Groups];

new 
Groups:g_PlayerGroupMAX_PLAYERS ] , g_pDisplayPlayers;

public 
plugin_init()
{
    
register_plugin("admin_who""1.0""rock!");
    
    
register_concmd("admin_who""cmdWho"0);
    
    
register_clcmd("say who""cmdSayWho");
    
register_clcmd("say /who""cmdSayWho");
    
register_clcmd("say admin""cmdSayWho");
    
register_clcmd("say /admin""cmdSayWho");
    
    
g_pDisplayPlayers register_cvar"aw_displayplayers""0" );
    
    for( new 
Groups:Founder Groupsi++ )
        
g_groupFlagsValue[i] = read_flags(g_groupFlags[i]);
}

public 
client_authorizedid )
{
    new 
iFlags get_user_flagsid );
    
    for ( new 
Groups:gGroup Founder gGroup Groups gGroup++ )
    {
        if( ( 
iFlags g_groupFlagsValuegGroup ] ) == g_groupFlagsValuegGroup ] )
        {
            
g_PlayerGroupid ] = gGroup;
            break;
        }
    }    
}

public 
cmdWho(id)
{
    new 
players[32], inumplayername[32];

    
get_players(playersinum);
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    for(new 
Groups:gGroup FoundergGroup < ( Groups Groups:!get_pcvar_numg_pDisplayPlayers ) ) ; gGroup++ )
    {
        
console_printid "-----[%d]%s-----" _:gGroup+g_groupNamesgGroup ] );
        
        for(new 
0inum; ++a)
        {
            
player players[a];
            
            if( 
gGroup == g_PlayerGroupplayer ] )
            {
                
get_user_nameplayer name charsmaxname ) );
                
console_printid "%s" name );
            }
        }
    }
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    return 
PLUGIN_HANDLED;
}

public 
cmdSayWho(id)
{
    
chat_color(id"!t[!g!t] !nCheck your console!");
    
    
cmdWho(id);
}

stock chat_color(const id, const input[], any:...)
{
    new 
iCount 1;
    new 
iPlayers[32];
    
    static 
sMsg[191];
    
    
vformat(sMsg190input3);
    
    
replace_all(sMsg190"!g""^4");
    
replace_all(sMsg190"!n""^1");
    
replace_all(sMsg190"!t""^3");
    
    if(
id)
        
iPlayers[0] = id;
    
    else
        
get_players(iPlayersiCount"ch");
    
    for(new 
0iCounti++)
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _iPlayers[i]);
            
write_byte(iPlayers[i]);
            
write_string(sMsg);
            
message_end();
        }

__________________

Last edited by Bugsy; 05-22-2016 at 09:09.
Bugsy is offline
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-23-2016 , 04:35   Re: Preventing the names from repeating
Reply With Quote #8

Quote:
Originally Posted by siriusmd99 View Post
Check flag t remove it and then do equal , it's so hard?

PHP Code:
for(new 0inum; ++a)
        {
            
player players[a];
            new 
flags get_user_flags(player)
            if(
flags ADMIN_LEVEL_H)
                 
flags &= ~(ADMIN_LEVEL_H)
            if(
flags == g_groupFlagsValue[i]){
                  
get_user_name(player,name,31)
                
console_print(id"%s"name);
            }
        } 
And don't use get user name before checking flags, you are wasting memory ....
Well yeah, it is so hard, 'cause I'm a begginer and I don't get loops so well. Thank you!


Quote:
Originally Posted by Bugsy View Post
I changed the way the plugin works by assigning the player group when the player connects. The who command will then match the players group with the list of groups as you loop through the groups. I also added a 'Player' group that will display players who do not match any of the defined groups. You can disable this group using the cvar aw_displayplayers. Let me know if this does what you want.

PHP Code:
#include < amxmodx >
#include < amxmisc >

#pragma semicolon 1

#define MAX_PLAYERS 32

enum Groups
{
    
Founder,
    
Owner,
    
CoOwner,
    
God,
    
SuperModerator,
    
Moderator,
    
Administrator,
    
Helper,
    
Slot,
    
Player
}

new 
g_groupNamesGroups ][] = 
{
    
"Founder",
    
"Owner",
    
"Co-Owner",
    
"God",
    
"Super-Moderator",
    
"Moderator",
    
"Administrator",
    
"Helper",
    
"Slot",
    
"Player"
};

new 
g_groupFlagsGroups ][] = 
{
    
"abcdefghijklmnopqrsuv",    // Founder
    
"abcdefghijkmnopqrsu",        // Owner
    
"abcdefijmnopqrsu",            // Co-Owner
    
"abcdefijmnopqrs",            // God
    
"abcdefijmnopqr",            // Super-Moderator
    
"abcdefijmnopq",            // Moderator
    
"abcdefijmno",                // Administrator
    
"abceijmno",                // Helper
    
"ab",                    // Slot
    
"z"                    //Player
};

new 
g_groupFlagsValue[Groups];

new 
Groups:g_PlayerGroupMAX_PLAYERS ] , g_pDisplayPlayers;

public 
plugin_init()
{
    
register_plugin("admin_who""1.0""rock!");
    
    
register_concmd("admin_who""cmdWho"0);
    
    
register_clcmd("say who""cmdSayWho");
    
register_clcmd("say /who""cmdSayWho");
    
register_clcmd("say admin""cmdSayWho");
    
register_clcmd("say /admin""cmdSayWho");
    
    
g_pDisplayPlayers register_cvar"aw_displayplayers""0" );
    
    for( new 
Groups:Founder Groupsi++ )
        
g_groupFlagsValue[i] = read_flags(g_groupFlags[i]);
}

public 
client_authorizedid )
{
    new 
iFlags get_user_flagsid );
    
    for ( new 
Groups:gGroup Founder gGroup Groups gGroup++ )
    {
        if( ( 
iFlags g_groupFlagsValuegGroup ] ) == g_groupFlagsValuegGroup ] )
        {
            
g_PlayerGroupid ] = gGroup;
            break;
        }
    }    
}

public 
cmdWho(id)
{
    new 
players[32], inumplayername[32];

    
get_players(playersinum);
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    for(new 
Groups:gGroup FoundergGroup < ( Groups Groups:!get_pcvar_numg_pDisplayPlayers ) ) ; gGroup++ )
    {
        
console_printid "-----[%d]%s-----" _:gGroup+g_groupNamesgGroup ] );
        
        for(new 
0inum; ++a)
        {
            
player players[a];
            
            if( 
gGroup == g_PlayerGroupplayer ] )
            {
                
get_user_nameplayer name charsmaxname ) );
                
console_printid "%s" name );
            }
        }
    }
    
    
console_print(id"~~~~~ www..ro ~~~~~");
    
    return 
PLUGIN_HANDLED;
}

public 
cmdSayWho(id)
{
    
chat_color(id"!t[!g!t] !nCheck your console!");
    
    
cmdWho(id);
}

stock chat_color(const id, const input[], any:...)
{
    new 
iCount 1;
    new 
iPlayers[32];
    
    static 
sMsg[191];
    
    
vformat(sMsg190input3);
    
    
replace_all(sMsg190"!g""^4");
    
replace_all(sMsg190"!n""^1");
    
replace_all(sMsg190"!t""^3");
    
    if(
id)
        
iPlayers[0] = id;
    
    else
        
get_players(iPlayersiCount"ch");
    
    for(new 
0iCounti++)
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _iPlayers[i]);
            
write_byte(iPlayers[i]);
            
write_string(sMsg);
            
message_end();
        }

It does exactly what I want and it does it even better. Thank you so much, Bugsy!
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
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 18:33.


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