Summary
Hooks
Stamina net var.Stamina to 100 when it is missing.Stamina value.Hooks
Implements hook GetBars
Called to collect the HUD bars; adds the stamina bar, with fatigue as its limit, while stamina is below 95.
The displayed value eases towards the Stamina net var by one point per call.
Parameters
- bars Map The bar list; entries are added with
bars:Add
cwStamina:OnePlayerSecond(player, curTime)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:68Implements hook OnePlayerSecond
Called every second for each player; copies their stamina character data to the Stamina net var.
The value is only sent to the player themselves, and only when it has changed.
Parameters
- player Player The player being updated
- curTime Number The current time
cwStamina:PlayerCanThrowPunch(player)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:45Implements hook PlayerCanThrowPunch
Called when a player tries to throw a punch; blocks it at 10 stamina or less.
Parameters
- player Player The player trying to punch
Returns
- Boolean False when the player is too tired, otherwise nil
cwStamina:PlayerDisconnected(player)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:205Called when a player disconnects; removes their stamina timers.
Parameters
- player Player The player who disconnected
Implements hook PlayerPunchThrown
Called when a player throws a punch; drains stamina (less with more endurance) and progresses melee.
Parameters
- player Player The player who punched
cwStamina:PlayerRestoreCharacterData(player, data)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:23Implements hook PlayerRestoreCharacterData
Called when a player's character data is restored; sets Stamina to 100 when it is missing.
Parameters
- player Player The player whose character is restored
- data Map The restored character data
cwStamina:PlayerSaveCharacterData(player, data)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:13Implements hook PlayerSaveCharacterData
Called when a player's character data is saved; rounds the Stamina value.
Parameters
- player Player The player whose character is saved
- data Map The character data about to be saved
cwStamina:PlayerThink(player, curTime, infoTable)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:171Implements hook PlayerThink
Called periodically for every player; drains or regenerates stamina and scales the run speed.
Jumping costs 2.5 stamina. Starting to run on the ground starts a drain timer, stopping starts a
regeneration timer (twice as fast while crouching, capped at 100 minus the Fatigue character data);
the PlayerShouldStaminaDrain and PlayerShouldStaminaRegenerate hooks stop a timer from running by
returning false. Nothing changes while noclipping. The run speed in infoTable is lowered towards the walk speed
as stamina falls, and capped at the run_speed config.
Parameters
- player Player The player being updated
- curTime Number The current time
- infoTable Map The player's movement info:
isJumping,isRunning,runSpeedandwalkSpeed;runSpeedis changed in place
cwStamina:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)
server gamemodes/catwork/plugins/stamina/plugin/sv_hooks.lua:35Implements hook PostPlayerSpawn
Called after a player spawns; refills their stamina unless it is a light spawn or the first spawn.
Parameters
- player Player The player who spawned
- lightSpawn Boolean Whether this is a light spawn that keeps the player's state
- changeClass Boolean Whether the spawn comes from a class change
- firstSpawn Boolean Whether this is the character's first spawn