RolePlay Commands turns the chat into roleplay chat. Plain text is in character speech heard within the 'talk_radius' config. The text is written in a small markup: *text* segments are actions and can be mixed with speech in one message, (text) is a whisper and text!! a yell, and the amount of parentheses or exclamation marks is the volume, which scales both the hearing radius and the font size. The me, whisper and yell commands only wrap their text in that markup (see RPCommands:wrap_speech), and RPCommands:format_message turns a phrase into a chat line on the server.

Besides speech the plugin adds out of character chat (// and /ooc for everyone, .//, [[ and /looc for the players nearby) with an OOC mute and cooldowns, the it, its, roll, event and eventlocal commands, static texts, and the kinds of speech that the Display Typing plugin shows above a typing player. The roll command rolls dice formulas of the Dice library and the stats and skills of the Stats plugin, and RPCommands:announce_roll shows any roll in the chat the way the command does.

Other plugins can step in through the PlayerCanSayIC, PlayerCanUseOOC, GetPlayerOOCName and PlayerAdjustRoll hooks.

Summary

Hooks

Replaces regular chat messages with formatted in character speech and logs them.
Cancels the message that stands in for a phrase a player was not allowed to say.
Shrinks the typing indicator range for whispers and extends it for yells, by as much as the volume of the phrase changes its hearing radius.
Gives the typing bubble of a player the kind of speech they are typing: its label, the color of the chat line it will become and the range that line will be heard from, which follows the volume of the phrase.
Returns the typing indicator text for emotes, whispers, yells and regular talking.
Draws nearby visible static texts, fading with distance and screen position.
Loads the static texts with the rest of the server data.
Sends a colored chat message to a single player.
Keeps the colors of the registered kinds of speech in step with the chat colors, which arrive from the server after the kinds have been registered.
Keeps what players say through the engine out of the chat.
Registers the kinds of speech of the plugin with the Display Typing plugin, if it is loaded, on both realms: the server reads the range of a kind to decide who is sent the typing bubble, the client its label and color.
Lets look-based messages be heard by players looking within the message radius of the sender.
Limits voice chat to the talk radius.
Prevents gagged players from using the OOC and LOOC chats.
Sends all static texts to a player once they have loaded in.
Registers the permission that exempts a player from the OOC and LOOC cooldowns.
Saves the static texts with the rest of the server data.

Functions

Adds a static text, saves it and sends it to all players.
Removes a static text, saves the change and removes it for all players.

Methods

Shows a roll in the chat to the players within the talk radius of the player who rolled, and to those who look at them from within it, and logs it.
Checks whether a player may say a phrase in character: speech, whispers, yells and actions alike.
Checks whether a player may send a message to the OOC or LOOC chat right now: asks the PlayerCanUseOOC hook, then checks the cooldown.
Checks the cooldown of the OOC or LOOC chat for a player and starts the next one if they may write.
Formats an in character message, scaling its font size, verb and hearing radius by the phrase volume.
Describes a roll for the chat in short: the formula with the dice and the total, as Dice.format_compact writes it ('d20 (14) + 3 = 17'), and a note when the roll is a critical success or failure.
Reads a chat color from the config.
Returns how long the OOC mute of a player still lasts.
Splits a phrase into alternating speech and asterisk emote parts with quotes and colors.
Determines how loud a phrase is from its leading parentheses or trailing exclamation marks.
Tells what kind of in character speech a text is going to be once it is sent, the same way the server will read it: an action if the phrase starts with an asterisk, else a whisper or a yell if it has a volume, else regular speech.
Returns how far a phrase of a volume carries, compared to regular speech.
Checks whether a phrase has anything to say once its markup is taken away, so that an empty whisper or a lone asterisk does not become an empty chat line.
load()server
Loads the static texts from the plugin data.
save()server
Saves the static texts to the plugin data.
Sends a message to the LOOC chat, which is read by the players within the talk radius.
Sends a message to the OOC chat, which every player reads.
Mutes a player in the OOC and LOOC chats, or lifts their mute.
Wraps a text in the markup of a speech command, the way the command itself says it.

Hooks

RPCommands:ChatboxAdjustPlayerSay(actor, text, message_data)

server plugins/rpcommands/plugin/sv_hooks.lua:58

Implements hook ChatboxAdjustPlayerSay

Replaces regular chat messages with formatted in character speech and logs them. A phrase that the player may not say (see RPCommands:can_say_ic), or that has nothing in it but markup, is replaced with a message that nobody hears and that RPCommands:ChatboxShouldSendMessage cancels.

Parameters

  • actor Player player that sent the message
  • text String message text
  • message_data Table message data, replaced in place

RPCommands:ChatboxShouldSendMessage(message_data, _listeners)

server plugins/rpcommands/plugin/sv_hooks.lua:77

Implements hook ChatboxShouldSendMessage

Cancels the message that stands in for a phrase a player was not allowed to say.

Parameters

  • message_data Table chat message data
  • _listeners List<Player> players the message is meant for

Returns

  • Boolean false for a refused phrase, nil otherwise

RPCommands:DisplayTypingAdjustFadeoffMultiplier(_target, text)

client plugins/rpcommands/plugin/cl_hooks.lua:211

Implements hook DisplayTypingAdjustFadeoffMultiplier

Shrinks the typing indicator range for whispers and extends it for yells, by as much as the volume of the phrase changes its hearing radius.

Parameters

  • _target Player player that is typing
  • text String text being typed

Returns

  • Number multiplier of the squared range, nil for regular talking

RPCommands:DisplayTypingGetKind(target, text)

client plugins/rpcommands/plugin/cl_hooks.lua:175

Implements hook DisplayTypingGetKind

Gives the typing bubble of a player the kind of speech they are typing: its label, the color of the chat line it will become and the range that line will be heard from, which follows the volume of the phrase. A knocked out player gets no bubble for in character speech, which they cannot say.

Parameters

  • target Player player that is typing
  • text String text being typed, or its outline

Returns

  • Map/Boolean kind definition for the Display Typing plugin, false to show no bubble, nil for anything that is not in character speech

RPCommands:DisplayTypingTextType(_target, text)

client plugins/rpcommands/plugin/cl_hooks.lua:198

Implements hook DisplayTypingTextType

Returns the typing indicator text for emotes, whispers, yells and regular talking. Only asked when RPCommands:DisplayTypingGetKind has not decided the kind of speech.

Parameters

  • _target Player player that is typing
  • text String text being typed

Returns

  • String indicator text, nil for other commands

RPCommands:HUDPaint()

client plugins/rpcommands/plugin/cl_hooks.lua:40

Draws nearby visible static texts, fading with distance and screen position. Staff holding Alt also see who placed each text and when.

RPCommands:LoadData()

server plugins/rpcommands/plugin/sv_hooks.lua:111

Implements hook LoadData

Loads the static texts with the rest of the server data.

RPCommands:NotifySelf(receiver, notification_color, message)

server plugins/rpcommands/plugin/sv_hooks.lua:248

Sends a colored chat message to a single player. Nothing is sent for a player who is not valid, as the message would reach everyone instead.

Parameters

  • receiver Player player to send the message to
  • notification_color Color color of the message
  • message String message

RPCommands:OnConfigReceived(key, _old_value, _new_value)

client plugins/rpcommands/plugin/cl_hooks.lua:107

Implements hook OnConfigReceived

Keeps the colors of the registered kinds of speech in step with the chat colors, which arrive from the server after the kinds have been registered.

Parameters

  • key String config key
  • _old_value Any value the client had before
  • _new_value Any value that has been received

RPCommands:OnPlayerChat(speaker, _text, _team_chat, _is_dead)

client plugins/rpcommands/plugin/cl_hooks.lua:96

Keeps what players say through the engine out of the chat. What is typed into the chatbox reaches the server through the chatbox itself and comes back as a line of roleplay chat. Plain text sent with the say console command does not: the base gamemode would show it to every player on the server under the real name of the speaker, past the talk radius, recognition and the speaking rules. Chat prefixes and commands in such a text are handled by the server before it gets here, and the lines of the server console are added by the Chatbox plugin.

Parameters

  • speaker Player the speaker, an invalid entity for the server console
  • _text String the message
  • _team_chat Boolean whether the message was sent to the team chat
  • _is_dead Boolean whether the speaker is dead

Returns

  • Boolean true to hide what a player has said, nil for the server console

RPCommands:OnPluginsLoaded()

shared plugins/rpcommands/plugin/sh_plugin.lua:118

Implements hook OnPluginsLoaded

Registers the kinds of speech of the plugin with the Display Typing plugin, if it is loaded, on both realms: the server reads the range of a kind to decide who is sent the typing bubble, the client its label and color. Each kind is named by its 'ui.hud.display_typing' phrase and has the range of its default volume; RPCommands:DisplayTypingGetKind refines the color and the range for each text on the client.

RPCommands:PlayerCanHear(listener, message_data)

server plugins/rpcommands/plugin/sv_hooks.lua:87

Implements hook PlayerCanHear

Lets look-based messages be heard by players looking within the message radius of the sender.

Parameters

  • listener Player player that would hear the message
  • message_data Table chat message data

Returns

  • Boolean whether the listener hears a look-based message, nil for other messages

RPCommands:PlayerCanHearPlayersVoice(listener, talker)

server plugins/rpcommands/plugin/sv_hooks.lua:43

Limits voice chat to the talk radius.

Parameters

  • listener Player player that would hear the voice
  • talker Player player talking

Returns

  • Boolean false if the talker is out of range, nil otherwise

RPCommands:PlayerCanUseOOC(actor)

server plugins/rpcommands/plugin/sv_hooks.lua:104

Implements hook PlayerCanUseOOC

Prevents gagged players from using the OOC and LOOC chats.

Parameters

  • actor Player player trying to use OOC

Returns

  • Boolean false while the player is gagged, nil otherwise

RPCommands:PlayerInitialized(actor)

server plugins/rpcommands/plugin/sv_hooks.lua:132

Implements hook PlayerInitialized

Sends all static texts to a player once they have loaded in.

Parameters

  • actor Player player that has loaded in

RPCommands:RegisterPermissions()

shared plugins/rpcommands/plugin/sh_plugin.lua:36

Implements hook RegisterPermissions

Registers the permission that exempts a player from the OOC and LOOC cooldowns.

RPCommands:SaveData()

server plugins/rpcommands/plugin/sv_hooks.lua:116

Implements hook SaveData

Saves the static texts with the rest of the server data.

Functions

RPCommands.add_static_text(data)

server plugins/rpcommands/plugin/sv_hooks.lua:21

Adds a static text, saves it and sends it to all players.

Parameters

  • data Table static text with pos, text, name, steamid and time fields

RPCommands.remove_static_text(id)

server plugins/rpcommands/plugin/sv_hooks.lua:31

Removes a static text, saves the change and removes it for all players.

Parameters

  • id Number index of the static text

Methods

RPCommands:announce_roll(actor, result, opponent, opponent_result, label)

server plugins/rpcommands/plugin/sv_plugin.lua:294

Shows a roll in the chat to the players within the talk radius of the player who rolled, and to those who look at them from within it, and logs it. A versus roll shows the rolls of both players in one line, to the players near either of them.

local result = Dice.roll('2d6 + 1')

RPCommands:announce_roll(actor, result)
RPCommands:announce_roll(actor, actor:roll_skill('stealth'), nil, nil, 'Stealth')

Parameters

  • actor Player player who rolled
  • result Map result of Dice.roll for the player
  • opponent Player optional, defaults to nil the other player of a versus roll
  • opponent_result Map optional, defaults to nil result of Dice.roll for the opponent; the roll is shown as a plain roll without it
  • label String optional, defaults to nil text that names what was rolled, such as the name of a skill

See also

RPCommands:can_say_ic(actor, text)

server plugins/rpcommands/plugin/sv_plugin.lua:110

Checks whether a player may say a phrase in character: speech, whispers, yells and actions alike. The PlayerCanSayIC hook decides; when no handler does, players who are dead or knocked out are refused and told so, while players who have merely fallen over may speak.

Parameters

  • actor Player
  • text String the phrase, with its markup

Returns

  • Boolean

RPCommands:can_use_ooc(actor, kind, text)

server plugins/rpcommands/plugin/sv_plugin.lua:82

Checks whether a player may send a message to the OOC or LOOC chat right now: asks the PlayerCanUseOOC hook, then checks the cooldown. A muted player is told how long their mute still lasts.

Parameters

  • actor Player
  • kind String 'ooc' or 'looc'
  • text String the message

Returns

  • Boolean

RPCommands:check_ooc_cooldown(actor, kind)

server plugins/rpcommands/plugin/sv_plugin.lua:51

Checks the cooldown of the OOC or LOOC chat for a player and starts the next one if they may write. The cooldown is the 'ooc_interval' or the 'looc_interval' config; players with the 'bypass_chat_cooldown' permission have none. A player who has to wait is told for how long.

Parameters

  • actor Player
  • kind String 'ooc' or 'looc'

Returns

  • Boolean false if the player has to wait

RPCommands:format_message(speaker, text)

server plugins/rpcommands/plugin/sv_hooks.lua:207

Formats an in character message, scaling its font size, verb and hearing radius by the phrase volume.

Parameters

  • speaker Player player speaking
  • text String phrase

Returns

  • Table chat message parts ending with the message data

RPCommands:format_roll(result)

server plugins/rpcommands/plugin/sv_plugin.lua:266

Describes a roll for the chat in short: the formula with the dice and the total, as Dice.format_compact writes it ('d20 (14) + 3 = 17'), and a note when the roll is a critical success or failure.

Parameters

Returns

  • String

RPCommands:get_chat_color(key)

shared plugins/rpcommands/plugin/sh_plugin.lua:100

Reads a chat color from the config. A color that has arrived as a plain table is turned back into a Color.

Parameters

  • key String config key of the color

Returns

  • Color the color, or nil if the config does not hold one

RPCommands:get_ooc_mute_left(target)

server plugins/rpcommands/plugin/sv_plugin.lua:25

Returns how long the OOC mute of a player still lasts. The end of a mute is kept in the player data as a real time (os.time), so it carries over restarts and map changes.

Parameters

  • target Player

Returns

  • Number seconds left, 0 if the player is not muted

RPCommands:get_phrase_table(text)

server plugins/rpcommands/plugin/sv_hooks.lua:139

Splits a phrase into alternating speech and asterisk emote parts with quotes and colors.

Parameters

  • text String phrase

Returns

  • Table chat message parts

RPCommands:get_phrase_volume(text)

shared plugins/rpcommands/plugin/sh_plugin.lua:75

Determines how loud a phrase is from its leading parentheses or trailing exclamation marks.

Parameters

  • text String phrase

Returns

  • String phrase without the parentheses
  • Number volume from -3 to 3

RPCommands:get_typing_kind(text)

client plugins/rpcommands/plugin/cl_hooks.lua:129

Tells what kind of in character speech a text is going to be once it is sent, the same way the server will read it: an action if the phrase starts with an asterisk, else a whisper or a yell if it has a volume, else regular speech. The me, whisper and yell commands are recognized by their exact names and aliases, so that /w does not match /warn. Works on the outlines that the Display Typing plugin sends in place of a text as well, since they keep the command and the punctuation at both ends.

Parameters

  • text String the text being typed, or its outline

Returns

  • String 'talking', 'whispering', 'yelling' or 'performing'
  • Number volume of the phrase from -3 to 3; nothing for out of character chat, for radio messages, for other commands and for a text without a phrase

RPCommands:get_volume_range(volume)

shared plugins/rpcommands/plugin/sh_plugin.lua:68

Returns how far a phrase of a volume carries, compared to regular speech.

Parameters

Returns

  • Number multiplier of the talk radius: 1 for regular speech, 0.6 to 0.2 for whispers and 1.6 to 2.4 for yells

RPCommands:has_phrase_content(text)

server plugins/rpcommands/plugin/sv_plugin.lua:145

Checks whether a phrase has anything to say once its markup is taken away, so that an empty whisper or a lone asterisk does not become an empty chat line.

Parameters

  • text String the phrase

Returns

  • Boolean

Loads the static texts from the plugin data.

Saves the static texts to the plugin data.

RPCommands:say_looc(actor, text, team_chat)

server plugins/rpcommands/plugin/sv_plugin.lua:206

Sends a message to the LOOC chat, which is read by the players within the talk radius. The line never shows a Steam avatar: it is tied to a character that the readers can see, and the avatar would tell them who plays it. The GetPlayerOOCName hook can replace the name of the character on the line.

Parameters

  • actor Player the player who writes
  • text String the message
  • team_chat Boolean optional, defaults to nil whether the message was sent to the team chat

RPCommands:say_ooc(actor, text, team_chat)

server plugins/rpcommands/plugin/sv_plugin.lua:161

Sends a message to the OOC chat, which every player reads. The line shows the Steam name of the player, with their Steam avatar if the 'ooc_avatars' config is enabled. An invalid player stands for the server console, whose messages are neither muted nor held back.

Parameters

  • actor Player the player who writes, an invalid entity for the server console
  • text String the message
  • team_chat Boolean optional, defaults to nil whether the message was sent to the team chat

RPCommands:set_ooc_mute(target, duration)

server plugins/rpcommands/plugin/sv_plugin.lua:34

Mutes a player in the OOC and LOOC chats, or lifts their mute.

Parameters

  • target Player
  • duration Number optional, defaults to nil seconds the mute lasts from now; nil or 0 lifts the mute

RPCommands:wrap_speech(id, text)

shared plugins/rpcommands/plugin/sh_plugin.lua:54

Wraps a text in the markup of a speech command, the way the command itself says it.

RPCommands:wrap_speech('me', 'waves') -- '*waves*'
RPCommands:wrap_speech('whisper', 'over here') -- '(over here)'
RPCommands:wrap_speech('yell', 'run') -- 'run!!'

Parameters

  • id String ID of the command: 'me', 'whisper' or 'yell'
  • text String text given to the command

Returns

  • String the phrase to say, or the text as it is for any other command

Defined in