Important functions and variables
This section details the main functions and variables used or exposed by the script.
Understanding them will help you customize the script or integrate it with other resources.
Editable functions (client)
Section titled “Editable functions (client)”These functions are located in the file: /client/opensource.lua. You can freely edit them to adapt the script to your server.
Display a notification
Section titled “Display a notification”function OS_Notify(msg, kind) -- msg : translated text -- kind : 'info' | 'success' | 'error'endReplace the content of this function to use your own notification system.
Play a UI sound
Section titled “Play a UI sound”function OS_PlaySound(name) -- name : 'Place' or 'Detonate' (see Config.Sounds)endDisplay the key of a command
Section titled “Display the key of a command”function OS_KeyLabel(command) -- Returns the key icon bound to a command (e.g. in notifications)endServer exports
Section titled “Server exports”These exports let you integrate the script with any inventory or shop system.
Add bombs to a player’s stock
Section titled “Add bombs to a player’s stock”exports['intense_smoke_grenade']:AddBombs(source, amount)Get a player’s stock
Section titled “Get a player’s stock”local count = exports['intense_smoke_grenade']:GetBombs(source)Start placing a bomb
Section titled “Start placing a bomb”exports['intense_smoke_grenade']:StartPlacing(source)Useful for an inventory other than ox_inventory: call this export when the player uses the item. Remember to set Config.Inventory.enabled to false and Config.Stock.enabled to true or false depending on how you remove the item.
ox_inventory callback
Section titled “ox_inventory callback”The script automatically exposes an export named after the item (Config.Inventory.item), used by ox_inventory:
server = { export = 'intense_smoke_grenade.intense_smoke_grenade' }The item is only removed from the inventory if the server validates the placement.
Best practices
Section titled “Best practices”- Use local variables (
local) to limit the scope to the relevant function or script. - You should only edit
client/opensource.lua,shared/config.luaand the files inlocales/: other files may be overwritten during an update.