Integrations
We provide various open source functions into our Advanced Meth Crafting resource that enables you to add further customization and/or add third-party resource integrations.
Client
Partial example of code available in client/functions.lua
-- Empty function used to allow or reject a user from obtaining a meth table
-- You can add custom requirements here if you have the knowledge to do so
-- To restrict obtaining the table return false. To allow return true.
function CanObtainTable()
return true
end
-- Empty function used to allow or reject a user from interacting with a table
-- You can add custom requirements here if you have the knowledge to do so
-- To restrict opening the table menu return false. To allow return true.
--- @param id number table ID
function CanCookOnTable(id)
return true
end
-- Empty function used to allow or reject a user from starting supply runs
-- You can add custom requirements here if you have the knowledge to do so
-- To restrict the player from starting return false. To allow return true.
function CanStartSupplyRun()
return true
end
-- Used to allow or reject a user from entering a warehouse
-- You can add custom requirements here if you have the knowledge to do so
-- To allow entry return true. To reject entry return false.
--- @param id number warehouse ID
function CanEnterWarehouse(id)
return true
end
-- Empty function that is triggered upon warehouse entry
--- @param id number warehouse ID
function EnteredWarehouse(id)
end
-- Empty function that is triggered upon warehouse exit
--- @param id number warehouse ID
function ExitedWarehouse(id)
end
-- Function that is triggered when a player has started viewing a camera
-- This can be used for anything, but by default is used to disable the
-- Ability to open/view the inventory during the process
function StartedCameraView()
DisableInventory()
end
-- Function that is triggered when a player has stopped viewing a camera
-- This can be used for anything, but by default is used to re-enable the
-- Ability to open/view the inventory once the process is over
function StoppedCameraView()
EnableInventory()
end
-- Function that is triggered when a player has started a long animation
-- This can be used for anything, but by default is used to disable the
-- Ability to open/view the inventory during the process
function StartPlayingAnim()
DisableInventory()
end
-- Function that is triggered when a player has stopped a long animation
-- This can be used for anything, but by default is used to re-enable the
-- Ability to open/view the inventory once the process is over
function StopPlayingAnim()
EnableInventory()
end
Server
Partial example of code available in server/functions.lua
-- Used to verify all conditions are met before allowing table placement
-- You can add custom requirements here if you have the knowledge to do so
-- To restrict placement return false. To allow placement return true.
--- @param source number Player ID
--- @return boolean
function CanPlaceTable(source)
if not source then
EventLog('[functions.lua]: CanPlaceTable: source missing or nil')
return false
end
local player = GetPlayerPed(source)
if not player then
EventLog('[functions.lua]: CanPlaceTable: unable to obtain player ped')
return false
end
local pos = GetEntityCoords(player)
if not pos then
EventLog('[functions.lua]: CanPlaceTable: unable to obtain player position')
return false
end
local identifier = GetIdentifier(source)
if not identifier then
EventLog('[functions.lua]: CanPlaceTable: unable to obtain player identifier')
return false
end
local count = 0
for _, table in pairs(Tables) do
if table.owner == identifier then
count += 1
end
end
if count >= Config.Table.limit then
TriggerClientEvent('lation_meth:Notify', source, Strings.Notify.max, 'error')
return false
end
if Config.Police.require then
local police = GetPoliceCount()
if police < Config.Police.count then
TriggerClientEvent('lation_meth:Notify', source, Strings.Notify.noPolice, 'error')
return false
end
end
for _, location in pairs(Config.Table.restricted) do
local dist = #(pos - location.coords)
if dist < location.radius then
TriggerClientEvent('lation_meth:Notify', source, Strings.Notify.restricted, 'error')
return false
end
end
return true
end
Last updated