Garry's Mod Wiki

AddWorldTip

  AddWorldTip( number entindex = nil, string text, number dieTime = SysTime() + 0.05, Vector pos = ent:GetPos(), Entity ent = nil )

Description

This function creates a World Tip, similar to the one shown when aiming at a Thruster where it shows you its force.

This function will make a World Tip that will only last 50 milliseconds (1/20th of a second), so you must call it continuously as long as you want the World Tip to be shown. It is common to call it inside a Think hook.

Contrary to what the function's name implies, it is impossible to create more than one World Tip at the same time. A new World Tip will overwrite the old one, so only use this function when you know nothing else will also be using it.

See SANDBOX:PaintWorldTips for more information.

This function is only available in Sandbox and its derivatives

Arguments

1 number entindex = nil
This argument is no longer used; it has no effect on anything. You can use nil in this argument.
2 string text
The text for the world tip to display.
3 number dieTime = SysTime() + 0.05
This argument is no longer used; when you add a World Tip it will always last only 0.05 seconds. You can use nil in this argument.
4 Vector pos = ent:GetPos()
Where in the world you want the World Tip to be drawn. If you add a valid Entity in the next argument, this argument will have no effect on the actual World Tip.
5 Entity ent = nil
Which entity you want to associate with the World Tip. This argument is optional. If set to a valid entity, this will override the position set in pos with the Entity's position.

Example

Creates a World Tip where the player is looking. If the player is looking at an entity, the World Tip is positioned on the entity.

hook.Add( "Think", "draw World Tip", function() local ply = Entity( 1 ) local tr = ply:GetEyeTrace() local pos = tr.HitPos -- will be unused if ent is valid local ent = tr.Entity AddWorldTip( nil, "Hello world!", nil, pos, ent ) end )