ping TD
#8

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Use a timer with an interval of 1 second to update the ping textdraw, that should be enough.
Most online-games don't even display your ping all the time.
They display the ping when you use a /ping command and it displays only the ping for that moment.

Ping isn't that important to update it up to 30 times per second (OnPlayerUpdate may run over 30 times per second and more as well).
When it's being updated that fast, you can't even read the value because ping isn't the same all the time and the entire textdraw becomes useless.
Good point, although; the server only updates the output of the ping every few seconds, so the textdraw will still be readable; so the code is still sufficient, but the timer is indeed better for optimization.

Use this instead, OP:

Код:
new Text:textid;
new pingUpdate[MAX_PLAYERS];
forward UpdatePlayerPing(playerid);

public OnGameModeInit()
{
    textid = TextDrawCreate(545.0, 27.5, "");
    TextDrawColor(textid, 0xAFAFAFAA);
    return 1;
}

public OnPlayerConnect(playerid)
{
    pingUpdate[playerid] = SetTimerEx("UpdatePlayerPing", 1000, true, "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(pingUpdate[playerid]);
    return 1;
}

public UpdatePlayerPing (playerid)
{
    new ping;
    new string[128];
    ping = GetPlayerPing (playerid);
    format (string, sizeof(string), "PING: %d", ping);
    TextDrawSetString(textid, string);
    TextDrawShowForPlayer(playerid, textid);
    return 1;
}
Reply


Messages In This Thread
ping TD - by sams90 - 03.03.2017, 14:40
Re: ping TD - by Edwin2801 - 03.03.2017, 14:46
Re: ping TD - by sams90 - 03.03.2017, 14:52
Re: ping TD - by Edwin2801 - 03.03.2017, 15:00
Re: ping TD - by LEOTorres - 03.03.2017, 15:17
Re: ping TD - by sams90 - 03.03.2017, 15:23
Re: ping TD - by PowerPC603 - 03.03.2017, 15:27
Re: ping TD - by LEOTorres - 03.03.2017, 15:39
Re: ping TD - by sams90 - 04.03.2017, 02:04
Re: ping TD - by Edwin2801 - 04.03.2017, 06:49

Forum Jump:


Users browsing this thread: 4 Guest(s)