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

Auto admin removal after days


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2017 , 10:53   Re: Auto admin removal after days
Reply With Quote #11

Quote:
Originally Posted by edon1337 View Post
What he asked for was obvious.



Scripters in other forums don't provide the source as their forums aren't dedicated to open-source coding.

Furthermore I even gave him the link of an AMXX plugin and he didn't reply back with 'I want it for CS:S'.
That's your opinion and that is fine. I explained why I asked what I asked. Back on topic
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 03-18-2017 , 11:14   Re: Auto admin removal after days
Reply With Quote #12

Quote:
Originally Posted by Bugsy View Post
Back on topic
Yes, sir.

I'm also interested on this if you could teach us how to do it .

I think a way would be to store the name and the expire time using nVault then check on Ham_Spawn.
__________________

Last edited by edon1337; 03-18-2017 at 11:15.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2017 , 12:36   Re: Auto admin removal after days
Reply With Quote #13

Not thoroughly tested.

This allows adding admins for X number of days (precise to the second). You may only add players who do not exist in users.ini. If you use the addtempadmin command on a player who is already a temp admin, it will over-write their current expire date with the new date. The admin power will expire when the player re-connects (or map change) after their expire date/time happens.

Commands:
  • amx_addtempadmin bugs 5
  • amx_removetempadmin bugs
CVar:
  • ata_flags <flags you want temp admins to have>
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>

new const Version[] = "0.1";

const 
Day_Seconds 86400;

new 
g_Vault;
new 
g_pFlags;

public 
plugin_init() 
{
    
register_plugin"Add Temp Admin" Version "bugsy" );
    
    
register_clcmd"amx_addtempadmin" "AddAdmin" ADMIN_CVAR "- Add temporary admin" );
    
register_clcmd"amx_removetempadmin" "RemoveAdmin" ADMIN_CVAR "- Remove temporary admin" );
    
    
g_pFlags register_cvar"ata_flags" "cfij" );
    
    
g_Vault nvault_open"AddTempAdmin" );
    
    
nvault_pruneg_Vault get_systime() );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    new 
szAuthID34 ] , szVal11 ] , iTS;
    
    
get_user_authidid szAuthID charsmaxszAuthID ) );
    
    if ( 
nvault_lookupg_Vault szAuthID szVal charsmaxszVal ) , iTS ) )
    {
        if ( 
get_systime() > str_to_numszVal ) )
        {
            
SetAdminAccessid );
            
set_task7.0 "NotifyPlayer" id );
        }
        else
        {
            
nvault_removeg_Vault szAuthID );
        }
    }
}

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
AddAdminid level cid )
{
    if( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
    
    new 
szName32 ] , szVal11 ] , iPlayer iDays szAuthID34 ] , iTS;
    
    
read_argvszName charsmaxszName ) );
    
read_argvszVal charsmaxszVal ) );
    
    
iDays str_to_numszVal );
    
    if ( ( 
iPlayer cmd_targetid szName CMDTARGET_ALLOW_SELF ) ) )
    {
        
get_user_nameiPlayer szName charsmaxszName ) );
        
get_user_authidiPlayer szAuthID charsmaxszAuthID ) );
        
        if ( !( 
get_user_flagsiPlayer ) & ADMIN_USER ) && !( nvault_lookupg_Vault szAuthID "" iTS ) ) )
        {
            
client_printid print_console "* %s is already an admin. You can only add players who are not in users.ini." szName );
        }
        else if ( 
iDays )
        {
            
num_to_strget_systime() + ( iDays Day_Seconds ) , szVal charsmaxszVal ) );
            
nvault_setg_Vault szAuthID szVal );
            
            
SetAdminAccessiPlayer );
            
NotifyPlayerid );
            
            
client_printid print_console "* Admin access granted for %s for %d day(s)." szName iDays );
        }
        else
        {
            
client_printid print_console "Proper usage: * amx_addtempadmin <name> <#days>" );
        }
    }
    
    return 
PLUGIN_HANDLED;
}


public 
RemoveAdminid level cid )
{
    if( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
    
    new 
szName32 ] , iPlayer szAuthID34 ] , iTS;
    
    
read_argvszName charsmaxszName ) );
    
    if ( ( 
iPlayer cmd_targetid szName CMDTARGET_ALLOW_SELF ) ) )
    {
        
get_user_nameiPlayer szName charsmaxszName ) );
        
get_user_authidiPlayer szAuthID charsmaxszAuthID ) );
        
        if ( 
nvault_lookupg_Vault szAuthID "" iTS ) )
        {
            
nvault_removeg_Vault szAuthID );
            
remove_user_flagsiPlayer , -);
            
set_user_flagsiPlayer ADMIN_USER );
            
            
client_printid print_console "* Admin access for %s has been removed." szName );
        }
        else
        {
            
client_printid print_console "* %s is not currently a temporary admin." szName );
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
SetAdminAccessid )
{
    new 
szFlags27 ];
    
    
get_pcvar_stringg_pFlags szFlags charsmaxszFlags ) );
            
    
remove_user_flagsid ADMIN_USER );
    
set_user_flagsid read_flagsszFlags ) );    
}

public 
NotifyPlayerid )
{
    
client_printid print_chat "* Admin access granted!" );

__________________

Last edited by Bugsy; 03-18-2017 at 12:39.
Bugsy is offline
ish12321
Veteran Member
Join Date: May 2016
Old 03-18-2017 , 13:24   Re: Auto admin removal after days
Reply With Quote #14

Quote:
Originally Posted by Bugsy View Post
Not thoroughly tested.

This allows adding admins for X number of days (precise to the second). You may only add players who do not exist in users.ini. If you use the addtempadmin command on a player who is already a temp admin, it will over-write their current expire date with the new date. The admin power will expire when the player re-connects (or map change) after their expire date/time happens.

Commands:
  • amx_addtempadmin bugs 5
  • amx_removetempadmin bugs
CVar:
  • ata_flags <flags you want temp admins to have>
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>

new const Version[] = "0.1";

const 
Day_Seconds 86400;

new 
g_Vault;
new 
g_pFlags;

public 
plugin_init() 
{
    
register_plugin"Add Temp Admin" Version "bugsy" );
    
    
register_clcmd"amx_addtempadmin" "AddAdmin" ADMIN_CVAR "- Add temporary admin" );
    
register_clcmd"amx_removetempadmin" "RemoveAdmin" ADMIN_CVAR "- Remove temporary admin" );
    
    
g_pFlags register_cvar"ata_flags" "cfij" );
    
    
g_Vault nvault_open"AddTempAdmin" );
    
    
nvault_pruneg_Vault get_systime() );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    new 
szAuthID34 ] , szVal11 ] , iTS;
    
    
get_user_authidid szAuthID charsmaxszAuthID ) );
    
    if ( 
nvault_lookupg_Vault szAuthID szVal charsmaxszVal ) , iTS ) )
    {
        if ( 
get_systime() > str_to_numszVal ) )
        {
            
SetAdminAccessid );
            
set_task7.0 "NotifyPlayer" id );
        }
        else
        {
            
nvault_removeg_Vault szAuthID );
        }
    }
}

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
AddAdminid level cid )
{
    if( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
    
    new 
szName32 ] , szVal11 ] , iPlayer iDays szAuthID34 ] , iTS;
    
    
read_argvszName charsmaxszName ) );
    
read_argvszVal charsmaxszVal ) );
    
    
iDays str_to_numszVal );
    
    if ( ( 
iPlayer cmd_targetid szName CMDTARGET_ALLOW_SELF ) ) )
    {
        
get_user_nameiPlayer szName charsmaxszName ) );
        
get_user_authidiPlayer szAuthID charsmaxszAuthID ) );
        
        if ( !( 
get_user_flagsiPlayer ) & ADMIN_USER ) && !( nvault_lookupg_Vault szAuthID "" iTS ) ) )
        {
            
client_printid print_console "* %s is already an admin. You can only add players who are not in users.ini." szName );
        }
        else if ( 
iDays )
        {
            
num_to_strget_systime() + ( iDays Day_Seconds ) , szVal charsmaxszVal ) );
            
nvault_setg_Vault szAuthID szVal );
            
            
SetAdminAccessiPlayer );
            
NotifyPlayerid );
            
            
client_printid print_console "* Admin access granted for %s for %d day(s)." szName iDays );
        }
        else
        {
            
client_printid print_console "Proper usage: * amx_addtempadmin <name> <#days>" );
        }
    }
    
    return 
PLUGIN_HANDLED;
}


public 
RemoveAdminid level cid )
{
    if( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
    
    new 
szName32 ] , iPlayer szAuthID34 ] , iTS;
    
    
read_argvszName charsmaxszName ) );
    
    if ( ( 
iPlayer cmd_targetid szName CMDTARGET_ALLOW_SELF ) ) )
    {
        
get_user_nameiPlayer szName charsmaxszName ) );
        
get_user_authidiPlayer szAuthID charsmaxszAuthID ) );
        
        if ( 
nvault_lookupg_Vault szAuthID "" iTS ) )
        {
            
nvault_removeg_Vault szAuthID );
            
remove_user_flagsiPlayer , -);
            
set_user_flagsiPlayer ADMIN_USER );
            
            
client_printid print_console "* Admin access for %s has been removed." szName );
        }
        else
        {
            
client_printid print_console "* %s is not currently a temporary admin." szName );
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
SetAdminAccessid )
{
    new 
szFlags27 ];
    
    
get_pcvar_stringg_pFlags szFlags charsmaxszFlags ) );
            
    
remove_user_flagsid ADMIN_USER );
    
set_user_flagsid read_flagsszFlags ) );    
}

public 
NotifyPlayerid )
{
    
client_printid print_chat "* Admin access granted!" );

Appreciated your work but ,....
is it possible that instead of a complete new configuration we can add a last new parameter in users.ini for date and integrate with the main amx_addadmin
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here

Last edited by ish12321; 03-18-2017 at 13:31.
ish12321 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2017 , 13:25   Re: Auto admin removal after days
Reply With Quote #15

That would be a lot more work.

What functionality is this missing that you want? I think it is cleaner to only list real admins in users.ini. This will handle all temps.
__________________
Bugsy is offline
ish12321
Veteran Member
Join Date: May 2016
Old 03-18-2017 , 14:56   Re: Auto admin removal after days
Reply With Quote #16

Actually on my server are very few real admins other all are paid and their adminship should be removed after 30days
I use ReAMXMODX so here is my admin.sma

Please help me ... Would be a great favor

Or please tell me how to do I will try a bit :-)
__________________
['O|s|G'] | Death Wins a.k.a Ish Chhabra was here
ish12321 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2017 , 16:15   Re: Auto admin removal after days
Reply With Quote #17

You still did not answer my question. I'm not going to build it to use users.ini unless you give a valid reason.
__________________
Bugsy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 03-18-2017 , 17:46   Re: Auto admin removal after days
Reply With Quote #18

its hard to keep track of temp admins when you add alot 30+ its will be better in a file or a menu in-game to manage all temp admins.
__________________
JusTGo is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2017 , 18:30   Re: Auto admin removal after days
Reply With Quote #19

How about a menu system

1. Add Admin - Show a menu of all non-permanent admins currently in game, select to add as temp
2. Remove Admin - Show a menu of all current temporary admins, select to remove
__________________
Bugsy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 03-18-2017 , 18:57   Re: Auto admin removal after days
Reply With Quote #20

yeah it will be better with menu but i don't think nvault is best to use in this case you will need info's about temp admin in the menu like Steam-id, last name, date added, time left for removal ect..
__________________
JusTGo is offline
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 14:40.


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