Hooks hooksserver
Part of Levels
Hooks called by Levels
Summary
Hooks
levels_combat_experience config is on.Player:give_experience, Player:set_level or the staff commands.Hooks
Lets plugins change or cancel the experience a player gains in combat while the
levels_combat_experience config is on. Called on the server by the Levels plugin for
the damage a player deals to an NPC or another player and for every NPC a player kills.
Change info.amount to give another amount; an amount that is not above 0 gives none.
function PLUGIN:AdjustCombatExperience(actor, info)
if info.victim:IsPlayer() then
info.amount = 0
end
end
Parameters
- actor Player The player who gains the experience
- info Map amount (Number experience to give), reason ('damage' or 'kill'), victim (Entity the NPC or player that was hurt or killed) and damage_info (CTakeDamageInfo the damage that was dealt; nil for a kill)
Returns
- Boolean Return false to give no experience. Return nothing to let other handlers run
Called from
give_combat_experience
Call sites
PlayerExperienceChanged(target, experience, old_experience, reason)
server plugins/levels/plugin/lib/sh_levels.lua:445Called on the server after the level or the experience of a player's character has
changed and the change has been networked, however it came about: through
Player:give_experience, Player:set_level or the staff commands. A call that moves
the character over several levels runs the hook once.
Parameters
- actor Player The player whose character it is
- experience Number New experience toward the next level, which may be more than the level needs while the character is at the level cap
- old Number Experience toward the next level before the change, which may have been a lower level
- reason String What the experience was given for: 'damage' and 'kill' for combat experience, 'command' for the
experience addcommand, 'level_set' when the level was set, 'catch_up' when the level cap has risen and kept experience was spent, 'level_floor' when the character was raised to the level floor, or whatever the caller ofPlayer:give_experiencepassed; may be nil
Called from
Call sites
Called on the server after the level of a player's character has changed, right after PlayerExperienceChanged. Its unspent points have already been worked out again. A call that moves the character over several levels runs the hook once. The Levels plugin applies the new maximum health from its own handler.
Parameters
- actor Player The player whose character it is
- level Number New level
- old_level Number Level before the change
Called from
Call sites
Called on the server when the server level has changed, because time has passed, because staff set it, or because a config of the server level was changed. The new level has already been networked. The Levels plugin levels characters up to the new level cap with their kept experience and raises them to the new level floor from its own handler.
Parameters
- level Number New server level
- old_level Number Server level before the change