Thread: [Solved] Admins Playtime
View Single Post
farhanhyper
Member
Join Date: Dec 2017
Location: Finland
Old 06-05-2019 , 13:40   Re: Admins Playtime
Reply With Quote #9

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

The plugin will not display the admins current time if they are actively connected. The data displayed with the /at command is saved on disconnect.

You will need nVault Utility and nVault Array.

Cvar apt_adminflags holds the flags the player must have to be considered an admin
PHP Code:

#include <amxmodx>
#include <nvault_array>
#include <nvault_util>

#define MAX_PLAYERS 32

new const Version[] = "0.1";

enum AdminData
{
    
adName32 ],
    
adAuthID34 ],
    
adFlags26 ],
    
bool:adIsAdmin,
    
adConnectTime,
    
adPlayTime,
    
adConnections
}

new 
g_adDataMAX_PLAYERS ][ AdminData ];
new 
g_Vault;
new 
pcvarAdminFlags;

public 
plugin_init() 
{
    
register_plugin"Admin Play Time" Version "bugsy" );
    
    
register_clcmd"say /at" "AdminTime" );
    
register_clcmd"say_team /at" "AdminTime" );
    
    
pcvarAdminFlags register_cvar"apt_adminflags" "cde" );
    
    
g_Vault nvault_open"apt_data" );
}

public 
plugin_end() 
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    new 
szFlags26 ] , iPlayerFlags iRequiredFlags;
    
get_pcvar_stringpcvarAdminFlags szFlags charsmaxszFlags ) );
    
    
iPlayerFlags get_user_flagsid );
    
iRequiredFlags read_flagsszFlags );
    
    if ( ( 
g_adDataid ][ adIsAdmin ] = bool:!!( ( iPlayerFlags iRequiredFlags ) == iRequiredFlags ) ) )
    {
        
get_user_authidid g_adDataid ][ adAuthID ] , charsmaxg_adData[][ adAuthID ] ) );
        
nvault_get_arrayg_Vault g_adDataid ][ adAuthID ] , g_adDataid ][ AdminData:] , sizeofg_adData[] ) );
        
        
get_flagsiPlayerFlags g_adDataid ][ adFlags ] , charsmaxg_adData[][ adFlags ] ) );
        
get_user_nameid g_adDataid ][ adName ] , sizeofg_adData[][ adName ] ) );
        
g_adDataid ][ adConnections ]++;
        
g_adDataid ][ adConnectTime ] = get_systime();
    }
}

public 
client_disconnectedid )
{
    if ( 
g_adDataid ][ adIsAdmin ] )
    {
        
g_adDataid ][ adPlayTime ] += ( get_systime() - g_adDataid ][ adConnectTime ] );
        
nvault_set_arrayg_Vault g_adDataid ][ adAuthID ] , g_adDataid ][ AdminData:] , sizeofg_adData[] ) );
    }
}

public 
AdminTimeid )
{
    new 
szHUD1024 ] , iHUDPos;
    new 
iVault iCount iPos szKey] , adDataAdminData ] , iTS;
    
    
nvault_closeg_Vault );
    
g_Vault nvault_open"apt_data" );
    
    
iVault nvault_util_open"apt_data" );
    
    
iCount nvault_util_countiVault );
    
    for ( new 
iCount i++ )
    {
        
iPos nvault_util_read_arrayiVault iPos szKey adDataAdminData:] , sizeofadData ) , iTS );
        
        
iHUDPos += formatexszHUDiHUDPos ] , charsmaxszHUD ) - iHUDPos "^n%d. %s, %s, %d connections, %d minutes" i+adDataadName ] , adDataadFlags ] , adDataadConnections ] , adDataadPlayTime ] / 60 );
    }
    
    if ( 
iCount )
    {
        
set_hudmessage255 255 255 0.05 0.30 0.07.0 );
        
show_hudmessageid szHUD );
    }


Bugsy I tested your plugin with amxmodx version 1.8.2.It compiled correctly without any error but it doesnt work in the server.Does it work with both amxmodx version 1.8.2 and version 1.8.3 ?
__________________
Never Say Never
farhanhyper is offline