Defines the cw.voices library, voice lines that play a sound when a player says a set phrase in character.

Voice groups decide who may use their lines; one is registered per faction, and the RegisterVoiceGroups, RegisterVoices and AdjustVoices hooks add more. The library is registered as the Voices plugin module, through which it rewrites matching chat messages and plays the sound.

Summary

Methods

Called when chat box info should be adjusted; turns matching IC messages into voice lines.
Called when a chat box message has been sent; plays the voice line's sound.
Called when the framework initializes; registers a voice group per faction and collects voices.
Returns a voice group.
GetAll()shared
Returns every registered voice group.
Returns the voice lines of a group.
Registers a voice group.

Methods

cw.voices:Add(groupName, command, phrase, sound, female, menu, pitch, volume)

shared gamemodes/catwork/gamemode/core/libraries/sh_voices.lua:81

Adds a voice line to a group.

A player in the group who says command in IC chat plays sound and shows phrase instead. Prints an error if the group is not registered.

voices:Add('Human', 'Figures', 'Figures.', 'vo/npc/male01/answer03.wav', 'vo/npc/female01/answer03.wav')

Parameters

  • groupName String Name of the group
  • command String Text that triggers the line; matched case-insensitively
  • phrase String Text shown in chat; the message is hidden when empty or nil
  • sound String Sound file path
  • female Any optional, defaults to nil When set in a gender group, female characters play sound with /male replaced by /female
  • menu Any optional, defaults to nil Stored with the line, unused by Catwork
  • pitch Number optional, defaults to nil Sound pitch
  • volume Number optional, defaults to nil Sound level; 80 when nil

cw.voices:ChatboxAdjustMessageInfo(info)

shared gamemodes/catwork/gamemode/core/libraries/sh_voices.lua:146

Called when chat box info should be adjusted; turns matching IC messages into voice lines.

When the message matches a voice line of a group the sender belongs to and the sender's voice cooldown has passed (admins skip it), sets info.voice, replaces the text with the line's phrase (or hides the message) and starts the voice_cooldown.

Parameters

  • info Map The chat message info, with filter, sender, text and data keys

Returns

  • Boolean true when the message became a voice line

cw.voices:ChatboxMessageSent(info)

shared gamemodes/catwork/gamemode/core/libraries/sh_voices.lua:210

Called when a chat box message has been sent; plays the voice line's sound.

The sender emits the sound. For global lines and radio messages, every listener except the sender also hears it.

Parameters

  • info Map The chat message info, with voice, sender, listeners and data keys

cw.voices:ClockworkInitialized()

shared gamemodes/catwork/gamemode/core/libraries/sh_voices.lua:108

Called when the framework initializes; registers a voice group per faction and collects voices.

Each faction gets a group its members can use. Then runs the RegisterVoiceGroups, RegisterVoices and AdjustVoices hooks (via hook.Run), and on the client adds each group's lines to the directory.

Returns a voice group.

Parameters

  • id String Name of the group

Returns

  • Map The group, or nil if it is not registered

Returns every registered voice group.

Returns

  • Map<Map> Voice groups keyed by name, each with bGender, IsPlayerMember and voices keys

Returns the voice lines of a group.

Errors if the group is not registered.

Parameters

  • id String Name of the group

Returns

  • Map<Map> Voice lines keyed by their lowercased command

cw.voices:RegisterGroup(group, bGender, callback)

shared gamemodes/catwork/gamemode/core/libraries/sh_voices.lua:51

Registers a voice group.

Does nothing if the group already exists.

voices:RegisterGroup('Combine', false, function(player)
  return player:IsCombine()
end)

Parameters

  • group String Name of the group
  • bGender Boolean optional, defaults to false Whether female characters get the female version of each sound
  • callback Function Called as callback(player); returns whether the player can use the group's voices

Defined in