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

Solved is_user_admin(id) , does not check after map change


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2020 , 12:16   Re: is_user_admin(id) , does not check after map change
Reply With Quote #51

Again, it sets flags, but the other plugin changes them after the fact. Try making my plugin the very last one in plugins.ini
__________________
Bugsy is offline
DJBosma
Member
Join Date: Dec 2009
Old 03-18-2020 , 12:35   Re: is_user_admin(id) , does not check after map change
Reply With Quote #52

Quote:
Originally Posted by Bugsy View Post
Again, it sets flags, but the other plugin changes them after the fact. Try making my plugin the very last one in plugins.ini
It worked out fine with admin.amxx, amxbans on the other hand does not comply. I'm going to mark this thread as Solved and search for an alternative ban system.

Great job Bugsy!
Thanks a lot.

For the ones browsing this thread, plugin provided in my first post.

Last edited by DJBosma; 03-18-2020 at 12:39.
DJBosma is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-18-2020 , 20:20   Re: is_user_admin(id) , does not check after map change
Reply With Quote #53

I thought that amxbans was supposed to replace admin.amxx. If that is still the case, you're likely going to experience issues. Also, if you have multiple plugin editing admin flags, you're always going to risk having race conditions like this. Unless you integrate all admin flag editing functionality in to the one plugin that gives the admin flags, you're going to have the possibility of race conditions.
__________________
fysiks is offline
DJBosma
Member
Join Date: Dec 2009
Old 03-18-2020 , 20:42   Re: is_user_admin(id) , does not check after map change
Reply With Quote #54

Quote:
Originally Posted by fysiks View Post
I thought that amxbans was supposed to replace admin.amxx. If that is still the case, you're likely going to experience issues. Also, if you have multiple plugin editing admin flags, you're always going to risk having race conditions like this. Unless you integrate all admin flag editing functionality in to the one plugin that gives the admin flags, you're going to have the possibility of race conditions.
I found some other vip plugins just now that use forwards of amxbans regarding admins. If I have any updates on this, you’ll see them in my first post. Regarding the functionality I do know that it is risky and barbaric to add more than one. I’m going to run a ZP mod and try to map most of the extra’s (zp_give_user_extra_item etc..) in bugsy’s plugin. Not in amxbans nor any ban system plugin.
I’ve rewritten a part of Amxbans to load admins from users & DB, where I thought I’d use the DB with a Paypal API and hand monthly subscriptions.. changed my mind, because “Pro” is just a harder to-get in bugsy’s plugin.

Last edited by DJBosma; 03-18-2020 at 20:46.
DJBosma is offline
DJBosma
Member
Join Date: Dec 2009
Old 03-29-2020 , 09:08   Re: is_user_admin(id) , does not check after map change
Reply With Quote #55

@bugsy , could you add if flags are already loaded to not set and save in vault.
DJBosma is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-29-2020 , 11:17   Re: is_user_admin(id) , does not check after map change
Reply With Quote #56

This version completely excludes regular admins from everything, including the say commands.
PHP Code:

#include <amxmodx>
#include <nvault>

new const Version[] = "0.4";

const 
DaySeconds 86400;

enum VeteranLevels
{
    
Player,
    
Veteran,
    
Pro
}
enum VeteranLevelData
{
    
SecondsNeeded,
    
VeteranFlags26 ],
    
VeteranBits
}
new 
VeteranInfoVeteranLevels ][ VeteranLevelData ] = 
{
    { 
"" },
    { 
1800 "fghji" },
    { 
3600 "fghjijklmnopqrstu" }
};

enum VeteranData
{
    
SteamID34 ],
    
bool:IsAdmin,
    
SecondsPlayed,
    
VeteranLevels:VeteranLevel
}
new 
PlayerDataMAX_PLAYERS ][ VeteranData ];

new 
g_Vault;

public 
plugin_init() 
{
    
register_plugin"Veterans" Version "bugsy" );

    
register_event"HLTV" "NewRound" "a" "1=0" "2=0" );
    
    
register_clcmd"say !veteran" "VeteranSay" );
    
register_clcmd"say_team !veteran" "VeteranSay" );
    
    
register_clcmd"say !pro" "ProSay" );
    
register_clcmd"say_team !pro" "ProSay" );

    
register_clcmd"say !skill" "SkillSay" );
    
register_clcmd"say_team !skill" "SkillSay" );
}

public 
plugin_cfg()
{
    
nvault_prune( ( g_Vault nvault_open"veteran_data" ) ) , get_systime() - ( DaySeconds ) );
    
    for ( new 
VeteranLevels:Veteran VeteranLevels i++ )
    {
        
VeteranInfo][ VeteranBits ] = read_flagsVeteranInfo][ VeteranFlags ] );
    }
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    new 
szData11 ] , iTS;
    
    if ( !( 
PlayerDataid ][ IsAdmin ] = bool:( !( get_user_flagsid ) & ADMIN_USER ) ) ) )
    { 
        
get_user_authidid PlayerDataid ][ SteamID ] , charsmaxPlayerData[][ SteamID ] ) );
        
        if ( 
nvault_lookupg_Vault PlayerDataid ][ SteamID ] , szData charsmaxszData ) , iTS ) )
        {
            
PlayerDataid ][ SecondsPlayed ] = str_to_numszData );
            
SetVeteranLevelid );
        }
    }
}

public 
client_disconnectedid )
{
    new 
szSeconds11 ];
    
    if ( !
PlayerDataid ][ IsAdmin ] )
    {
        
num_to_strPlayerDataid ][ SecondsPlayed ] + get_user_timeid ) , szSeconds charsmaxszSeconds ) )
        
nvault_setg_Vault PlayerDataid ][ SteamID ] , szSeconds );
        
        
PlayerDataid ][ SecondsPlayed ] = 0;
        
PlayerDataid ][ VeteranLevel ] = Player;
    }
}

public 
VeteranSayid )
{
    
show_motdid "veteran_motd.txt" );
}

public 
ProSayid )
{
    
show_motdid "pro_motd.txt" );
}

public 
SkillSayid )
{
    if ( 
PlayerDataid ][ IsAdmin ] )
    {
        
client_printid  print_chat "* You are an admin" );
    }
    else
    {
        if ( 
PlayerDataid  ][ VeteranLevel ] < Pro )
        {
            
set_dhudmessage255 , -1.0 , -1.0 0.0 5.0 0.0 0.0 );
            
            switch ( 
PlayerDataid  ][ VeteranLevel ] )
            {
                case 
Player:
                {
                    
show_dhudmessageid  "To become veteran play %d minutes. Type !veteran" VeteranInfoVeteran ][ SecondsNeeded ] / 60 );
                }
                case 
Veteran:
                {
                    
show_dhudmessageid  "You are a Veteran. To become Pro play for %d minutes. Type !pro" VeteranInfoPro ][ SecondsNeeded ] / 60 );
                }
            }
        }
        else
        {
            
client_printid  print_chat "* You are a Pro player" );
        }
    }
}

public 
NewRound()
{
    new 
iPlayers32 ] , iNum iPlayer;
    
    
get_playersiPlayers iNum "ch" );
    
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        if ( !
PlayerDataiPlayer ][ IsAdmin ] )
        {
            
SetVeteranLeveliPlayer );
            
SkillSayiPlayer );
        }
    }
}

SetVeteranLevelid )
{
    new 
VeteranLevels:vlLevel Player;
    
    if ( 
PlayerDataid ][ VeteranLevel ] < Pro )
    {
        for ( new 
VeteranLevels:Pro >= Veteran i-- )
        {
            if ( 
PlayerDataid ][ SecondsPlayed ] >= VeteranInfo][ SecondsNeeded ] )
            {
                
vlLevel i;
                
remove_user_flagsid ADMIN_USER );
                
set_user_flagsid , ( get_user_flagsid ) | VeteranInfo][ VeteranBits ] ) );
                break;
            }
        }
        
        
PlayerDataid ][ VeteranLevel ] = vlLevel;
    }

__________________

Last edited by Bugsy; 03-29-2020 at 14:33.
Bugsy is offline
DJBosma
Member
Join Date: Dec 2009
Old 03-29-2020 , 14:23   Re: is_user_admin(id) , does not check after map change
Reply With Quote #57

Primarly I've changed
PHP Code:
 if ( !PlayerDataid ][ IsAdmin ]  && 
to
PHP Code:
if ( !PlayerDataid ][ IsAdmin ] ) { 
in client_authorized. Flag distribution is ok, I've removed the check for admins on motd showing, since all players can review the extra's given. The only issue is that if every round it display's to an admin "To become a veteran" and a pro user with flags sees it as well.

PS: Please make all commands as well !skill can still be available to all users.

Last edited by DJBosma; 03-29-2020 at 19:04. Reason: Removed buggy code to avoid misunderstandings
DJBosma is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-29-2020 , 14:34   Re: is_user_admin(id) , does not check after map change
Reply With Quote #58

Quote:
Originally Posted by DJBosma View Post
Primarly I've changed
PHP Code:
 if ( !PlayerDataid ][ IsAdmin ]  && 
to
PHP Code:
if ( !PlayerDataid ][ IsAdmin ] ) { 
I agree with this, it saves a get_user_authid() call when not needed.

Quote:
Originally Posted by DJBosma View Post
in client_authorized. Flag distribution is ok, I've removed the check for admins on motd showing, since all players can review the extra's given. The only issue is that if every round it display's to an admin "To become a veteran" and a pro user with flags sees it as well.

PS: Please make all commands as well !skill can still be available to all users.
Above code updated. There is now a message shown specific for admins, change it to whatever you want.
__________________

Last edited by Bugsy; 03-29-2020 at 14:36.
Bugsy is offline
DJBosma
Member
Join Date: Dec 2009
Old 03-29-2020 , 17:31   Re: is_user_admin(id) , does not check after map change
Reply With Quote #59

All well, the only thing is that it does not reload the flags after a map change when player has become a veteran OR pro. After reconnect it is fine.

Last edited by DJBosma; 03-29-2020 at 17:34.
DJBosma is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-29-2020 , 18:14   Re: is_user_admin(id) , does not check after map change
Reply With Quote #60

client_disconnected() and then client_authorized() is called when the map is changed, it should not require that a player reconnects. I would re-test.
__________________
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 07:31.


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