Thread: [REQ] Play Time
View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2017 , 09:43   Re: [REQ] Play Time
Reply With Quote #2

Untested and I'm not sure what flag you want, so you need to update that part in the code.
PHP Code:

#include <amxmodx>
#include <nvault>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

const FortyEightHours = ( 86400 );

enum PlayerData
{
    
pdAuthID34 ],
    
pdConnectTime,
    
pdPlayTime,
    
pdIgnorePlayer
}

new 
g_pdDataMAX_PLAYERS ][ PlayerData ];
new 
g_Vault;

public 
plugin_init() 
{
    
register_plugin"Play Time VIP" Version "bugsy" );

    
g_Vault nvault_open"ptvip" );
}

public 
plugin_end() 
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    new 
szTime11 ] , iTS szMsg48 ];
    
    if ( !( 
g_pdDataid ][ pdIgnorePlayer ] = ( is_user_botid ) || is_user_hltvid ) ) ) )
    {
        
get_user_authidid g_pdDataid ][ pdAuthID ] , charsmaxg_pdData[][ pdAuthID ] ) );
        
        
g_pdDataid ][ pdConnectTime ] = get_systime();
        
        if ( 
nvault_lookupg_Vault g_pdDataid ][ pdAuthID ] , szTime charsmaxszTime ) , iTS ) )
        {
            
g_pdDataid ][ pdPlayTime ] = str_to_numszTime );
            
            if ( 
g_pdDataid ][ pdPlayTime ] >= FortyEightHours )
            {
                
set_user_flagsid ADMIN_LEVEL_F );
                
                
formatexszMsg charsmaxszMsg ) , "You have played for %d seconds and now have VIP" g_pdDataid ][ pdPlayTime ] );
            }
            else
            {
                
formatexszMsg charsmaxszMsg ) , "You have played for %d seconds. Play more to get VIP" g_pdDataid ][ pdPlayTime ] );
            }
        }
        else
        {
            
copyszMsg charsmaxszMsg ) , "This is your first time connecting." );
        }
        
        
set_task8.0 "ShowMessage" id , .parameter=szMsg , .len=sizeofszMsg ) );
    }
}

public 
client_disconnectid )
{
    new 
szTime11 ];
    
    if ( !
g_pdDataid ][ pdIgnorePlayer ] )
    {
        
num_to_strg_pdDataid ][ pdPlayTime ] + ( get_systime() - g_pdDataid ][ pdConnectTime ] ) , szTime charsmaxszTime ) );
        
nvault_setg_Vault g_pdDataid ][ pdAuthID ] , szTime );
        
g_pdDataid ][ pdPlayTime ] = 0;
    }
}

public 
ShowMessageszMsg[] , id )
{
    if ( 
is_user_connectedid ) )
    {
        
client_printid print_chat szMsg );
    }

__________________

Last edited by Bugsy; 10-09-2017 at 21:47.
Bugsy is offline