Chest Anywhere
Documentation relating to the jo_chest.
1. Installation
jo_chest works on all frameworks compatible with jo_libs (the list).
To install jo_chest:
- Download the library: jo_libs
- Unzip the folder and drop it in your resource folder
- Download jo_chest from your portal
- Unzip the folder and drop it in your resource folder
- Add these ensures in your server.cfg
ensure jo_libsensure jo_chest
- Add the item to your items table / file that will be used for the chest item (used in
Config.items.chest)
WARNING
Be sure you have oxmysql ensure in your server.cfg
TIP
The script automatically creates all necessary database tables during its initial startup.
Congratulation, the Chest script is ready to be used!
2. Usage
Shops
- Visit a chest shop (marked with a blip on the map)
- Press the prompt key to interact with the shop
- Select a chest type to purchase
- You can pay with money or gold depending on your preference
Placing Chests
- Use the chest item from your inventory
- Position the chest using your mouse, rotate with weapon wheel keys
- Initialize a 4-digit code to secure your chest
- Press enter to place the chest
Using Chests
- Approach a chest and press the prompt key to interact
- Enter the correct code to unlock the chest
- Access the storage inventory once unlocked
Removing Chests
- Approach a chest you own
- Hold the remove key to pick up the chest (chest must be empty)
- The chest will return to your inventory
3. Config.lua
The configuration file is config.lua in the resource root. Do not edit this file directly as your changes may be lost during updates. Instead, use overwriteConfig.lua to store your customizations.
config.lua- Default configuration maintained by developers. Do not modify this file.overwriteConfig.lua- This is where you place only the values you want to override.
How to customize the configuration
- Open
/overwriteConfig.lua - Find the value you want to change in
config.lua(e.g.,Config.language) - Copy only that line into
overwriteConfig.lua - Edit the copied value to your liking
The script loads config.lua first, then overwriteConfig.lua overwrites only the values you redefine. This ensures your customizations are preserved when updating the script.
4. For developers
Exports
Server giveChest
Use this export to give a chest to a player
-- @param source - int : serverID of the player
-- @param chestKey - string : key of the chest in Config.chests
exports.jo_chest:giveChest(source, chestKey)Filters
Filters are the new way to modify data used by the script added in the v1.2.0. These filters are fired at a specific point in time during the execution of the script. But contrary to events, filters are synchronous.
Server canBuyChest
Fires before a player buys a chest
-- @param canBuy - boolean
-- @param source - int : serverID of the player
-- @param chestKey - string : key of the chest in Config.chests
exports.jo_chest:registerFilter('canBuyChest', function(canBuy, source, chestKey)
return canBuy
end)Server canOpenShop
Fires before a player opens a shop
-- @param canOpen - boolean
-- @param source - int : serverID of the player
-- @param shop - table : shop data
exports.jo_chest:registerFilter('canOpenShop', function(canOpen, source, shop)
return canOpen
end)Server canPlaceChest
Fires when a player tries to place a chest
-- @param canPlace - boolean
-- @param source - int : serverID of the player
-- @param metadata - table : chest metadata
-- @param coords - vector3 : placement coordinates
-- @param heading - float : chest heading
exports.jo_chest:registerFilter('canPlaceChest', function(canPlace, source, metadata, coords, heading)
return canPlace
end)Server canRemoveChest
Fires when a player tries to remove a chest
-- @param isOwner - boolean
-- @param source - int : serverID of the player
-- @param chest - table : chest data
exports.jo_chest:registerFilter('canRemoveChest', function(isOwner, source, chest)
return isOwner
end)Server canUseChest
Fires when a player tries to use a chest item
-- @param canUse - boolean
-- @param source - int : serverID of the player
-- @param metadata - table : chest metadata
exports.jo_chest:registerFilter('canUseChest', function(canUse, source, metadata)
return canUse
end)Server isCheckCodeValid
Fires when checking if a code entered is valid for a chest
-- @param isValid - boolean
-- @param source - int : serverID of the player
-- @param code - int : code entered by the player
-- @param chest - table : chest data
exports.jo_chest:registerFilter('isCheckCodeValid', function(isValid, source, code, chest)
return isValid
end)