View Single Post
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-05-2022 , 13:15   Re: Time played ( First seen & Last seen )
Reply With Quote #4

Quote:
Originally Posted by bigdaddy424 View Post
Can you explain the use of using a task instead of subtracting @disonnected get_systime() with the one from @putinserver
Code:
 It is check when the user connecting to the server public client_putinserver( id ) {  Load the data from nvault         UseNvault( id, false )  after loading the data check if this user has joined before or not and if he is not then read the current time         if( !g_iPlayer[ id ][ First_Seen ] ) g_iPlayer[ id ][ First_Seen ] = get_systime( );  I see this way is better than saves get_user_time so if i used that way it gonna be like this g_iPlayer[ id ][ Time_Played ] += get_user_time( id ) / 60 and i need to use this way everytime when return it  But using task for check the time every second when connected to the server is faster and better         set_task( 1.0, "DisplayTimePlayed", id + TASK_TIME_PLAYED, .flags = "b" ); // Faster than get_user_time     } } public client_disconnected( id ) {     if( !g_iPlayer[ id ][ bBot_HLTV ] )     {  Read the current time every time when the user left the server         g_iPlayer[ id ][ Last_Seen ] = get_systime( );         UseNvault( id, true ); // save the data  Clear the data         arrayset( g_iPlayer[ id ][ Name ], 0, sizeof( g_iPlayer[ ][ Name ] ) );         arrayset( g_iPlayer[ id ][ AuthID ], 0, sizeof( g_iPlayer[ ][ AuthID ] ) );         arrayset( g_iPlayer[ id ][ IP ], 0, sizeof( g_iPlayer[ ][ IP ] ) );         arrayset( g_iPlayer[ id ][ Time_Played ], 0, sizeof( g_iPlayer[ ][ Time_Played ] ) );         arrayset( g_iPlayer[ id ][ First_Seen ], 0, sizeof( g_iPlayer[ ][ First_Seen ] ) );         arrayset( g_iPlayer[ id ][ Last_Seen ], 0, sizeof( g_iPlayer[ ][ Last_Seen ] ) );         arrayset( g_iPlayer[ id ][ bBot_HLTV ], false, sizeof( g_iPlayer[ ][ bBot_HLTV ] ) );         remove_task( id + TASK_TIME_PLAYED );     } }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 02-05-2022 at 13:30.
Supremache is offline