SetPlayerStat
Sets a stat of the player’s character to a level, and the XP toward the next, exactly.
stat is strength, agility, vitality, speech, storyprogress (the story’s progress) or prestige (the Blacksmith
Prestige). A skill’s name is refused - use SetPlayerSkill - and so is mainlevel: the main level is the figure the game
works out from the other levels, so a mode moves it by setting those and reads it with GetPlayerLevel. level is
0 .. 30 (a fractional one is rounded down), and xp the XP already gathered toward the next level (0 by default, also
for a missing or non-numeric value). An xp at or above what the next level takes is cut to just under it, where the server
knows that figure: once the player’s game has reported the level and this call leaves it as it is. The set is exact:
the level is what it says, a higher one lowered included, and the game shows no level-up notice. The record (GetPlayerStat) holds it at once; the main level follows a moment later, and
OnPlayerLevelUp does not announce that rise.
A player who was not set starts as the level’s own character (level 5 in the four core stats and in most skills, level 0 in
the rest), so a mode that wants another start
sets it - a saved character’s at the login with SetPlayerProgress, a class’s here. Called before the player is in the
world, the set waits for their spawn and is applied right after it. With [spawn] stat_level above 0 the four core
stats are raised to at least that level at every spawn, so a set below it lasts only until the next one. A hunting bow
needs strength 13 to be held drawn.
Syntax
Section titled “Syntax”SetPlayerStat(pid, stat, level [, xp])| Parameter | Type | |
|---|---|---|
pid |
number | the player |
stat |
string | the stat’s name |
level |
number | 0 .. 30 |
xp |
number | the XP gathered toward the next level (optional) |
Returns
Section titled “Returns”boolean - false for a name that is no stat (a skill’s too, and mainlevel), a level that is missing, not a number or outside 0..30, an XP below 0 or infinite, or a player not connected
Example
Section titled “Example”-- archers get the strength for a war bow and a steady eyeSetPlayerStat(pid, "strength", 20)SetPlayerSkill(pid, "marksmanship", 18)
-- a veteran: nimble, and part of the way to the next level of agilitySetPlayerStat(pid, "agility", 16, 120)
-- the main level is not set at all: the game works it out from the levels above and shows it a moment laterSetPlayerStat(pid, "mainlevel", 12) -- falseSee also
Section titled “See also”GetPlayerStat · GetPlayerLevel · SetPlayerSkill · SetPlayerProgress · AddPlayerStatXP · the Stats, skills, XP and perks group of the index
