Ping Textdraw?
#1

How would I go on about and make a textdraw that shows the ping in white on a player? (Their ping on their body)
Reply
#2

You are thinking of 3dtexts.

Edit:

OnPlayerSpawn()
pawn Код:
new ping, text[12];
ping = GetPlayerPing(playerid);

format(text, sizeof(text), "Ping: %d", ping);

label[playerid] = Create3DTextLabel(text, 0x008080FF,30.0,40.0,50.0,40.0,0);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
Make a callback and a timer and call this function like every 10th second or something.
pawn Код:
for(i=0; i<MAX_PLAYERS, i++)
{
    new ping, text[12];
    ping = GetPlayerPing(i);
    format(text, sizeof(text), "Ping: %d", ping);
    Update3DTextLabelText(label[i], 0xFFFFFFFF, text);
}
and a global variable: Text3D:label[MAX_PLAYERS]
Reply
#3

pawn Код:
new Text3D:ping;
forward updater(playerid);

public OnFilterScriptInit()
{


    ping = Create3DTextLabel("Ping: %d",0xFFFFFFFF, 0.0, 0.0, 0.0, 100, 0, 1);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    Attach3DTextLabelToPlayer(ping, playerid, 0.0, 0.0, 0.0);
    SetTimerEx("updater",1000,false,"i",playerid);
    return 1;
}
public updater(playerid)
{
   new string[128];
   format(string,sizeof(string),"Ping: %d",GetPlayerPing(playerid));
   Update3DTextLabelText(ping, 0xFFFFFFFF, string);
   return 1;
}
Reply
#4

Quote:
Originally Posted by blackwave
Посмотреть сообщение
pawn Код:
new Text3D:ping
forward updater(playerid)

public OnFilterScriptInit()
{


    ping = Create3DTextLabel("Ping: %d",0xFFFFFFFF, 0.0, 0.0, 0.0, 100, 0, 1);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    Attach3DTextLabelToPlayer(ping, playerid, 0.0, 0.0, 0.0);
    SetTimerEx("updater",1000,false,"i",playerid);
    return 1;
}
public updater(playerid)
{
   new string[128];
   format(string,sizeof(string),"Ping: %d",GetPlayerPing(playerid));
   Update3DTextLabelText(ping, 0xFFFFFFFF, string);
   return 1;
}
That code won't work and it will return loads of errors. First of all you forgot to close your variables and the forward. Btw you don't need that many cells for a string on max 7 characters. I admit mine should have been smaller to, but 128?!
Reply
#5

Quote:
Originally Posted by _rAped
Посмотреть сообщение
That code won't work and it will return loads of errors. First of all you forgot to close your variables and the forward. Btw you don't need that many cells for a string on max 7 characters. I admit mine should have been smaller to, but 128?!
I ever use 128 at all. And I did it quickly..
Reply
#6

SetTimerEx("updater",1000,false,"i",playerid);

SetTimerEx("updater",1000,true,"i",playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)