Hooks called by Flow

Summary

Hooks

Called on the server when the client of a player reports that it has included the schema files.
Called for every player a command with immunity set is about to be run on, when the command was not run from the server console.
Called on the client when the local player presses the use key on an entity that is not a player, to fill the interaction menu.
Called on the client when the local player presses the use key on another player, to fill the interaction menu.
Called on the client every frame to draw the target ID of the entity that the local player is looking at, or has closest to the crosshair, when DrawPlayerTargetID does not apply to it and it has no DrawTargetID method of its own.
Called on the client every frame to draw the target ID of the player that the local player is looking at, or has closest to the crosshair.
Called after an entity has been frozen with Entity:freeze, on the realm that function was called on (it is meant for the server).
Called after an entity has been unfrozen with Entity:unfreeze, on the realm that function was called on (it is meant for the server).
Lets plugins set the damage a player takes from a fall.
Called on the client every frame while the local player is alive and the HUD is shown, for drawing HUD elements.
Called at the end of the gamemode's Initialize handler, on both realms.
Called at the end of the gamemode's InitPostEntity handler, right after LoadData, on both realms.
Called on the server when a player tries to give themselves a weapon from the spawn menu, after the gamemode has checked that they have the spawn_sweps permission.
Called on the server from the gamemode's PlayerShouldTakeDamage handler, when a player is about to take damage from an attacker.
Called on the server when a player tries to spawn an effect, after the gamemode has checked that they have the spawn_entities permission.
Called on the server when a player tries to spawn an NPC, after the gamemode has checked that they have the spawn_npcs permission.
Called on the server when a player tries to spawn a prop, a ragdoll or an effect, after the gamemode has checked that they have the spawn_entities permission.
Called on the server when a player tries to spawn a prop, after the gamemode has checked that they have the spawn_props permission.
Called on the server when a player tries to spawn a ragdoll, after the gamemode has checked that they have the spawn_ragdolls permission.
Called on the server when a player tries to spawn a scripted entity, after the gamemode has checked that they have the spawn_entities permission.
Called on the server when a player tries to spawn a weapon, after the gamemode has checked that they have the spawn_sweps permission.
Called on the server when a player tries to spawn a vehicle, after the gamemode has checked that they have the spawn_vehicles permission.
Called on the server when all persistent data has to be saved: every data_save_interval seconds unless FLShouldSaveData returns false, when the server shuts down or changes the map, and by the restart command of the admin plugin.
Asks whether the periodic data save may happen now.
Called on the client shortly after the schema files have been included, right after the server has been told about it (which runs ClientIncludedSchema there).
Called on the server while the files that get sent to the clients are written, on FluxPackageLoaded and after a Lua refresh, once the shared data, the settings and the language phrases have been written.
Collects the lines of text shown in the target ID of a player.
Lets plugins give a display name to an entity that is not a player.
Lets plugins replace the status text and the progress shown on the loading screen.
Lets plugins replace the name a player is shown under, for example with the name of their character.
Called twice a second on both realms.
Called on the client every frame while the local player is dead, before the theme paints the death screen, for drawing behind it.
Called on the client every frame while the local player is dead, after the theme has painted the death screen, for drawing on top of it.
Called on the client when the language that t translates to has changed, because the player picked another one with Flux.Lang:set_language or changed the language of the game.
Called eight times a second on both realms.
Called once the map's entities have been created, for plugins to load their saved data.
Called on the client when a log entry sent with Log:replicate arrives, before it is output.
Asks whether a player should use the raised weapon animations of their model.
Called on the server and the client after a command has been registered with Flux.Command:create.
Called once a minute on both realms.
Called once a second on both realms.
Called on the client when the screen resolution has changed.
Sandbox's PersistenceSave hook, which saves the persistent entities.
Asks whether a player who lacks the physgun_freeze permission may freeze an entity with the physics gun all the same, for instance because they own it.
Asks whether a player who lacks the physgun_pickup permission may pick an entity up with the physics gun all the same, for instance because they own it.
Called on the server when a player is about to run a command, after the permission check has passed and before the arguments are checked.
Asks whether a player may start a timed action.
Called on the server when a player joins for the first time, after their new database record has been given the SteamID, the name and the user role and right before it is saved.
GMod's PlayerDisconnected hook, which the game only runs on the server.
Called on both realms when a player tries to enter noclip.
Called on both realms when a player tries to leave noclip.
Decides whether a player has a permission.
Called on the server when the client of a player has finished loading and reports that its local player exists, right after the config, the networked variables and the list of disabled plugins have been sent to it.
GMod's PlayerInitialSpawn hook, which the game only runs on the server.
Decides whether a player has root access, that is can do anything.
Called on the server when the client of a player has reported a new language: the one the player picked with Flux.Lang:set_language, or else the language of their game.
Called on the server once a spawning player holds the default loadout, after the gamemode has stripped their weapons and given the default ones.
Called when the model of a player changes, right before the new model is applied.
Called once a minute for every player, on both realms.
Called on the server once a second for every player, right after that player's PlayerThink.
Called on the server when a player is not where they were a second ago.
Called on the server once the database record of a player who has just joined is available as actor.record.
Called on the server right before a command is logged and run, after all of the checks have passed and its targets have been found.
GMod's PlayerSetModel hook, run by Flux on the server every time a player spawns, before the rest of their state is reset.
Called on the server and the client when the data tables of a player are set up, right after Flux has added its own Initialized variable.
Called on the server when a player toggles their flashlight, before the engine does it.
Called on the server whenever a player takes damage, from the gamemode's EntityTakeDamage handler.
Called on the server eight times a second for every player, including players who are dead or not initialized yet.
Called when a timed action of a player has ended, after the callback of the action.
Called when a timed action of a player has started.
Called on the client once the server has initialized the local player, right before the spawn menu is rebuilt with the spawnmenu_reload console command.
Sandbox's PopulateToolMenu hook, run once more by Flux on the client when the server has initialized the local player, after the spawn menu reload has been requested.
Called on the client every frame right after the loading screen has been drawn, for drawing on top of it.
Called on the server when a player gets their loadout after spawning.
Called on the server every time a player spawns, after their model, collisions, visibility and movement speeds have been reset and before their hands model is created.
Called on the server after a data save, when the config has been saved and every SaveData handler has run.
Called on the server after Player:save_player has saved the database record of a player.
Called on the client after the target ID lines of a player have been collected with GetDrawPlayerInfo and before they are drawn.
Called on the server and the client when a tool file is about to be included.
Lets plugins choose the model a player gets when the gamemode sets it, which happens on the server every time the player spawns.
Called on the server before Player:save_player saves the database record of a player.
Called on the server for plugins to save their persistent data, from the gamemode's FLSaveData handler after the config has been saved.
Asks whether the loading screen should stay up.
Asks whether the HUD should be drawn.
Asks whether the empty server may reload the current map.
Called on the client when the local player presses the undo key (a bind containing gmod_undo).
Called on the client when the tool gun has to learn about the Flux tools: once the map's entities have been created, and again whenever the tool menu has been populated.
Lets plugins add target selectors for the player argument of commands.
Called on the server and the client after a tool file has been included, right before the console variables of the tool are created with Tool:CreateConVars.

Hooks

ClientIncludedSchema(actor)

server packages/flow/hooks/sv_nethooks.lua:9

Called on the server when the client of a player reports that it has included the schema files. FluxClientSchemaLoaded is its client-side counterpart.

Parameters

  • actor Player The player whose client has loaded the schema

Call sites

CommandCheckImmunity(actor, target, cmd.can_equal)

server packages/flow/lib/sh_command.lua:908

Called for every player a command with immunity set is about to be run on, when the command was not run from the server console. The actor themselves can be among the targets; the admin plugin's handler always lets that pass, and lets root players target anyone.

Parameters

  • actor Player Player who runs the command
  • target Player Player the command targets
  • can_equal Boolean The command's can_equal setting: whether a target of the same standing as the actor may be affected

Returns

  • Boolean Return false if the target is immune to the actor; the command is then not run and the actor is notified

Called from

  • find_targets

Call sites

CreateEntityInteractions(interaction_menu, entity)

client packages/flow/hooks/cl_nethooks.lua:102

Called on the client when the local player presses the use key on an entity that is not a player, to fill the interaction menu. The menu opens in the middle of the screen if a handler has added anything to it and is removed otherwise. The server triggers this at most once a second for each player.

Parameters

  • menu Panel The DermaMenu to add options to
  • entity Entity The entity being used

Call sites

CreatePlayerInteractions(interaction_menu, target)

client packages/flow/hooks/cl_nethooks.lua:83

Called on the client when the local player presses the use key on another player, to fill the interaction menu. The menu opens in the middle of the screen if a handler has added anything to it and is removed otherwise. The server triggers this at most once a second for each player.

Parameters

  • menu Panel The DermaMenu to add options to
  • target Player The player being used

Call sites

DrawEntityTargetID(ent, x, y, dist)

client packages/flow/hooks/cl_hooks.lua:346

Called on the client every frame to draw the target ID of the entity that the local player is looking at, or has closest to the crosshair, when DrawPlayerTargetID does not apply to it and it has no DrawTargetID method of its own. Nothing is drawn unless a handler does it.

Parameters

  • entity Entity The entity being looked at
  • x Number Screen x of the point above the entity to center the text on
  • y Number Screen y of that point
  • distance Number Distance from the camera to the entity in units

Called from

Call sites

DrawPlayerTargetID(ent, x, y, dist)

client packages/flow/hooks/cl_hooks.lua:334

Called on the client every frame to draw the target ID of the player that the local player is looking at, or has closest to the crosshair. Only happens while the local player is alive and for targets that are alive, initialized and not obstructed. The gamemode's handler draws the lines collected with GetDrawPlayerInfo.

Parameters

  • target Player The player being looked at
  • x Number Screen x of the point above the target to center the text on
  • y Number Screen y of that point
  • distance Number Distance from the camera to the target's eyes in units

Called from

Call sites

EntityFreeze(self)

shared packages/flow/lib/meta/sh_entity.lua:153

Called after an entity has been frozen with Entity:freeze, on the realm that function was called on (it is meant for the server).

Parameters

  • entity Entity The entity that has been frozen; can be a player

Called from

Call sites

EntityUnfreeze(self)

shared packages/flow/lib/meta/sh_entity.lua:172

Called after an entity has been unfrozen with Entity:unfreeze, on the realm that function was called on (it is meant for the server).

Parameters

  • entity Entity The entity that has been unfrozen; can be a player

Called from

Call sites

FLGetFallDamage(actor, speed)

server packages/flow/hooks/sv_hooks.lua:252

Lets plugins set the damage a player takes from a fall. Called on the server from the gamemode's GetFallDamage handler.

Parameters

  • actor Player The player who has hit the ground
  • speed Number Speed at which the player hit the ground

Returns

  • Number Damage to deal; when nothing or false is returned, the damage is calculated from the speed

Called from

Call sites

FLHUDPaint(cur_time, scrw, scrh)

client packages/flow/hooks/cl_hooks.lua:231

Called on the client every frame while the local player is alive and the HUD is shown, for drawing HUD elements. Runs after the damage flash and before the info displays (InfoDisplay) and the top bars (Flux.Bars) are drawn. The gamemode's handler draws the circular action indicator.

Parameters

  • cur_time Number CurTime() of the frame
  • scrw Number Screen width
  • scrh Number Screen height

Returns

  • Boolean Return true to keep the info displays and the top bars from being drawn

Called from

Call sites

FLInitialize()

shared packages/flow/hooks/sh_hooks.lua:62

Called at the end of the gamemode's Initialize handler, on both realms. On the server the config has been loaded, the connection to the database has been started and the Discord webhooks from the settings have been registered by then.

Called from

Call sites

FLInitPostEntity()

shared packages/flow/hooks/sv_hooks.lua:50

Called at the end of the gamemode's InitPostEntity handler, right after LoadData, on both realms. The Flux tools have been registered with the tool gun by then, and on the client the PLAYER global has been set. Gamemode (GM) handlers are not called.

Called from

Call sites

FLPlayerGiveSWEP(actor, weapon, swep)

server packages/flow/hooks/sv_hooks.lua:508

Called on the server when a player tries to give themselves a weapon from the spawn menu, after the gamemode has checked that they have the spawn_sweps permission.

Parameters

  • actor Player The player taking the weapon
  • weapon String Class of the weapon
  • swep Map Information about the weapon from the weapon list

Returns

  • Boolean Return false to prevent the weapon from being given

Called from

Call sites

FLPlayerShouldTakeDamage(victim, attacker)

server packages/flow/hooks/sv_hooks.lua:275

Called on the server from the gamemode's PlayerShouldTakeDamage handler, when a player is about to take damage from an attacker.

Parameters

  • victim Player The player about to take damage
  • attacker Entity The entity dealing the damage

Returns

  • Boolean Return false to prevent the damage. The player takes the damage when anything else or nothing is returned

Called from

Call sites

FLPlayerSpawnEffect(actor, model)

server packages/flow/hooks/sv_hooks.lua:375

Called on the server when a player tries to spawn an effect, after the gamemode has checked that they have the spawn_entities permission.

Parameters

  • actor Player The player spawning the effect
  • model String Model of the effect

Returns

  • Boolean Return false to prevent the effect from being spawned

Called from

Call sites

FLPlayerSpawnNPC(actor, npc, weapon)

server packages/flow/hooks/sv_hooks.lua:350

Called on the server when a player tries to spawn an NPC, after the gamemode has checked that they have the spawn_npcs permission.

Parameters

  • actor Player The player spawning the NPC
  • npc String Type of the NPC
  • weapon String Class of the weapon given to the NPC

Returns

  • Boolean Return false to prevent the NPC from being spawned

Called from

Call sites

FLPlayerSpawnObject(actor, model, skin)

server packages/flow/hooks/sv_hooks.lua:323

Called on the server when a player tries to spawn a prop, a ragdoll or an effect, after the gamemode has checked that they have the spawn_entities permission.

Parameters

  • actor Player The player spawning the object
  • model String Model of the object
  • skin Number Skin of the object

Returns

  • Boolean Return false to prevent the object from being spawned

Called from

Call sites

FLPlayerSpawnProp(actor, model)

server packages/flow/hooks/sv_hooks.lua:296

Called on the server when a player tries to spawn a prop, after the gamemode has checked that they have the spawn_props permission.

Parameters

  • actor Player The player spawning the prop
  • model String Model of the prop

Returns

  • Boolean Return false to prevent the prop from being spawned

Called from

Call sites

FLPlayerSpawnRagdoll(actor, model)

server packages/flow/hooks/sv_hooks.lua:481

Called on the server when a player tries to spawn a ragdoll, after the gamemode has checked that they have the spawn_ragdolls permission.

Parameters

  • actor Player The player spawning the ragdoll
  • model String Model of the ragdoll

Returns

  • Boolean Return false to prevent the ragdoll from being spawned

Called from

Call sites

FLPlayerSpawnSENT(actor, class)

server packages/flow/hooks/sv_hooks.lua:456

Called on the server when a player tries to spawn a scripted entity, after the gamemode has checked that they have the spawn_entities permission.

Parameters

  • actor Player The player spawning the entity
  • class String Class of the entity

Returns

  • Boolean Return false to prevent the entity from being spawned

Called from

Call sites

FLPlayerSpawnSWEP(actor, weapon, swep)

server packages/flow/hooks/sv_hooks.lua:431

Called on the server when a player tries to spawn a weapon, after the gamemode has checked that they have the spawn_sweps permission.

Parameters

  • actor Player The player spawning the weapon
  • weapon String Class of the weapon
  • swep Map Information about the weapon from the weapon list

Returns

  • Boolean Return false to prevent the weapon from being spawned

Called from

Call sites

FLPlayerSpawnVehicle(actor, model, name, tab)

server packages/flow/hooks/sv_hooks.lua:404

Called on the server when a player tries to spawn a vehicle, after the gamemode has checked that they have the spawn_vehicles permission.

Parameters

  • actor Player The player spawning the vehicle
  • model String Model of the vehicle
  • name String Name of the vehicle in the vehicle list
  • tab Map Vehicle table from the vehicle list

Returns

  • Boolean Return false to prevent the vehicle from being spawned

Called from

Call sites

Called on the server when all persistent data has to be saved: every data_save_interval seconds unless FLShouldSaveData returns false, when the server shuts down or changes the map, and by the restart command of the admin plugin. The gamemode's handler saves the config and runs SaveData, which is the hook that plugins normally implement, followed by PostSaveData.

Called from

Call sites

FLShouldSaveData()

server packages/flow/hooks/sv_hooks.lua:573

Asks whether the periodic data save may happen now. Called on the server every data_save_interval seconds (360 unless configured), for the first time about ten seconds after the server has started.

Returns

  • Boolean Return false to skip this save

Called from

Call sites

FluxClientSchemaLoaded()

client packages/flow/core/sh_core.lua:111

Called on the client shortly after the schema files have been included, right after the server has been told about it (which runs ClientIncludedSchema there). The gamemode's handler creates the fonts.

Call sites

FLWriteClientFiles()

server packages/flow/hooks/sv_hooks.lua:667

Called on the server while the files that get sent to the clients are written, on FluxPackageLoaded and after a Lua refresh, once the shared data, the settings and the language phrases have been written. Packages and plugins that generate clientside code of their own, such as the compiled templates of Lumen, write it here with Flux.write_client_file.

Called from

  • write_client_files

Call sites

GetDrawPlayerInfo(target, x, y, distance, lines)

client packages/flow/hooks/cl_hooks.lua:391

Collects the lines of text shown in the target ID of a player. Called on the client every frame the gamemode draws a player's target ID. Handlers add their entries to lines and should not return anything, so that the other handlers run too; the gamemode's handler adds the name line.

Parameters

  • target Player The player being looked at
  • x Number Screen x of the target ID
  • y Number Screen y of the target ID
  • distance Number Distance to the player in units
  • lines Map Lines to draw by ID. Each one is a table with the text and priority fields (lines with a lower priority are drawn first) and optionally color (white by default), font, offset_x and offset_y

Called from

Call sites

GetEntityName(self)

shared packages/flow/lib/meta/sh_entity.lua:112

Lets plugins give a display name to an entity that is not a player. Called on both realms by Entity:get_name, and on the client for entities passed as arguments of a notification.

Parameters

  • entity Entity The entity whose name is requested

Returns

  • String Name to show; when nothing is returned, the string representation of the entity is used

Called from

Call sites

GetLoadingScreenMessage()

client packages/flow/hooks/cl_hooks.lua:142

Lets plugins replace the status text and the progress shown on the loading screen. Called on the client every frame while the loading screen is drawn. Gamemode (GM) handlers are not called.

Returns

  • String Text to show instead of the default status
  • Number Progress of the bar from 0 to 100; optional and only used along with a text

Called from

Call sites

GetPlayerName(self)

shared packages/flow/lib/meta/sh_player.lua:55

Lets plugins replace the name a player is shown under, for example with the name of their character. Called on both realms whenever the name of a player is requested with Player:Name (unless the true name is forced) or Entity:get_name, and on the client for players passed as arguments of a notification. Inside a handler, use target:name(true) to get the unmodified name: target:name() would run the hook again.

Parameters

  • target Player The player whose name is requested

Returns

  • String Name to show; when nothing is returned, the player's name networked variable or else their Steam name is used

Called from

Call sites

Called twice a second on both realms.

Call sites

HUDPaintDeathBackground(cur_time, scrw, scrh)

client packages/flow/hooks/cl_hooks.lua:205

Called on the client every frame while the local player is dead, before the theme paints the death screen, for drawing behind it. The gamemode's handler draws a red blood overlay.

Parameters

  • cur_time Number CurTime() of the frame
  • scrw Number Screen width
  • scrh Number Screen height

Called from

Call sites

HUDPaintDeathForeground(cur_time, scrw, scrh)

client packages/flow/hooks/cl_hooks.lua:212

Called on the client every frame while the local player is dead, after the theme has painted the death screen, for drawing on top of it.

Parameters

  • cur_time Number CurTime() of the frame
  • scrw Number Screen width
  • scrh Number Screen height

Called from

Call sites

LanguageChanged(new_lang, old_lang)

client packages/flow/lib/sh_lang.lua:452

Called on the client when the language that t translates to has changed, because the player picked another one with Flux.Lang:set_language or changed the language of the game. Interface elements that keep translated text can rebuild it here.

Parameters

  • new_lang String New language code
  • old_lang String Previous language code

Called from

  • apply_language

Call sites

Called eight times a second on both realms. A cheaper alternative to Tick and Think for work that has to happen often, but not on every tick or frame.

Call sites

Called once the map's entities have been created, for plugins to load their saved data. Runs on both realms, from the server-side and from the client-side InitPostEntity handler of the gamemode. The counterpart of SaveData, which only runs on the server.

Called from

Call sites

LogReplicate(message, action, object, subject, data)

client packages/flow/models/log.lua:182

Called on the client when a log entry sent with Log:replicate arrives, before it is output. Gamemode (GM) handlers are not called.

Parameters

  • message String Text of the entry
  • action String Type of the logged event in snake_case; empty if there is none
  • object String/Number Who or what performed the action
  • subject String/Number Who or what the action was performed on
  • data Map How the server has output the entry: type is 'print', 'colored' or 'write' (an entry without output), and color is the console color of a colored entry

Returns

  • Any Return any non-nil value to prevent the default output of the entry

Call sites

ModelWeaponRaised(actor, actor.fl_anim_model)

shared packages/flow/hooks/sh_hooks.lua:269

Asks whether a player should use the raised weapon animations of their model. Called on both realms whenever the gamemode translates a movement activity of a player who is on the ground and whose model has a Flux animation table. Gamemode (GM) handlers are not called.

Parameters

  • actor Player The player being animated
  • model String Path of the model the player's animation table belongs to

Returns

  • Boolean Return true to use the raised animations; the lowered ones are used when nothing or false is returned

Called from

Call sites

OnCommandCreated(id, data)

shared packages/flow/lib/sh_command.lua:170

Called on the server and the client after a command has been registered with Flux.Command:create.

Parameters

  • id String command ID
  • data Command the command, with the defaults filled in; its subcommands are in Command:get_subcommands

Called from

Call sites

Called once a minute on both realms.

Call sites

Called once a second on both realms. On the server the gamemode's handler uses it to trigger the periodic data save (FLSaveData) and the restart of an empty server.

Call sites

OnResolutionChanged(new_w, new_h, scrw, scrh)

client packages/flow/hooks/cl_hooks.lua:99

Called on the client when the screen resolution has changed. The gamemode checks the resolution once a second; Active UI recreates the fonts from this hook.

Parameters

  • new_w Number New screen width
  • new_h Number New screen height
  • old_w Number Previous screen width
  • old_h Number Previous screen height

Called from

Call sites

PersistenceSave()

server packages/flow/hooks/sh_hooks.lua:518

Sandbox's PersistenceSave hook, which saves the persistent entities. Flux runs it on demand from the fl_save_pers console command, on the server and in development only.

Call sites

PlayerCanPhysgunFreeze(actor, entity)

server packages/flow/hooks/sv_hooks.lua:530

Asks whether a player who lacks the physgun_freeze permission may freeze an entity with the physics gun all the same, for instance because they own it. Called on the server after every OnPhysgunFreeze handler has had the chance to refuse.

Parameters

  • actor Player The player holding the physics gun
  • entity Entity The entity being frozen

Returns

  • Boolean Return true to allow the freeze

Called from

Call sites

PlayerCanPhysgunPickup(actor, entity)

shared packages/flow/hooks/sh_hooks.lua:508

Asks whether a player who lacks the physgun_pickup permission may pick an entity up with the physics gun all the same, for instance because they own it. Called on both the server and the client after every PhysgunPickup handler has had the chance to refuse.

Parameters

  • actor Player The player holding the physics gun
  • entity Entity The entity being picked up

Returns

  • Boolean Return true to allow the pickup

Called from

Call sites

PlayerCanRunCommand(actor, cmd_table, from_console)

server packages/flow/lib/sh_command.lua:1011

Called on the server when a player is about to run a command, after the permission check has passed and before the arguments are checked. The player is not told when a handler stops the command, so the handler should notify them.

Parameters

  • actor Player the player who runs the command, an invalid entity for the server console
  • cmd_table Command the command that runs; for a subcommand this is the subcommand, and its parent is the command it belongs to
  • from_console Boolean true if it was run as a console command, nil if it was typed in the chat

Returns

  • Any Return any non-nil value, even true, to stop the command from running

Called from

Call sites

PlayerCanStartTimedAction(actor, id, duration, options)

server packages/flow/lib/sh_timed_action.lua:213

Asks whether a player may start a timed action. Called on the server by Flux.TimedAction:start once the action is known to be valid and the player to be free (or the start to be forced), before anything is changed.

Parameters

  • actor Player The player about to start the action
  • id String Action ID
  • duration Number Seconds the action takes
  • options Map The options given to Flux.TimedAction:start

Returns

  • Boolean Return false to keep the action from starting

Called from

Call sites

PlayerCreated(self, obj)

server packages/flow/lib/meta/sv_player.lua:215

Called on the server when a player joins for the first time, after their new database record has been given the SteamID, the name and the user role and right before it is saved. Handlers can set further defaults on the record. PlayerRestored follows.

Parameters

  • actor Player The player who has joined
  • record User The new database record of the player

Call sites

PlayerDisconnected(Entity(ply_index))

client packages/flow/hooks/cl_nethooks.lua:29

GMod's PlayerDisconnected hook, which the game only runs on the server. Flux runs it on every client as well when the server announces that a player has left.

Parameters

  • actor Player The player who is leaving. The entity is not valid if the client has already lost it

Call sites

PlayerEnterNoclip(actor)

shared packages/flow/hooks/sh_hooks.lua:478

Called on both realms when a player tries to enter noclip. Gamemode (GM) handlers are not called. A handler that returns false may put the player into a noclip mode of its own, which is how the observer plugin works.

Parameters

  • actor Player The player entering noclip

Returns

  • Boolean Return false to prevent it or true to allow it; when nothing is returned, it is allowed to players with the 'noclip' permission

Called from

Call sites

PlayerExitNoclip(actor)

shared packages/flow/hooks/sh_hooks.lua:466

Called on both realms when a player tries to leave noclip. Gamemode (GM) handlers are not called.

Parameters

  • actor Player The player leaving noclip

Returns

  • Boolean Return false to prevent it or true to allow it; it is allowed when nothing is returned

Called from

Call sites

PlayerHasPermission(self, action, object)

shared packages/flow/lib/meta/sh_player.lua:351

Decides whether a player has a permission. Called on both realms by Player:can, which returns whatever the hook returns. Flux has no handler of its own: an admin plugin is expected to implement it.

Parameters

  • actor Player The player being checked
  • action String Permission ID, such as 'spawn_props'
  • object Any Object the permission is checked against; nil if none was given

Returns

  • Boolean Whether the player has the permission

Called from

Call sites

PlayerInitialized(actor)

server packages/flow/hooks/sv_nethooks.lua:29

Called on the server when the client of a player has finished loading and reports that its local player exists, right after the config, the networked variables and the list of disabled plugins have been sent to it. The gamemode's handler marks the player as initialized (see Player:has_initialized) and, a quarter of a second later, runs the hook on the player's own client, where it is called without arguments. Not called for bots, which are marked as initialized as soon as they join.

Parameters

  • actor Player The player who has finished loading; nil on the client

Call sites

PlayerInitialSpawn(target)

client packages/flow/hooks/cl_nethooks.lua:20

GMod's PlayerInitialSpawn hook, which the game only runs on the server. Flux runs it on every client as well when the server announces a newly connected player; bots are not announced. The hook waits for the client to receive the entity of the player (see util.wait_for_ent) and is not run if the entity never arrives.

Parameters

  • actor Player The player who has joined

Call sites

PlayerIsRoot(self)

shared packages/flow/lib/meta/sh_player.lua:363

Decides whether a player has root access, that is can do anything. Called on both realms by Player:is_root, which returns whatever the hook returns. Flux has no handler of its own: an admin plugin is expected to implement it.

Parameters

  • target Player The player being checked

Returns

  • Boolean Whether the player is root

Called from

Call sites

PlayerLanguageChanged(actor, lang, old_lang)

server packages/flow/hooks/sv_nethooks.lua:49

Called on the server when the client of a player has reported a new language: the one the player picked with Flux.Lang:set_language, or else the language of their game. Runs after Flux.Lang:get_player_lang has started to return the new language. Not called for the first report of a player whose language is English, which is what the server assumes until then.

Parameters

  • actor Player The player whose language has changed
  • new_lang String New language code
  • old_lang String Previous language code

Call sites

PlayerLoadoutGiven(actor, default_loadout)

server packages/flow/hooks/sv_hooks.lua:845

Called on the server once a spawning player holds the default loadout, after the gamemode has stripped their weapons and given the default ones. This is where a plugin or schema gives the player the weapons of their faction, rank or job: a weapon given from PostPlayerLoadout would be stripped right after. Runs inside Player:Spawn, so whatever happens after the spawn, such as restoring saved ammo, sees these weapons.

Parameters

  • actor Player the player who has spawned
  • default_loadout List<String> weapon classes the player has been given

Called from

Call sites

PlayerModelChanged(client, model, model)

shared packages/flow/lib/meta/sh_player.lua:81

Called when the model of a player changes, right before the new model is applied. Player:SetModel runs it on the realm it is called on, and the server also announces the change to every client, which runs the hook once the player's entity is valid there. In addition, the client runs it for every player when the map's entities have been created, with the current model as both the new and the old one. The gamemode's handler assigns the animation table of the new model to the player.

Parameters

  • target Player The player whose model changes
  • new_model String Path of the new model
  • old_model String Path of the previous model

Called from

Call sites

PlayerOneMinute(client)

shared packages/flow/hooks/sh_hooks.lua:563

Called once a minute for every player, on both realms. The calls are spread out: each player's call comes a quarter of a second after the previous player's.

Parameters

  • actor Player The player the call is for

Call sites

PlayerOneSecond(client, cur_time)

server packages/flow/hooks/sv_hooks.lua:895

Called on the server once a second for every player, right after that player's PlayerThink. The gamemode's handler uses it to detect movement (see PlayerPositionChanged).

Parameters

  • actor Player The player to process
  • cur_time Number CurTime() of the call

Called from

Call sites

PlayerPositionChanged(actor, last_pos, pos, cur_time)

server packages/flow/hooks/sv_hooks.lua:721

Called on the server when a player is not where they were a second ago. The gamemode checks this once a second for every player, from its PlayerOneSecond handler.

Parameters

  • actor Player The player who has moved
  • old_pos Vector Position at the previous check; nil at the player's first check
  • new_pos Vector Current position
  • cur_time Number CurTime() of the check

Called from

Call sites

PlayerRestored(self, self.record)

server packages/flow/lib/meta/sv_player.lua:197

Called on the server once the database record of a player who has just joined is available as actor.record. For a player who joins for the first time it runs after PlayerCreated, when the new record has been saved. Bots get it right away with a blank record.

Parameters

  • actor Player The player who has joined
  • record User The database record of the player

Called from

Call sites

PlayerRunCommand(actor, cmd_table, args)

server packages/flow/lib/sh_command.lua:1062

Called on the server right before a command is logged and run, after all of the checks have passed and its targets have been found.

Parameters

  • actor Player the player who runs the command, an invalid entity for the server console
  • cmd_table Command the command that runs; for a subcommand this is the subcommand, and its parent is the command it belongs to
  • args List arguments that are passed to on_run, without the subcommand word; for a command that targets players, the player argument is already a List<Player>

Returns

  • Boolean Return true to stop the command from running; the player is not notified

Called from

Call sites

PlayerSetModel(actor)

server packages/flow/hooks/sv_hooks.lua:83

GMod's PlayerSetModel hook, run by Flux on the server every time a player spawns, before the rest of their state is reset. The gamemode's handler applies the model (see PrePlayerSetModel for changing it). A plugin or schema handler that returns a value replaces the gamemode's handler and has to set the model itself.

Parameters

  • actor Player The player who is spawning

Called from

Call sites

PlayerSetupDataTables(self.Player)

shared packages/flow/lib/classes/sh_player.lua:34

Called on the server and the client when the data tables of a player are set up, right after Flux has added its own Initialized variable. Add the data table variables of your plugin to the player here with DTVar.

Parameters

  • target Player the player whose data tables are being set up

Called from

Call sites

PlayerSwitchedFlashlight(actor, on)

server packages/flow/hooks/sv_hooks.lua:789

Called on the server when a player toggles their flashlight, before the engine does it. The Shared Flashlight plugin handles it by toggling a light that other players can see and returning false.

Parameters

  • actor Player The player who toggles the flashlight
  • on Boolean Whether the flashlight is being turned on

Returns

  • Boolean Return false to keep the engine flashlight from toggling, true to allow it; the base gamemode decides when nothing is returned

Called from

Call sites

PlayerTakeDamage(ent, damage_info)

server packages/flow/hooks/sv_hooks.lua:548

Called on the server whenever a player takes damage, from the gamemode's EntityTakeDamage handler. The return value is ignored, so the damage cannot be blocked from here. The gamemode's handler tells the victim's client to show the damage flash.

Parameters

  • victim Player The player taking the damage
  • damage_info CTakeDamageInfo The damage being dealt

Called from

Call sites

PlayerThink(client, cur_time)

server packages/flow/hooks/sv_hooks.lua:887

Called on the server eight times a second for every player, including players who are dead or not initialized yet. Prefer PlayerOneSecond when once a second is often enough. The gamemode's handler runs the player's current action.

Parameters

  • actor Player The player to process
  • cur_time Number CurTime() of the call

Called from

Call sites

PlayerTimedActionFinished(actor, action, success)

shared packages/flow/lib/sh_timed_action.lua:143

Called when a timed action of a player has ended, after the callback of the action. Runs on the server and, for the local player only, on the client of the owner (where the action table has no condition, callback and options).

Parameters

  • actor Player The player who was doing the action; no longer valid on the server if they have already left
  • action Map The action, see Flux.TimedAction:get
  • success Boolean true if the action ran for its whole duration, false if it was canceled

Called from

  • finish
  • clear

Call sites

PlayerTimedActionStarted(actor, action)

shared packages/flow/lib/sh_timed_action.lua:252

Called when a timed action of a player has started. Runs on the server and, for the local player only, on the client of the owner (where the action table has no condition, callback and options).

Parameters

Called from

Call sites

PopulateSpawnMenu()

client packages/flow/hooks/cl_hooks.lua:69

Called on the client once the server has initialized the local player, right before the spawn menu is rebuilt with the spawnmenu_reload console command. Plugins add their spawn menu tabs here.

Called from

Call sites

PopulateToolMenu()

client packages/flow/hooks/cl_hooks.lua:75

Sandbox's PopulateToolMenu hook, run once more by Flux on the client when the server has initialized the local player, after the spawn menu reload has been requested. The gamemode's handler adds every registered Flux tool to the tool menu and then runs SynchronizeTools.

Called from

Call sites

PostDrawLoadingScreen()

client packages/flow/hooks/cl_hooks.lua:171

Called on the client every frame right after the loading screen has been drawn, for drawing on top of it. Gamemode (GM) handlers are not called.

Called from

Call sites

PostPlayerLoadout(self.Player, self.loadout)

shared packages/flow/lib/classes/sh_player.lua:80

Called on the server when a player gets their loadout after spawning. The handler of the Flux gamemode strips the weapons of the player, gives them the weapons of the default loadout and selects the first one; it does not run if a plugin or schema handler returns a non-nil value.

Parameters

  • actor Player the player who has spawned
  • default_loadout List<String> weapon classes of the default loadout

Called from

Call sites

PostPlayerSpawn(actor)

server packages/flow/hooks/sv_hooks.lua:111

Called on the server every time a player spawns, after their model, collisions, visibility and movement speeds have been reset and before their hands model is created. This is the place to set up whatever the player should spawn with. The gamemode's handler gives the loadout, plus the tool gun and the physics gun to players with the permissions for them, then runs the hook on the player's own client, where it is called without arguments.

Parameters

  • actor Player The player who has spawned; nil on the client

Called from

Call sites

PostSaveData()

server packages/flow/hooks/sv_hooks.lua:690

Called on the server after a data save, when the config has been saved and every SaveData handler has run. This is the place for work that depends on the saved state, such as a backup or a log entry. Database queries that the handlers have started may still be running.

Called from

Call sites

PostSavePlayerData(self)

server packages/flow/lib/meta/sv_player.lua:57

Called on the server after Player:save_player has saved the database record of a player. Not called for bots.

Parameters

  • actor Player The player who has been saved

Called from

Call sites

PreDrawPlayerInfo(target, x, y, distance, lines)

client packages/flow/hooks/cl_hooks.lua:402

Called on the client after the target ID lines of a player have been collected with GetDrawPlayerInfo and before they are drawn. Handlers can change or remove the entries of lines.

Parameters

  • target Player The player being looked at
  • x Number Screen x of the target ID
  • y Number Screen y of the target ID
  • distance Number Distance to the player in units
  • lines Map Lines about to be drawn by ID, see GetDrawPlayerInfo

Returns

  • Boolean Return false to draw nothing for this player

Called from

Call sites

PreIncludeTool(TOOL)

shared packages/flow/lib/sh_tool.lua:26

Called on the server and the client when a tool file is about to be included. The tool is a new Tool object that only has its mode and ID set.

Parameters

  • tool Tool the tool that is being loaded

Call sites

PrePlayerSetModel(actor)

server packages/flow/hooks/sv_hooks.lua:172

Lets plugins choose the model a player gets when the gamemode sets it, which happens on the server every time the player spawns.

Parameters

  • actor Player The player whose model is being set

Returns

  • String/Boolean Path of the model to use, or false to let the base gamemode pick the model. When nothing is returned, bots and initialized players get the model from their model networked variable and everyone else is left to the base gamemode

Called from

Call sites

PreSavePlayerData(self)

server packages/flow/lib/meta/sv_player.lua:42

Called on the server before Player:save_player saves the database record of a player. Not called for bots.

Parameters

  • actor Player The player about to be saved

Returns

  • Boolean Return true to prevent the record from being saved; in that case PostSavePlayerData is not run either

Called from

Call sites

Called on the server for plugins to save their persistent data, from the gamemode's FLSaveData handler after the config has been saved. The counterpart of LoadData.

Called from

Call sites

ShouldDrawLoadingScreen()

client packages/flow/hooks/cl_hooks.lua:125

Asks whether the loading screen should stay up. Called on the client every frame once the local player has been initialized; until then the loading screen is always drawn.

Returns

  • Boolean Return true to keep drawing the loading screen

Called from

Call sites

ShouldHUDPaint()

client packages/flow/hooks/cl_hooks.lua:186

Asks whether the HUD should be drawn. Called on the client every frame once the local player has been initialized, from the gamemode's HUDPaint handler. HUD elements that plugins draw on their own, such as the crosshair, can run it too.

Returns

  • Boolean Return false to hide the Flux HUD and the HUD of the base gamemode

Called from

Call sites

ShouldServerAutoRestart()

server packages/flow/hooks/sv_hooks.lua:594

Asks whether the empty server may reload the current map. Called on the server every half an hour, if no players are connected at that moment.

Returns

  • Boolean Return false to prevent the map from being reloaded

Called from

Call sites

SoftUndo(client)

client packages/flow/hooks/cl_hooks.lua:606

Called on the client when the local player presses the undo key (a bind containing gmod_undo). The gamemode's handler asks the server to undo the last entry of the player's Flux undo queue and returns true if the queue is not empty.

Parameters

  • client Player The local player

Returns

  • Any Return any non-nil value to block the bind, which keeps sandbox's own undo from running as well

Called from

Call sites

SynchronizeTools()

client packages/flow/hooks/cl_hooks.lua:50

Called on the client when the tool gun has to learn about the Flux tools: once the map's entities have been created, and again whenever the tool menu has been populated. The gamemode's handler copies every registered Flux tool into the tool table of the tool gun.

Called from

Call sites

TargetFromString(actor, str, start)

server packages/flow/lib/sh_command.lua:768

Lets plugins add target selectors for the player argument of commands. Called on the server when the argument does not start with one of the built-in selector characters. If no function is returned, the argument is looked up as a player name.

Parameters

  • actor Player the player who is running the command, an invalid entity for the server console
  • str String the whole player argument
  • start String first character of the argument

Returns

  • Function Parser that is called with the actor and the argument; it returns a List<Player> of targets, or false if there are none, and the selector character

Called from

Call sites

ToolPreCreateConvars(TOOL)

shared packages/flow/lib/sh_tool.lua:33

Called on the server and the client after a tool file has been included, right before the console variables of the tool are created with Tool:CreateConVars.

Parameters

  • tool Tool the tool that has been loaded

Call sites

Defined in