Cinematics shows cinematics: black letterbox bars slide in from the top and the bottom of the screen, text fades in, stays for a while and fades out, and the bars slide back out. A cinematic has a caption on the bottom bar, a title with a subtitle in the middle of the screen, or both. Cinematics are queued on the client and played one after another; the bars stay in place between two of them. While the bars are on screen the top bars, the info display and the crosshair are hidden, and the bars are drawn above the rest of the HUD.

The server shows a cinematic to one player, a list of players or everyone with Cinematics:show and takes them off the screen with Cinematics:clear. Client code queues one for the local player with Cinematics:add.

-- Server: a caption for everyone.
Cinematics:show(nil, 'The curfew has begun.')

-- Server: a title card for one player, with a language phrase as the caption.
Cinematics:show(target, {
  title = 'Chapter One',
  subtitle = 'Point Insertion',
  text = 'my_schema.chapter_one.caption',
  arguments = { name = target:name() },
  duration = 8
})

When a player loads a character for the first time since joining, the plugin plays an intro: the name of the schema as the title, its description as the subtitle and a credits line with its author as the caption. The 'cinematic_intro' config turns the intro off, and the GetCinematicIntroInfo hook lets a schema change, replace or suppress it.

The look comes from the theme, which the plugin fills in from its OnThemeLoaded handler: the 'cinematic_bar_size', 'cinematic_duration', 'cinematic_slide_time' and 'cinematic_fade_time' options, the 'cinematic_bars', 'cinematic_text' and 'cinematic_title' colors and the 'cinematic_caption', 'cinematic_title' and 'cinematic_subtitle' fonts. The handler of a schema runs after the one of the plugin, so a schema overrides them from its own OnThemeLoaded.

Summary

Hooks

Sets the options, colors and fonts of the cinematics on the theme that was loaded.
Plays the intro when the local player loads a character for the first time since joining, unless the 'cinematic_intro' config is off.
Draws the letterbox bars and the text of the cinematic that is being played.
Keeps the info display from being drawn while the letterbox bars are on screen.
Hides the top bars while the letterbox bars are on screen.
Hides the crosshair while the letterbox bars are on screen.
Think()client
Advances the timeline of the cinematics every frame while there is anything to play.

Functions

Draws lines of text one below another, aligned to a horizontal position and outlined in black so that they stay readable on any background.
Converts a color that may have come over the network to an opaque Color.

Methods

Queues a cinematic for the local player.
advance(frame_time)client internal
Advances the timeline: updates the tween or the countdown of the current stage and moves on to the next stage, the next cinematic or the closing of the bars when it is over.
Takes the cinematic that is on screen away from one player, several players or everyone, along with the ones they have queued.
Draws the letterbox bars and, once it has started to fade in, the text of the cinematic that is being played: the caption in the middle of the bottom bar, the title and the subtitle above the middle of the screen.
Returns the cinematic that is being played.
Checks whether the letterbox bars are on screen, which is when the plugin hides the top bars, the info display and the crosshair.
Wraps the texts of a cinematic to the width of the screen and stores the lines in it.
Builds the intro cinematic out of the name, the description and the author of the schema and queues it, unless the GetCinematicIntroInfo hook suppresses it.
set_stage(stage)client internal
Switches the timeline to a stage and sets up the tween or the countdown that drives it.
Shows a cinematic to one player, several players or everyone.
start_next()client internal
Takes the next cinematic off the queue and starts it.

Hooks

Cinematics:OnThemeLoaded(current_theme)

client plugins/cinematics/plugin/cl_hooks.lua:8

Implements hook OnThemeLoaded

Sets the options, colors and fonts of the cinematics on the theme that was loaded.

Parameters

  • current_theme ThemeBase

Cinematics:PostCharacterLoaded(char_id)

client plugins/cinematics/plugin/cl_hooks.lua:72

Implements hook PostCharacterLoaded

Plays the intro when the local player loads a character for the first time since joining, unless the 'cinematic_intro' config is off.

Parameters

  • char_id Number ID of the character that has been loaded

Cinematics:PostDrawHUD()

client plugins/cinematics/plugin/cl_hooks.lua:36

Draws the letterbox bars and the text of the cinematic that is being played. This hook runs once the HUD has been drawn, which puts the cinematic above everything on it.

Cinematics:PreDrawInfoDisplay(_icons)

client plugins/cinematics/plugin/cl_hooks.lua:55

Implements hook PreDrawInfoDisplay

Keeps the info display from being drawn while the letterbox bars are on screen.

Parameters

  • _icons Map all of the registered icons by ID

Returns

  • Boolean true while the letterbox bars are on screen, otherwise nil

Cinematics:ShouldDrawBar(bar)

client plugins/cinematics/plugin/cl_hooks.lua:46

Implements hook ShouldDrawBar

Hides the top bars while the letterbox bars are on screen. Bars of the other types, such as the respawn bar, are drawn in the middle of the screen and stay visible.

Parameters

  • bar Map bar data

Returns

  • Boolean false for a top bar while the letterbox bars are on screen, otherwise nil

Cinematics:ShouldHUDPaintCrosshair()

client plugins/cinematics/plugin/cl_hooks.lua:63

Implements hook ShouldHUDPaintCrosshair

Hides the crosshair while the letterbox bars are on screen.

Returns

  • Boolean false while the letterbox bars are on screen, otherwise nil

Cinematics:Think()

client plugins/cinematics/plugin/cl_hooks.lua:28

Advances the timeline of the cinematics every frame while there is anything to play.

Functions

Cinematics.draw_lines(lines, font, x, y, color, align)

client plugins/cinematics/plugin/cl_plugin.lua:83

Draws lines of text one below another, aligned to a horizontal position and outlined in black so that they stay readable on any background. Other plugins that draw text over the screen, such as Area Display, use it as well.

Parameters

  • lines List<String> lines to draw
  • font String font name
  • x Number screen x the lines are aligned to
  • y Number screen y of the top of the first line
  • color Color text color, with the alpha to draw the text at
  • align Number optional, defaults to TEXT_ALIGN_CENTER horizontal alignment, one of the TEXT_ALIGN enums

Returns

  • Number screen y below the last line

Cinematics.to_color(value)

client plugins/cinematics/plugin/cl_plugin.lua:67

Converts a color that may have come over the network to an opaque Color. Other plugins that show text sent by the server, such as Area Display, use it as well.

Parameters

  • value Color/Map color, or any table with the r, g and b fields

Returns

  • Color the color without its alpha, or nil if the value is not a color

Methods

Cinematics:add(cinematic)

client plugins/cinematics/plugin/cl_plugin.lua:122

Queues a cinematic for the local player. It is played once the cinematics queued before it are over. The texts are translated when the cinematic is queued, so each of them can be a language phrase or plain text.

Cinematics:add('The curfew has begun.')

Cinematics:add({
  title = 'City 17',
  subtitle = 'Trainstation',
  color = Color(255, 220, 160),
  duration = 8,
  bar_size = 0.12
})

Parameters

  • cinematic String/Map caption text or language phrase, or a table with the fields: text (caption on the bottom bar), title and subtitle (drawn in the middle of the screen), arguments (Map of values for the placeholders of the phrases), color (Color of the text, the 'cinematic_text' theme color by default), title_color (Color of the title, the color of the text by default), duration (seconds the text stays once it has faded in, the 'cinematic_duration' theme option by default), delay (seconds to wait before the cinematic starts, 0 by default), bar_size (height of a bar as a fraction of the screen height from 0 to 0.5, the 'cinematic_bar_size' theme option by default) and replace (true to drop the cinematic on screen and the queued ones first)

Returns

  • Map the queued cinematic, or nil if it has no text, title or subtitle

Cinematics:advance(frame_time)

client internal plugins/cinematics/plugin/cl_plugin.lua:283

Internal

This function is internal. It is not part of the public API and may change without notice.

Advances the timeline: updates the tween or the countdown of the current stage and moves on to the next stage, the next cinematic or the closing of the bars when it is over. A cinematic that is queued while the bars are closing starts right away, from where the bars are, unless it has a delay: then the bars finish closing first.

Parameters

  • frame_time Number seconds that have passed since the last call

Cinematics:clear(targets)

shared plugins/cinematics/plugin/sv_plugin.lua:34

On the server

Takes the cinematic that is on screen away from one player, several players or everyone, along with the ones they have queued. The text disappears at once and the bars slide out.

Parameters

  • targets Player/List<Player> whose cinematics to clear; everyone if nil. Players that are not valid any more are left out

On the client

Drops the queued cinematics and takes the one on screen away: its text disappears at once and the bars slide out.

Parameters

  • targets

Defined in

Cinematics:draw(scrw, scrh)

client plugins/cinematics/plugin/cl_plugin.lua:342

Draws the letterbox bars and, once it has started to fade in, the text of the cinematic that is being played: the caption in the middle of the bottom bar, the title and the subtitle above the middle of the screen.

Parameters

  • scrw Number screen width
  • scrh Number screen height

Cinematics:get_current()

client plugins/cinematics/plugin/cl_plugin.lua:182

Returns the cinematic that is being played.

Returns

  • Map the cinematic as queued by Cinematics:add, or nil if there is none

Cinematics:is_active()

client plugins/cinematics/plugin/cl_plugin.lua:176

Checks whether the letterbox bars are on screen, which is when the plugin hides the top bars, the info display and the crosshair.

Returns

  • Boolean

Cinematics:layout(cinematic, scrw)

client internal plugins/cinematics/plugin/cl_plugin.lua:316

Internal

This function is internal. It is not part of the public API and may change without notice.

Wraps the texts of a cinematic to the width of the screen and stores the lines in it.

Parameters

  • cinematic Map the cinematic, as queued by Cinematics:add
  • scrw Number screen width

Cinematics:play_intro(char_id)

client plugins/cinematics/plugin/cl_plugin.lua:190

Builds the intro cinematic out of the name, the description and the author of the schema and queues it, unless the GetCinematicIntroInfo hook suppresses it.

Parameters

  • char_id Number optional, defaults to nil ID of the character that has been loaded, passed on to the hook

Returns

  • Map the queued cinematic, or nil if the intro has been suppressed or has no text

Cinematics:set_stage(stage)

client internal plugins/cinematics/plugin/cl_plugin.lua:229

Internal

This function is internal. It is not part of the public API and may change without notice.

Switches the timeline to a stage and sets up the tween or the countdown that drives it. An 'open' stage that has nothing to move, because the bars already have the size the cinematic asks for, turns into 'fade_in'.

Parameters

  • stage String 'delay', 'open', 'fade_in', 'hold', 'fade_out' or 'close'; nil when nothing is left to play

Cinematics:show(targets, cinematic)

server plugins/cinematics/plugin/sv_plugin.lua:18

Shows a cinematic to one player, several players or everyone. It is added to the queue of every receiver and played once the cinematics queued before it are over. Clients that have not been initialized yet, or that have no character loaded, ignore it.

Cinematics:show(nil, 'The curfew has begun.')
Cinematics:show(target, { title = 'City 17', subtitle = 'Trainstation', duration = 8 })

Parameters

  • targets Player/List<Player> who to show the cinematic to; everyone if nil. Players that are not valid any more are left out
  • cinematic String/Map caption text or language phrase, or a table with the fields that Cinematics:add takes on the client: text, title, subtitle, arguments, color, title_color, duration, delay, bar_size and replace

Returns

  • Boolean true if the cinematic has been sent, false if it is not valid

See also

Cinematics:start_next()

client internal plugins/cinematics/plugin/cl_plugin.lua:263

Internal

This function is internal. It is not part of the public API and may change without notice.

Takes the next cinematic off the queue and starts it. With an empty queue the bars are closed if they are on screen, and the timeline stops otherwise.

Returns

  • Map the cinematic that has been started, or nil if the queue is empty

Defined in