ping TD
#1

how to make ping TextDraw?
Reply
#2

GetPlayerPing + TextDrawSetString
Reply
#3

i know but how to make?
Reply
#4

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

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;
}
Reply
#6

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
Reply
#7

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.
Reply
#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
#9

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

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


Forum Jump:


Users browsing this thread: 5 Guest(s)