OnPlayerProgressChange
The player’s game reported a change to their progression - the moment to save it.
The report held something the record did not: levels is true when a level, a perk or a number of perk points
changed - save the character now - and false when only XP or the nourishment and energy moved, which happens all the
time: save those on a timer and in OnPlayerDisconnect. The first report of a visit, the whole of the progression,
counts as levels: it is also the sign that GetPlayerProgress now holds the player’s own values (a mode that restores
a saved character has put the saved ones back before then; one whose character has nothing saved takes this as the moment
saving may begin).
Not called for the mode’s own sets - SetPlayerStat, SetPlayerPerkPoints, SetPlayerProgress,
AddPlayerPerk and the rest - only for what the player’s game did, and for what the mode vouches for: under
[audit] mode = "enforce", an excess the mode vouches for in OnPlayerProgressViolation comes here with levels
true, so the character is saved with it.
Syntax
Section titled “Syntax”function OnPlayerProgressChange(pid, levels) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
levels |
boolean | true when a level, a perk or perk points changed, false for XP and the two states alone |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”function OnPlayerProgressChange(pid, levels) if not levels or not restored[pid] then return end -- XP moves every few seconds; a level or a perk is worth a write now saveProgress(pid) -- GetPlayerProgress into the mode's database: see GetPlayerProgressendSee also
Section titled “See also”GetPlayerProgress · SetPlayerProgress · OnPlayerLevelUp · OnPlayerDisconnect · the Stats, skills, XP and perks group of the index
