OnPlayerLevelUp
The player earned a level in a stat or a skill, or a level of the character.
The player’s game reported a level higher than the record had - the XP the game awarded (SetXPRate) or the mode’s own
AddPlayerSkillXP filled the bar. The record already holds the new level when this runs. It does not run for a level
the mode set (SetPlayerStat, SetPlayerProgress); it needs a level the server already had to compare with, so the
first report of a visit raises none. OnPlayerProgressChange follows for the same report, so a mode that saves
characters needs only that one. A level the mode vouches for in OnPlayerProgressViolation under [audit] mode = "enforce" is announced here too, as a level the player’s game earned.
The main level comes here too, as the stat mainlevel: the level the game shows for the character rose because the
levels beneath it did. The game works it out from those, so a rise the mode’s own sets cause - a restore, SetPlayerStat,
the [spawn] stat_level floor - a moment later is not a level the player earned, and is not announced: for about ten
seconds after such a set the main level is taken into the record quietly.
Syntax
Section titled “Syntax”function OnPlayerLevelUp(pid, kind, name, level) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
kind |
string | "stat" or "skill" |
name |
string | the stat’s or skill’s lower-case name ("mainlevel" for the main level) |
level |
number | the new level |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerLevelUp(pid, kind, name, level) if name == "mainlevel" then SendClientMessageToAll(COLOR_GOLD, string.format("%s is a level %d character now.", GetPlayerName(pid), level)) else SendClientMessageToAll(COLOR_GOLD, string.format("%s reached level %d in %s.", GetPlayerName(pid), level, (name:gsub("_", " ")))) endendSee also
Section titled “See also”OnPlayerGainXP · OnPlayerProgressChange · GetPlayerSkill · GetPlayerLevel · the Stats, skills, XP and perks group of the index
