Summary

Hooks

Registers a named karma level covering a range of karma values.
Called when a targeted player's status is drawn; shows the karma level of recognised non-Combine players.
Called when the local player's info text is built; adds the karma level line.
Called while the info menu is painted; draws the karma bar with a slider at the local player's karma.
Called when a character's data is restored; starts characters without karma at 0.
Called just after a player spawns; networks the character's karma to clients.

Hooks

cwKarma:AddKarmaLevel(bottom, ceiling, phrase)

shared gamemodes/cwhl2rp/plugins/karma/plugin/sh_plugin.lua:27

Registers 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:54

Implements 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 y position below the drawn text, or nil when nothing was drawn

cwKarma:GetPlayerInfoText(playerInfoText)

client gamemodes/cwhl2rp/plugins/karma/plugin/cl_hooks.lua:8

Implements 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)

cwKarma:PaintInfoMenuExtras(info)

client gamemodes/cwhl2rp/plugins/karma/plugin/cl_hooks.lua:18

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, width and height; info:Adjust(n) moves it down by n

cwKarma:PlayerRestoreCharacterData(player, data)

server gamemodes/cwhl2rp/plugins/karma/plugin/sv_hooks.lua:7

Implements 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; karma is set in place

cwKarma:PostPlayerSpawn(player, lightSpawn, changeClass, firstSpawn)

server gamemodes/cwhl2rp/plugins/karma/plugin/sv_hooks.lua:18

Implements 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

Defined in