Examples/Floating_names_and_a_key_bind_client
BindKey("F5", BINDTYPE_DOWN, "toggleLabels");
labelsOn <- true;
function toggleLabels()
{
labelsOn = !labelsOn;
Message("Labels " + (labelsOn ? "on" : "off"));
}
function onClientRender()
{
if (!labelsOn) return;
for (local i = 0; i < MAX_PLAYERS; i++)
{
local p = FindPlayer(i);
if (p && p.ID != FindLocalPlayer().ID)
{
local pos = p.Pos;
local text = p.Name + " (" + p.Health.tointeger() + "hp)";
Draw3DText(text, pos.x, pos.y, pos.z + 1.2, 40.0);
}
}
}Categories: Worked examples