AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Play Time (https://forums.alliedmods.net/showthread.php?t=301888)

khashayar007 10-08-2017 09:23

[REQ] Play Time
 
Hi. I want a plugin when a player played more than 48 hours gets TZ flag(VIP).

Bugsy 10-08-2017 09:43

Re: [REQ] Play Time
 
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 );
    }



khashayar007 10-08-2017 10:09

Re: [REQ] Play Time
 
I changed it 10 seconds for testing and It didn't work.

Bugsy 10-08-2017 10:12

Re: [REQ] Play Time
 
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.

khashayar007 10-08-2017 10:21

Re: [REQ] Play Time
 
Yes I did. After 10 seconds there was no message and also I checked it via amx_who

Bugsy 10-08-2017 10:37

Re: [REQ] Play Time
 
Try the updated code

khashayar007 10-08-2017 10:47

Re: [REQ] Play Time
 
Not working also no messages shown

Bugsy 10-08-2017 10:49

Re: [REQ] Play Time
 
Are there any errors? Steam?

khashayar007 10-08-2017 10:51

Re: [REQ] Play Time
 
No errors also I have the latest hlds (build 7561)

khashayar007 10-08-2017 11:03

Re: [REQ] Play Time
 
My hlds sometimes crashes after adding this plugin


All times are GMT -4. The time now is 01:02.

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