Permissions
Staff grades persisted in the database, with linear level inheritance and permission-checked commands.
Staff grades persisted in the database, with linear level inheritance and permission-checked commands.
lib.permissions manages staff grades stored in the database. A grade is { name, level },
and inheritance is linear by level — a level-100 player has every right of the lower
levels. Grades are defined in see_lib's config.
| Function | Returns | Description |
|---|---|---|
getGrade(source) | { name, level }? | The player's grade, or nil. |
hasLevel(source, level) | boolean | Whether the player is at least level. |
isStaff(source) | boolean | Whether the player has any grade. |
setGrade(source, gradeName) | boolean | Assign a grade (persisted). |
removeGrade(source) | boolean | Remove the player's grade. |
getGradeLevel(gradeName) | number? | The level of a grade, by name. |
getGrade(source){ name, level }?nil.hasLevel(source, level)booleanlevel.isStaff(source)booleansetGrade(source, gradeName)booleanremoveGrade(source)booleangetGradeLevel(gradeName)number?if not lib.permissions.hasLevel(source, 50) then return end
lib.permissions.setGrade(source, 'moderator')registerCommand(name, requiredLevel, handler, allowConsole?) wraps RegisterCommand with an
automatic level check:
lib.permissions.registerCommand('revive', 50, function(source, args)
local targetId = tonumber(args[1])
if targetId then revivePlayer(targetId) end
end)A player below requiredLevel gets an error notification. The server console (source 0) is
blocked unless you pass allowConsole = true.
Client-side, lib.permissions exposes a synchronous cache of the local player's grade —
for UI filtering only, never as a source of truth.
getLevel() → number — local grade level (0 if not staff).hasLevel(level) → boolean — note: no source here (the local player is implied).isStaff() → boolean.Always re-check on the server for anything sensitive — the client cache can be tampered with. Inheritance is by level, not by named scope. A grade must exist in the config, or setGrade fails (returns false).