SA-MP Forums Archive
ping TD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ping TD (/showthread.php?tid=629760)



ping TD - sams90 - 03.03.2017

how to make ping TextDraw?


Re: ping TD - Edwin2801 - 03.03.2017

GetPlayerPing + TextDrawSetString


Re: ping TD - sams90 - 03.03.2017

i know but how to make?


Re: ping TD - Edwin2801 - 03.03.2017

Get the ping, format it to a string (%i, ping), and set textdraw
OK?


Re: ping TD - LEOTorres - 03.03.2017

Here, this should display the PING above the armour bar:

Код:
new Text:textid;

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

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



Re: ping TD - sams90 - 03.03.2017

Quote:
Originally Posted by LEOTorres
Посмотреть сообщение
Here, this should display the PING above the armour bar:

Код:
new Text:textid;

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

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


Re: ping TD - PowerPC603 - 03.03.2017

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.


Re: ping TD - LEOTorres - 03.03.2017

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;
}



Re: ping TD - sams90 - 04.03.2017

ty guys i need abit more help.
how to make k/d td for player i mean kill and death ratio TD.


Re: ping TD - Edwin2801 - 04.03.2017

We must create it for you?
You have been given the ready code. What are you need?