Sends notifications and sounds from the server to the players. Flux.Player:notify notifies one player and Flux.Player:broadcast notifies everyone. The message can be a language phrase with arguments; it is translated on the client of each recipient and displayed there with Flux.Notification. Player:notify is the shorter way to notify a single player.

Flux.Player:play_sound plays a sound once on the clients of the given players, and Flux.Player:start_sound and Flux.Player:stop_sound control named looping sounds there, such as an ambience or an alarm that only some players should hear. Player has methods of the same names for a single player.

Summary

Methods

Sends a notification to every player and writes it to the server log.
Sends a notification to a player.
Plays a sound once on the clients of the given players.
Starts a named looping sound on the clients of the given players.
Stops a named sound on the clients of the given players.

Methods

Flux.Player:broadcast(message, arguments)

server packages/flow/lib/sv_player.lua:38

Sends a notification to every player and writes it to the server log.

Parameters

  • message String text or language phrase
  • arguments Map optional, defaults to nil values to substitute into the phrase

Flux.Player:notify(target, message, arguments, color)

server packages/flow/lib/sv_player.lua:26

Sends a notification to a player. If the player is not valid (e.g. the server console) the message is written to the server log instead.

Parameters

  • target Player
  • message String text or language phrase
  • arguments Map optional, defaults to nil values to substitute into the phrase
  • color Color optional, defaults to nil

Flux.Player:play_sound(target, path)

server packages/flow/lib/sv_player.lua:51

Plays a sound once on the clients of the given players. The sound has no position in the world and is heard at full volume, like an interface sound.

Flux.Player:play_sound(target, 'buttons/button15.wav')

Parameters

  • target Player/List<Player> who hears the sound; everyone if nil
  • path String path of the sound file, relative to the sound/ folder

Flux.Player:start_sound(target, id, path, volume)

server packages/flow/lib/sv_player.lua:69

Starts a named looping sound on the clients of the given players. The sound keeps playing until it is stopped with Flux.Player:stop_sound under the same name. Starting another sound under a name that is in use replaces the old one, and starting the same sound again does nothing. Whether the sound loops is up to the sound file: a file without loop points plays once.

Flux.Player:start_sound(target, 'heartbeat', 'player/heartbeat1.wav', 0.5)

Parameters

  • target Player/List<Player> who hears the sound; everyone if nil
  • id String name to stop the sound by
  • path String path of the sound file, relative to the sound/ folder
  • volume Number optional, defaults to 0.75 volume from 0 to 1

Flux.Player:stop_sound(target, id, fade_out)

server packages/flow/lib/sv_player.lua:83

Stops a named sound on the clients of the given players. Does nothing for players who do not have a sound under that name.

Flux.Player:stop_sound(target, 'heartbeat', 2)

Parameters

  • target Player/List<Player> whose sound stops; everyone if nil
  • id String name the sound was started under
  • fade_out Number optional, defaults to 0 seconds over which the sound fades out; 0 cuts it off

Defined in