• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X playerGetPing is very imprecise

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
48
Hi, I'm using tfs 0.4 and this getPlayerPing from mock adapted but it is very imprecise, when I ping my server with cmd it says that my ping is over 100, but this function says I'm at 20 something ping, any idea how I can improve it?

Here's the 0.4 version
C++:
int32_t LuaInterface::luaDoPlayerSendPing(lua_State* L) // Adaptado by Yan Liima(Night for tibiaking.com)
{
    //doPlayerSendPing(cid)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID(popNumber(L));
    if(!player)
    {
        lua_pushboolean(L, false);
        return 1;
    }
    int64_t timeNow = OTSYS_TIME();
    player->lastPing = timeNow;
    if(player->client)
    {
            void sendPing();
            lua_pushboolean(L, true);
    }else{
          lua_pushboolean(L, false);       
          }
    lua_pushboolean(L, true);
 
    return 1;
}
int32_t LuaInterface::luaGetOtsysTime(lua_State* L)
{
    //getOtsysTime()
    lua_pushnumber(L, OTSYS_TIME());
    return 1;
}
int32_t LuaInterface::luaGetPlayerLastPing(lua_State* L)
{
    //getPlayerLastPing(cid)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID(popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
         lua_pushboolean(L, false);
        return 1;
    }
    lua_pushnumber(L, player->lastPing);
    return 1;
}
int32_t LuaInterface::luaGetPlayerLastPong(lua_State* L)
{
    //getPlayerLastPong(cid)
    ScriptEnviroment* env = getEnv();
    Player* player = env->getPlayerByUID(popNumber(L));
    if(!player)
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
         lua_pushboolean(L, false);
        return 1;
    }
    lua_pushnumber(L, player->lastPong);
    return 1;
}
 
can u help me to put it to work here?
 
Back
Top