AddWorldTip

From Garry's Mod
Jump to: navigation, search
 AddWorldTip( )

Contents

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.

NOTE

This function is only available in Sandbox and its derivatives

Arguments

number entindex=nil

This argument is no longer used; it has no effect on anything. You can use nil in this argument.

Arguments

string text

The text for the world tip to display.

Arguments

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.

Arguments

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.

Arguments

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.

Examples

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 )


Personal tools
Navigation