RPG Xdocumentation About RPG X

Ranks and permissions

The three ranks, setting them with or without ULX, and adding your own permissions.

Three fixed ranks. Which rank has which permission is hardcoded; the only thing that changes is which rank a player is.

Rank ULX group Can
User user Play. Everyone starts here.
Admin operator Nothing extra yet.
Owner superadmin Everything below.
Permission Rank What it covers
sandbox Owner Spawn menu (Q), context menu (C), spawning, toolgun (so also the Enemy Spawns tool), properties, noclip (still subject to sbox_noclip)
setrank Owner rpgx_setrank, rpgx_ranks
inventory_manage Owner rpgx_inventory_setslots
resource_debug Owner rpgx_resource (spend or refill stamina / mana by command, for testing)
weapon_balance Owner The guns' Change values editor (see Guns)
buff_debug Owner rpgx_buff (give and clear buffs by command, for testing)

A player's rank is their usergroup (owner = superadmin, admin = operator), so IsSuperAdmin() and other addons agree with it. Players without sandbox can't open Q or C and don't get the "press Q" hint; it's enforced on the server too, so gm_spawn and friends don't get around it. Nobody spawns with weapons either way; see Inventory.

Setting ranks (without ULX) #

From the server console (and, in their own console, for owners):

rpgx_setrank <player name or SteamID> <user|admin|owner>
rpgx_ranks

Online players can be named by part of their name; offline players need a SteamID64 or STEAM_0:x:y. Ranks are saved (rpgx_player_rank) and set again when the player joins. The very first owner has to be made from the server console. Players without a saved rank keep whatever the base game gave them (a listen server's host is superadmin).

With ULX #

Install ULX and it takes over, no setup:

  • Every permission is registered with ULX as rpgx <id> (category "RPG X") and granted to its rank's group: rpgx sandbox to superadmin, and so on. From then on they're ULX permissions, changed in xgui > Groups like any other.
  • At the first map start with ULX, every saved rank is added to ULX's users (owner as superadmin, admin as operator), once. Players ULX already knew keep their ULX group. rpgx_ranks shows which ones were moved.
  • Ranks are then set with ULX (ulx adduser); rpgx_setrank says so.

Adding permissions (addons) #

-- On both realms. GAMEMODE doesn't exist yet while addon autorun files load, so in a hook:
hook.Add( "Initialize", "MyAddon", function()
	GAMEMODE:RegisterPermission( "myaddon_fly", "admin", "Fly around" )   -- lowest rank that has it
end )

if ( GAMEMODE:HasPermission( ply, "myaddon_fly" ) ) then ... end

It's checked against the player's rank, or with ULX installed, registered there as rpgx myaddon_fly for the rank's group (operator here), exactly like the built-in ones. GAMEMODE:PlayerRank( ply ) gives "user", "admin" or "owner". A RPGXHasPermission( ply, id ) hook returning true or false overrules both; CanUseSandbox returning false still takes Sandbox away.