Garry's Mod Wiki

Garry's Mod Wiki

  gui.AddCaption( string captionStream, number duration, boolean fromPlayer = false )

Description

Pushes text to the closed caption box.

The function will not work, if the console command variable closecaption is set to 0.

Arguments

1 string captionStream
The caption to emit. See Closed Captions for more info.

Note the ability to add special commands to captions, such as <sfx> to mark the caption as a sound effect caption, which would be hidden if cc_subtitles is set to 1. (To only show dialogue subtitles)

2 number duration
How long the caption should stay for
3 boolean fromPlayer = false
Is this caption coming from the player?

This is used to give different colors to the caption to differentiate, for example, whether the SMG is fired by the player or an NPC.

Example

Prints "Hello World" in bold

// For the sake of the test: activate the caption system. // You should not be forcing this option on players, it should be up to the player to choose whether they want to see captions or not. RunConsoleCommand( "closecaption", "1" ) // Push a new caption text to the UI gui.AddCaption( "<B>Hello World!<B>", 5 )
Output:
image.png

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...