Shared Flashlight replaces the engine flashlight, which only the player who holds it can see, with an fl_flashlight entity. The entity is created on the server, parented to the player and sent to every client, and each client draws a projected light from the eyes of the owner, so the server, the owner and everyone around them agree on whether a flashlight is on and where it shines.

The flashlight key still toggles it: the PlayerSwitchedFlashlight hook turns the light on or off through Player:set_flashlight and keeps the engine flashlight from toggling. The state is read with Player:is_flashlight_on on both realms, and the entity of a lit flashlight with Player:get_flashlight. The light goes out when the player dies, spawns and leaves the server. The PlayerFlashlightChanged hook runs on the server after every change.

The shared_flashlight_enabled config switches the plugin off, which leaves the engine flashlight alone; flashlight_fov, flashlight_distance, flashlight_brightness and flashlight_shadows shape the light on every client.

Summary

Hooks

Puts every shared flashlight out when the shared_flashlight_enabled config is turned off, so that nobody keeps a light the engine flashlight has taken over from.
Puts the flashlight of a player out when they die.
Removes the light of a player who leaves the server, so that it never outlives them.
Makes sure that a player spawns with their flashlight off.
Toggles the player's shared flashlight and keeps the engine flashlight from toggling.

Methods

Tells whether the plugin stands in for the engine flashlight.

Hooks

SharedFlashlight:OnConfigSet(key, _old_value, new_value)

server plugins/shared_flashlight/plugin/sv_hooks.lua:67

Implements hook OnConfigSet

Puts every shared flashlight out when the shared_flashlight_enabled config is turned off, so that nobody keeps a light the engine flashlight has taken over from.

Parameters

  • key String key of the config that has changed
  • _old_value Any
  • new_value Any

SharedFlashlight:PlayerDeath(victim, _inflictor, _attacker)

server plugins/shared_flashlight/plugin/sv_hooks.lua:35

Puts the flashlight of a player out when they die.

Parameters

  • victim Player
  • _inflictor Entity
  • _attacker Entity

SharedFlashlight:PlayerDisconnected(actor)

server plugins/shared_flashlight/plugin/sv_hooks.lua:52

Implements hook PlayerDisconnected

Removes the light of a player who leaves the server, so that it never outlives them.

Parameters

  • actor Player

SharedFlashlight:PlayerSpawn(actor)

server plugins/shared_flashlight/plugin/sv_hooks.lua:44

Makes sure that a player spawns with their flashlight off. A silent kill, which Flux uses when a player goes back to the main menu or changes character, does not run PlayerDeath, so a light that was on at that time would otherwise stay on through the spawn; the engine flashlight is put out as well, in case the engine has kept it from a previous life.

Parameters

  • actor Player

SharedFlashlight:PlayerSwitchedFlashlight(actor, _on)

server plugins/shared_flashlight/plugin/sv_hooks.lua:14

Implements hook PlayerSwitchedFlashlight

Toggles the player's shared flashlight and keeps the engine flashlight from toggling. The engine always asks to turn its flashlight on, since it never gets to turn on, so the player's current state decides which way the toggle goes. The light is only turned on for a living player whom Player:CanUseFlashlight allows it, the way the base gamemode decides for the engine flashlight, and a player toggles it at most five times a second. Does nothing while the shared_flashlight_enabled config is off, which leaves the decision to the base gamemode.

Parameters

  • actor Player
  • _on Boolean whether the engine flashlight is being turned on

Returns

  • Boolean false while the plugin is enabled, nil otherwise

Methods

SharedFlashlight:is_enabled()

shared plugins/shared_flashlight/plugin/sh_plugin.lua:27

Tells whether the plugin stands in for the engine flashlight.

Returns

  • Boolean value of the shared_flashlight_enabled config

Defined in