RPG Xdocumentation About RPG X

Inventory and hotbar

The hotbar, the inventory window, death drops and lootable containers.

Players spawn with nothing: no weapons, no ammo. Any SWEP they pick up, spawn from the Q menu or get through Player:Give goes into their inventory instead of their hands (with a "... added to your inventory" notice). If the inventory is full, the weapon stays where it is.

Hotbar #

Like Minecraft's: the first rpgx_hotbar_slots (9) inventory slots are the hotbar, shown at the bottom of the screen. Whatever is in the selected slot (gold edge) is in your hands, and only that; an empty slot means empty hands. Pick a slot with 1-9 / 0, the mouse wheel, or the last-weapon key (back to the one before). GMod's own weapon selector is gone, and so is the pickup list on the right (switching slots hands you the gun, so scrolling filled it). The item's name shows above the hotbar for a moment after switching. The selected slot is saved.

Picked-up weapons fill the hotbar first, then the backpack; one that lands in the selected slot is in your hands right away.

The window #

Open it with I. Each player can change the key with rpgx_inventory_key in their console (key names like i, tab, f1), or bind the rpgx_inventory command. Movement keys keep working while it's open. It has two tabs: Inventory (what it opens on) and Quests (the quest journal, see Interactable NPCs). On the Inventory tab the hotbar row is on top, the backpack (the other slots) below.

In the window Does
Left click Moves it to the other side (hotbar ↔ backpack), into the first free slot
Right click Hold (selects its hotbar slot), Move to backpack / hotbar, Drop
Drag onto another slot Move or swap
  • Everything keeps its slot, counts towards capacity and is saved.
  • Two weapons of the same type can sit in the hotbar; switching between them swaps which one is out (GMod only allows one of a type in hand).
  • Clip ammo is kept per weapon. Reserve ammo isn't: it's cleared on spawn and not saved yet.
  • On death, the whole inventory drops in a container where you died: a cardboard box by default (rpgx_death_container_model). Anyone can press E on it and take items out one by one or all at once; it disappears when empty or after rpgx_death_container_lifetime seconds. Clip ammo stays with each weapon. With rpgx_death_drop 0 you keep everything instead. What's in a container isn't saved: a map change or restart loses it.
  • A weapon in hand that disappears any other way (stripped by an admin tool, used up, dropped by another addon) is gone from the inventory as well.
  • Server: GAMEMODE:HotbarSelect( ply, slot ), GAMEMODE:InventoryHold( ply ) (makes the hands match the selected slot), GAMEMODE:InventoryMove( ply, from, to ) (to 0 = the other side).

Inventory size per player #

rpgx_inventory_slots is the default. To change one player's size:

rpgx_inventory_setslots <player name or SteamID> <slots|default>

Works from the server console, and for owners in their own console (the inventory_manage permission). Online players can be named by part of their name; offline players need a SteamID64 or STEAM_0:x:y. default goes back to rpgx_inventory_slots. Making an inventory smaller never deletes anything: items above the new size stay (shown red) and can be moved or dropped, but nothing new fits until there's room.

Containers (addons too) #

The death drop is a general lootable container, rpgx_container: any prop holding items that players take with E. Loot chests and stashes can use the same thing (server):

local box = GAMEMODE:ContainerCreate( pos, angle, "models/props_junk/wood_crate001a.mdl", {
	{ class = "weapon_pistol" },            -- clip1 / clip2 optional
	{ class = "weapon_crowbar" },
}, { title = "Supply crate", removeWhenEmpty = true, lifetime = 0 } )

box:AddItem( "weapon_357" )

RPGXContainerCanTake( ply, box, item ) returning false stops a player taking an item (locked chests, owner-only drops).