Summary

Hooks

Finds the player an item is applied to: the living character its user looks at from up close.
Called every second for each player; runs the disease symptoms and random infections.
Called when the local player's motion blurs should be adjusted; applies disease screen effects.
Called when a character data value changes; networks the diseases value to clients.
Called when a player has been healed with an item; applies the medicine's rewards.
Called when a player's character data is restored; defaults a missing or unknown disease to 'none'.
Called when a player uses an item; can give a disease from food and triggers food symptoms.
Changes a character's disease after a delay, provided it is still the expected one by then.

Hooks

cwDiseases:FindPatient(player, itemTable, phrase)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:25

Finds the player an item is applied to: the living character its user looks at from up close.

Tells the user why when there is none. Custom item functions do not ask the PlayerCanUseItem hook themselves, so pass them the item and the hook has to allow its use first.

local patient = cwDiseases:FindPatient(player, self)

if !patient then return false end

Parameters

  • player Player The player applying the item
  • itemTable Item optional, defaults to nil The item, when it is applied through one of its custom functions
  • phrase String optional, defaults to 'Diseases_MustLookAtPerson' Phrase the player is told when they look at nobody

Returns

  • Player The patient, or nil when there is none

cwDiseases:OnePlayerSecond(player, curTime, infoTable)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:114

Implements hook OnePlayerSecond

Called every second for each player; runs the disease symptoms and random infections.

Coughs (which can turn into pneumonia), fever and gastritis play emotes and sounds at random intervals while the player is not noclipping. Healthy players have a chance every five to ten minutes to catch a cough, a fever, colour blindness or, at a Hunger of 65 or more, diarrhea. The death injections drain a point of health every few seconds (fast_deathinjection every half second) and perma-kill the character once health drops below 5. The diseases net var is kept in step with the character, which also covers a character that has just been loaded.

Parameters

  • player Player The player being updated
  • curTime Number The current time
  • infoTable Map Per-second player info; unused

cwDiseases:PlayerAdjustMotionBlurs(motionBlurs)

client gamemodes/cwhl2rp/plugins/diseases/plugin/cl_hooks.lua:13

Implements hook PlayerAdjustMotionBlurs

Called when the local player's motion blurs should be adjusted; applies disease screen effects.

Fever and the death injections add motion blur, and colour blindness draws the screen in greyscale.

Parameters

  • motionBlurs Map Motion blur state; entries of its blurTable are blur amounts by name

cwDiseases:PlayerCharacterDataChanged(player, key, oldValue, value)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:63

Implements hook PlayerCharacterDataChanged

Called when a character data value changes; networks the diseases value to clients.

Parameters

  • player Player The player whose character data changed
  • key String Name of the changed value
  • oldValue Any The previous value
  • value Any The new value

cwDiseases:PlayerHealed(player, healer, itemTable)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:219

Implements hook PlayerHealed

Called when a player has been healed with an item; applies the medicine's rewards.

Most medicines boost the patient's agility for two minutes, and every one listed progresses the healer's medical attribute by an amount that depends on the item.

Parameters

  • player Player The patient
  • healer Player The player who used the item; the patient themselves for self-treatment
  • itemTable Item The medicine used

cwDiseases:PlayerRestoreCharacterData(player, data)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:72

Implements hook PlayerRestoreCharacterData

Called when a player's character data is restored; defaults a missing or unknown disease to 'none'.

Parameters

  • player Player The player whose character is loaded
  • data Map The character data being restored

cwDiseases:PlayerUseItem(player, itemTable, itemEntity)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:253

Implements hook PlayerUseItem

Called when a player uses an item; can give a disease from food and triggers food symptoms.

A healthy player may get an allergy from some fruit and bread, gastritis from junk food or insomnia from coffee. Allergic players take damage from those foods again, and players with diarrhea vomit and take damage after eating or drinking anything. The delayed effects are dropped when the player has left, died or switched character by then.

Parameters

  • player Player The player who used the item
  • itemTable Item The item used
  • itemEntity Entity The item's entity when used from the world, otherwise nil

cwDiseases:SetDiseaseDelayed(player, delay, expected, disease)

server gamemodes/cwhl2rp/plugins/diseases/plugin/sv_hooks.lua:47

Changes a character's disease after a delay, provided it is still the expected one by then.

Does nothing when the player has left or switched character in the meantime.

Parameters

  • player Player The player whose character is affected
  • delay Number Seconds to wait
  • expected String The disease the character must still have
  • disease String The disease to set, 'none' to cure

Defined in