View Single Post
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-27-2017 , 13:36   Re: get_user_time is not supported in client_disconnected?
Reply With Quote #26

Quote:
Originally Posted by OnePL View Post
Sorry, get_user_time returns 0 when map is changing (server is full - 32 players)
I think it returns 0 when someone goes to fastdl on changelevel. It is 0 because get_user_time is reset on reconnect. If you need time that is insensitive to reconnections (like player's time in ServerBrowser) you can use this:
PHP Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    
register_clcmd("say /mytime""MyTime");
}

public 
MyTime(player) {
    
client_print(playerprint_chat"%f"GetPlayerTime(player));
}

Float:GetPlayerTime(player) {
    new 
pUserInfo engfunc(EngFunc_GetInfoKeyBufferplayer);
    new 
userInfoOffs is_linux_server() ? 0x4AA0 0x4BC0;
    new 
pClient pUserInfo userInfoOffs;
    new 
netchanConnectTimeOffs is_linux_server() ? 0x3C 0x40;
    new 
pNetchanConnectTime pClient netchanConnectTimeOffs;
    new 
Float:netchanConnectTime any:get_tr2(pNetchanConnectTimeTR_AllSolid);
    
// netchanConnectTime is realtime based and Time is Sys_FloatTime based
    // but Sys_FloatTime is nearly the same as realtime, the difference should be lower than 1ms
    
return Float:engfunc(EngFunc_Time) - netchanConnectTime;

But it is sensitive to retry and fastdl.
__________________

Last edited by PRoSToTeM@; 04-27-2017 at 13:38.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@