All resources

rsg-backpacks – Docs (v3.0.4)#

Contents#

  1. Files
  2. How it works
  3. Setup
  4. Configuration
  5. Exports and commands
  6. Database
  7. Security
  8. Troubleshooting

1. Files#

FilePurpose
fxmanifest.luaManifest; depends on rsg-core, rsg-inventory, oxmysql
shared/config.luaBackpack types, limits, belt attachments
client/main.luaWearing, prop attach, /removebackpack
client/belt.luaBelt and back attachments (lanterns, lasso, machete, quiver)
server/main.luaUseable items, stashes, nested and one-backpack rules, recovery
server/database.luaAutomatic table creation and upgrade
server/utils.luaRate limit helpers
server/versionchecker.luaGitHub version check
installation/items.luaThe 7 backpack items to paste into your items file
installation/player_backpack.sqlManual database install
locales/*.jsonen, de, el, es, fr, ja, nl, pl, pt-br, ro, ru

2. How it works#

  • Merges and replaces hdrp-backpack and bln_belt_attachments. Stop both before starting rsg-backpacks.
  • 7 wearable backpack types, each with its own stash size and prop position.
  • Each backpack has a unique serial; its stash is backpack_<serial> and persists.
  • A backpack cannot be stored inside another backpack or itself (BlockNestedBackpacks).
  • With OneBackpackOnly, a player can carry only one backpack item; extras are moved back.
  • Belt/back attachments: lanterns, Davy lantern, metal detector, lasso, reinforced lasso, machete, bow quiver.
ItemSlotsMax weight
backpack_ammo2422000
backpack_fish2432000
backpack_nat3242000
backpack_big12862000
backpack_normal6452000
backpack_simple3222000
backpack_trapper6422000

3. Setup#

  1. Paste installation/items.lua into RSGShared.Items in rsg-core/shared/items.lua. Backpack items must be unique = true.
  2. Copy the images from installation/images/ into rsg-inventory/html/images/.
  3. Database: nothing to import; the table is created and upgraded on start (Config.AutoCreateTable).
  4. ensure oxmysql, rsg-core, rsg-inventory, then rsg-backpacks.

4. Configuration#

shared/config.lua:

OptionDefaultMeaning
ActionCooldown1000ms between open requests per player
AutoCreateTabletrueBuild/upgrade player_backpack on start
BlockNestedBackpackstrueNo backpacks inside backpack stashes
OneBackpackOnlytrueOne backpack item per player
backpackTypelist{ model, item, maxweight, slots, position, rotation } per backpack

5. Exports and commands#

NameSideNotes
IsBackpackItem(itemName)server exportTrue if the item is a configured backpack
rsg-backpacks:client:wearclient event(itemName, serial)
CommandWhoWhat
/removebackpackeveryoneTake the worn backpack off
/backpackrecovereveryoneRecover items from a backpack stash (rate limited)

6. Database#

CREATE TABLE IF NOT EXISTS `player_backpack` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `serial` VARCHAR(32) NOT NULL,
    `citizenid` VARCHAR(50) DEFAULT NULL,
    `owner` VARCHAR(50) DEFAULT NULL,
    `backpackitem` VARCHAR(50) NOT NULL,
    `model` VARCHAR(100) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `serial` (`serial`),
    KEY `owner` (`owner`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Older tables (e.g. from hdrp-backpack) get missing columns and indexes added automatically.

7. Security#

Open requests are rate limited. Nested and extra backpacks are removed by the server and returned to the player's inventory (with restore on failure). Stash names come from the item serial, never from the client.

8. Troubleshooting#

ProblemFix
Backpack doesn't openItem must be unique = true and listed in backpackType
Items missing after movingUse /backpackrecover
Old resources conflictStop hdrp-backpack and bln_belt_attachments
Table errorsImport installation/player_backpack.sql

Support the Project : https://rexshack.tebex.store/

<!-- BEGIN AUTO-REFERENCE (generated from the code; re-run the generator instead of editing by hand) -->

Technical reference#

Generated from the source of rsg-backpacks 3.0.4. Names, arguments and defaults below are read straight from the code.

Dependencies#

rsg-core, rsg-inventory, oxmysql

Database#

Tables: player_backpack.

For a manual install set Config.AutoDatabase = false and import installation/player_backpack.sql once.

-- shared/config.lua
Config.AutoDatabase = true -- false = import the SQL file yourself

Configuration#

OptionDefaultNotes
Config.ActionCooldown1000ms between backpack open requests per player
Config.AutoCreateTabletruebuild / upgrade the player_backpack table on start (no manual SQL needed)
Config.BlockNestedBackpackstruebackpacks can not be stored inside another backpack stash
Config.OneBackpackOnlytruea player can only carry ONE backpack item at a time
Config.backpackTypetablebackpack models (item names / stash sizes). Stash name is always 'backpack_<serial>'
Config.backpackByItem{}lookup by item name (built automatically)
Config.Belttable

Exports#

Server

ExportArgumentsFile
IsBackpackItemitemNameserver/main.lua
-- example
local result = exports['rsg-backpacks']:IsBackpackItem(itemName)

Events#

Server events can be fired by any client, so every handler re-validates the player, the arguments and any permission, distance or cooldown on the server. Never add a reward to a handler without those checks.

EventSideArgumentsFile
rsg-backpacks:client:wearclientitemName, serialclient/main.lua
rsg:client:refreshSkinclient``client/main.lua
rsg-inventory:server:SetInventoryDataserverfromInventory, toInventory, _, toSlotserver/main.lua
rsg-inventory:server:closeInventoryserverinventoryserver/main.lua
-- from a client script
TriggerServerEvent('rsg-inventory:server:SetInventoryData', fromInventory, toInventory, _, toSlot)
-- from a server script
TriggerClientEvent('rsg-backpacks:client:wear', source, itemName, serial)

Commands#

CommandNotesFile
/removebackpackclient/main.lua
/backpackrecoverlocale('cmd_recover_help')server/main.lua

Locales#

Language files in locales/: de, el, en, es, fr, ja, nl, pl, pt-br, ro, ru. Set the language with setr rsg:locale "en".

<!-- END AUTO-REFERENCE -->