Summary
Hooks
Hooks
cwKarma:AddKarmaLevel(bottom, ceiling, phrase)
shared gamemodes/cwhl2rp/plugins/karma/plugin/sh_plugin.lua:27Registers a named karma level covering a range of karma values.
Levels are checked in the order they were added, and playerMeta:GetKarmaLevel returns the
phrase of the first one whose range contains the karma. Does nothing if an argument is missing.
cwKarma:AddKarmaLevel(-9, 9, '#Karma_Neutral')
Parameters
- bottom Number Lowest karma value of the level, inclusive
- ceiling Number Highest karma value of the level, inclusive
- phrase String Language phrase naming the level
cwKarma:DrawPlayerStatusExtra(entity, alpha, x, y)
client gamemodes/cwhl2rp/plugins/karma/plugin/cl_hooks.lua:54Implements hook DrawPlayerStatusExtra
Called when a targeted player's status is drawn; shows the karma level of recognised non-Combine players.
Parameters
- entity Entity The targeted entity
- alpha Number Opacity of the target text
- x Number Horizontal centre of the text
- y Number Vertical position to draw at
Returns
- Number The
yposition below the drawn text, ornilwhen nothing was drawn
cwKarma:GetPlayerInfoText(playerInfoText)
client gamemodes/cwhl2rp/plugins/karma/plugin/cl_hooks.lua:8Implements hook GetPlayerInfoText
Called when the local player's info text is built; adds the karma level line.
Parameters
- playerInfoText Map The info text object; lines are added with
:Add(id, text)
Implements hook PaintInfoMenuExtras
Called while the info menu is painted; draws the karma bar with a slider at the local player's karma.
Parameters
- info Map Drawing area with
x,y,widthandheight;info:Adjust(n)moves it down byn
cwKarma:PlayerRestoreCharacterData(player, data)
server gamemodes/cwhl2rp/plugins/karma/plugin/sv_hooks.lua:7Implements hook PlayerRestoreCharacterData
Called when a character's data is restored; starts characters without karma at 0.
Parameters
- player Player The player whose character is loading
- data Map The character data;
karmais set in place
cwKarma:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)
server gamemodes/cwhl2rp/plugins/karma/plugin/sv_hooks.lua:18Implements hook PostPlayerSpawn
Called just after a player spawns; networks the character's karma to clients.
Parameters
- player Player The player who spawned
- lightSpawn Boolean Whether this was a light spawn
- changeClass Boolean Whether the player spawned because their class changed
- firstSpawn Boolean Whether this is the character's first spawn