• 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!

Add Ping - OTX 2

potinho

Intermediate OT User
Joined
Oct 11, 2009
Messages
1,397
Solutions
17
Reaction score
148
Location
Brazil
How to add ping on OTCv8? Im using OTX 2 (TFS 0.3.7)
1637705374248.png
 
Maybe with some custom module making use of opcodes and updating this function:
modules/client_topmenu/topmenu.lua
1641920227528.png
 
Just open tfs1.2 sources and copy and paste function responsible for ping to your server
 
You can find all the server source modification here
my server dont have data/events/scripts/player.lua, believe because old engine (OTX 2)

Now ping is enabled but show a incorrect value, i dont have lag.

1657570539232.png

Someone can help me fix this?
 
I can try yelling "WORK DAMN YOU!" at the pictures you provided but probably would do better if you provided the code for the ping where it checks connection strength/ping so we can see why/where the values are coming from. For all we know, the values are technically displaying correctly and the script isn't modified to ping your server but instead pings another IP which you indeed have a bad connection too.

TL/DR: Provide code for analysis.
 
I can try yelling "WORK DAMN YOU!" at the pictures you provided but probably would do better if you provided the code for the ping where it checks connection strength/ping so we can see why/where the values are coming from. For all we know, the values are technically displaying correctly and the script isn't modified to ping your server but instead pings another IP which you indeed have a bad connection too.

TL/DR: Provide code for analysis.
Here ping stuffs that i have in my sources

at game.cpp
C++:
bool Game::playerReceivePing(uint32_t playerId)
{
    Player* player = getPlayerByID(playerId);
    if(!player || player->isRemoved())
        return false;

    player->receivePing();
    return true;
}

player.cpp
C++:
    lastLoad = lastPing = lastPong = lastAttack = lastMail = OTSYS_TIME();
AND
Code:
void Player::onThink(uint32_t interval)
{
    Creature::onThink(interval);
    int64_t timeNow = OTSYS_TIME();
    if(timeNow - lastPing >= 5000)
    {
        lastPing = timeNow;
        if(hasClient())
            client->sendPing();
        else if(g_config.getBool(ConfigManager::STOP_ATTACK_AT_EXIT))
            setAttackedCreature(NULL);
    }

    if((timeNow - lastPong) >= 60000 && !getTile()->hasFlag(TILESTATE_NOLOGOUT)
        && !isConnecting && !pzLocked && !hasCondition(CONDITION_INFIGHT))
    {
        if(hasClient())
            client->logout(true, true);
        else if(g_creatureEvents->playerLogout(this, false))
            g_game.removeCreature(this, true);
    }

    messageTicks += interval;
    if(messageTicks >= 1500)
    {
        messageTicks = 0;
        addMessageBuffer();
    }

player.h
Code:
        void receivePing() {lastPong = OTSYS_TIME();}
        virtual void onThink(uint32_t interval);
and
Code:
        int64_t lastPong;
        int64_t lastPing;

at protocolgame.cpp
C++:
void ProtocolGame::parseReceivePing(NetworkMessage&)
{
    addGameTask(&Game::playerReceivePing, player->getID());
and
C++:
        void sendPing();

spectators.h
C++:
        void sendPing()
        {
            if(!owner)
                return;

            owner->sendPing();
            for(SpectatorList::iterator it = spectators.begin(); it != spectators.end(); ++it)
                it->first->sendPing();
        }
 
i have the ping system working in otx2 but it's not otcv8 one just the normal ping sytem
 
Back
Top