[HELP]Update ping 3DText.
#1

pawn Код:
new Text3D:label[MAX_PLAYERS];
pawn Код:
new string[256];
    new ping;
    ping=GetPlayerPing(playerid);
    format(string,sizeof(string),"ping: %d",ping);
    label[playerid] = Create3DTextLabel(string, 0x008080FF,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.3);
my doubt is, the ping does not update ...
is only 65535, why?

thanks.
Reply
#2

where is this code place. if its onplayerspawn. thats why its not working. ur best bet as the ping always changes is to make a timer. or im not sure but u could try onplayerupdate.
Reply
#3

Yep the ping will not update, because
GetPlayerPing only returns ping at the current time;

you need to put it under a timer or something.
ex

pawn Код:
new PingTimer;

public OnFilterScriptInit()
{
....
    PingTimer = SetTimer("PingLabelUpdate", 5000, true); //run it every 5 seconds
}
public OnFilterScriptInit()
{
    KillTimer(PingTimer);
}


forward PingLabelUpdate();
public PingLabelUpdate()
{
    new string[256];
    new ping;
    for(new playerid=0; playerid<GetMaxPlayers(); playerid++)
    {
        if(!IsPlayerConnected(playerid)) continue;
        ping=GetPlayerPing(playerid);
        format(string,sizeof(string),"ping: %d",ping);
        Update3DTextLabelText(label[playerid], 0x008080FF, string);
    }
}
Reply
#4

now not show up anything
/imageshack/img193/864/123il.jpg
Reply
#5

Post your script that includes this and i will take a look.
Reply
#6

oh i know why. he prob replaced his entire code with your one so now its not showing. u still need to add the created text and the attach text to player.this code simply like updates ur code every 5 seconds.
Reply
#7

Quote:
Originally Posted by bluray
oh i know why. he prob replaced his entire code with your one so now its not showing. u still need to add the created text and the attach text to player.this code simply like updates ur code every 5 seconds.
Yep, thats what i am worried about. So if he posts his code I will fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)