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

Plugin calculating hours played...


Post New Thread Reply   
 
Thread Tools Display Modes
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 01-21-2010 , 13:27   Re: Plugin calculating hours played...
Reply With Quote #21

I have it as apart of my default install of 1.8.1, so I guess it's with that version.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
azzou
Member
Join Date: Jan 2014
Location: AlGeRiA
Old 08-17-2014 , 12:22   Re: Plugin calculating hours played...
Reply With Quote #22

PHP Code:
#include <amxmodx>
#include <nvault>

new g_auth[33][24]
new 
g_time_played[33]
new 
g_connect_time[33]
new 
g_db_name[] = "time_played"

public plugin_init(){
    
register_plugin("Player Time Played""1.0""Azzou")
    
register_clcmd("say /h""show_time")
}

public 
show_time(id){
    if(
g_time_played[id] == -1){
        
client_print(idprint_chat"Server was unable to retrieve your time played.")
        return
    }
    new 
time()-g_connect_time[id]+g_time_played[id]
    new 
t/3600
    
new t/60%60
    
new t%60
    client_print
(idprint_chat"Your total time played is: %d hour%s %d minute%s %d second%s.",
    
hh==1?"":"s"mm==1?"":"s"ss==1?"":"s")
}

public 
client_connect(id)
    
g_auth[id][0] = '^0'
    
public client_putinserver(id)
    
g_connect_time[id] = time()

public 
client_authorized(id){
    
get_user_authid(idg_auth[id], 23)
    new 
nv_hnd nvault_open(g_db_name)
    if(
nv_hnd == INVALID_HANDLE){
        
log_amx("Failed to open nVault %s."g_db_name)
        
g_time_played[id] = -1
        
return
    }
    new 
data[10], ts
    
if(!nvault_lookup(nv_hndg_auth[id], data9ts))
        
g_time_played[id] = 0
    
else
        
g_time_played[id] = str_to_num(data)
    
nvault_close(nv_hnd)
}

public 
client_disconnect(id){
    if(
g_auth[id][0] == '^0' || g_time_played[id] == -1)
        return
    new 
nv_hnd nvault_open(g_db_name)
    new 
data[10]
    
formatex(data9"%d"time()-g_connect_time[id]+g_time_played[id])
    
nvault_set(nv_hndg_auth[id], data)
    
nvault_close(nv_hnd

Last edited by azzou; 08-17-2014 at 12:23.
azzou is offline
Reply



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 20:35.


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