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

[REQ] Play Time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 09:23   [REQ] Play Time
Reply With Quote #1

Hi. I want a plugin when a player played more than 48 hours gets TZ flag(VIP).
khashayar007 is offline
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
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 10:09   Re: [REQ] Play Time
Reply With Quote #3

I changed it 10 seconds for testing and It didn't work.
khashayar007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2017 , 10:12   Re: [REQ] Play Time
Reply With Quote #4

Did you disconnect and reconnect. And how do you know it didnt work? The message gets displayed immediately upon connecting so you wouldn't see it, I will need to add a delay.
__________________

Last edited by Bugsy; 10-08-2017 at 10:13.
Bugsy is offline
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 10:21   Re: [REQ] Play Time
Reply With Quote #5

Yes I did. After 10 seconds there was no message and also I checked it via amx_who

Last edited by khashayar007; 10-08-2017 at 10:21.
khashayar007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2017 , 10:37   Re: [REQ] Play Time
Reply With Quote #6

Try the updated code
__________________
Bugsy is offline
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 10:47   Re: [REQ] Play Time
Reply With Quote #7

Not working also no messages shown
khashayar007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2017 , 10:49   Re: [REQ] Play Time
Reply With Quote #8

Are there any errors? Steam?
__________________
Bugsy is offline
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 10:51   Re: [REQ] Play Time
Reply With Quote #9

No errors also I have the latest hlds (build 7561)

Last edited by khashayar007; 10-08-2017 at 10:51.
khashayar007 is offline
khashayar007
Senior Member
Join Date: Jan 2015
Location: Macedonia
Old 10-08-2017 , 11:03   Re: [REQ] Play Time
Reply With Quote #10

My hlds sometimes crashes after adding this plugin
khashayar007 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 13:50.


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