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

Solved Admins Playtime


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
farhanhyper
Member
Join Date: Dec 2017
Location: Finland
Old 05-31-2019 , 15:26   Admins Playtime
Reply With Quote #1

Hi

I need a plugin that when a player say /at it shows how much time admins played in a server and how many times did they connect to the server.
__________________
Never Say Never

Last edited by farhanhyper; 06-06-2019 at 07:11.
farhanhyper is offline
BesTKiLLeR
Junior Member
Join Date: Jun 2019
Location: 127.0.0.1
Old 06-01-2019 , 10:54   Re: Admins Playtime
Reply With Quote #2

Did you check this?
https://forums.alliedmods.net/showthread.php?p=457071
BesTKiLLeR is offline
farhanhyper
Member
Join Date: Dec 2017
Location: Finland
Old 06-01-2019 , 12:18   Re: Admins Playtime
Reply With Quote #3

Quote:
Originally Posted by BesTKiLLeR View Post
Yes,but that plugin is not what I want.I want it shows just admins playtime not specific player or all the players.
__________________
Never Say Never
farhanhyper is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-01-2019 , 21:41   Re: Admins Playtime
Reply With Quote #4

You want this to only record admins play time, and when any player says /at, it shows each admin name and their number of connections and total play time?
__________________
Bugsy is offline
farhanhyper
Member
Join Date: Dec 2017
Location: Finland
Old 06-02-2019 , 00:50   Re: Admins Playtime
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
You want this to only record admins play time, and when any player says /at, it shows each admin name and their number of connections and total play time?
Thats exactly what I want
__________________
Never Say Never
farhanhyper is offline
Old 06-03-2019, 10:29
BesTKiLLeR
This message has been deleted by BesTKiLLeR. Reason: Test :|
BesTKiLLeR
Junior Member
Join Date: Jun 2019
Location: 127.0.0.1
Old 06-03-2019 , 11:27   Re: Admins Playtime
Reply With Quote #6

I edited this plugin (now only save admins playtime and players can see their playtime via /at)
Attached Files
File Type: sma Get Plugin or Get Source (played_time_authid.sma - 326 views - 5.9 KB)

Last edited by BesTKiLLeR; 06-03-2019 at 11:28.
BesTKiLLeR is offline
farhanhyper
Member
Join Date: Dec 2017
Location: Finland
Old 06-04-2019 , 01:43   Re: Admins Playtime
Reply With Quote #7

Quote:
Originally Posted by BesTKiLLeR View Post
I edited this plugin (now only save admins playtime and players can see their playtime via /at)
but excuse me,It shows all the players playtime.I want to shows just admins playtime and number of their connections to the server like this:

name - flags - time - number of connections

1.Farhanhyper - abcdefghijklmnopqrstu - 5minutes - 5times
__________________
Never Say Never
farhanhyper is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-04-2019 , 20:31   Re: Admins Playtime
Reply With Quote #8

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_disconnectid )
{
    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 );
    
    if ( 
iCount )
    {
        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 );
        }
    }
    else
    {
        
copyszHUD charsmaxszHUD ) , "No data to display" );
    }
    
    
set_hudmessage255 255 255 0.05 0.30 0.07.0 );
    
show_hudmessageid szHUD );
    
    return 
PLUGIN_HANDLED;

__________________

Last edited by Bugsy; 06-05-2019 at 17:59.
Bugsy is offline
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
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-05-2019 , 17:45   Re: Admins Playtime
Reply With Quote #10

Try now, I don't think 1.8.2 or 1.8.3 like client_disconnected()

Also, did you read this in the nVault Utility & Array pages? Make sure you use this module.
Quote:
Note: This include file requires that you use a fixed version of the nVault module. During the development of these new functions, a bug was discovered in the nVault module that will result in invalid values and possibly errors. This fixed module is attached below and is also available in AMX-X dev builds >= 4589. Thanks to Arkshine for fixing this so quickly for me.
__________________

Last edited by Bugsy; 06-05-2019 at 17:56.
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 03:20.


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