Skip to content

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.

These functions are located in the file: /client/opensource.lua. You can freely edit them to adapt the script to your server.

function OS_Notify(msg, kind)
-- msg : translated text
-- kind : 'info' | 'success' | 'error'
end

Replace the content of this function to use your own notification system.

function OS_PlaySound(name)
-- name : 'Place' or 'Detonate' (see Config.Sounds)
end
function OS_KeyLabel(command)
-- Returns the key icon bound to a command (e.g. in notifications)
end

These exports let you integrate the script with any inventory or shop system.

exports['intense_smoke_grenade']:AddBombs(source, amount)
local count = exports['intense_smoke_grenade']:GetBombs(source)
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.

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.

  • Use local variables (local) to limit the scope to the relevant function or script.
  • You should only edit client/opensource.lua, shared/config.lua and the files in locales/: other files may be overwritten during an update.