đConfigurables
Config files
--[[
BY RX Scripts Š rxscripts.xyz
--]]
Config.SaveInterval = 60 -- How often to save the smelters to the database (in seconds)
Config.Smelters = {
["Furnace"] = {
label = "Furnace",
prop = "prop_ind_mech_03a", -- Global prop to access the smelter
slots = 3, -- Material input/output slots
smeltTimer = 3, -- Seconds to wait before smelting everything once
fuel = { -- As long as the 'from' item and amount is inside the machine, it can be turned on
from = { item = "gold", amount = 10 },
to = { item = "stone", amount = 5 }, -- Remove this line if u don't want any output item
},
smeltings = {
{
from = { item = "gold", amount = 1 },
to = { item = "stone", amount = 3 },
},
{
from = { item = "stone", amount = 1 },
to = { item = "gold", amount = 3 },
},
},
locations = { -- Locations to spawn a smelter on server start
vector4(1879.4086, 281.6312, 163.2741, 240.4952),
},
placeable = {
enabled = true, -- If you want to allow players to place smelters
item = "furnace", -- Item to place a smelter
pickup = {
enabled = true, -- If you want to allow players to pick up smelters
placerOnly = true, -- If you want only the placer to be able to pick up the smelter
returnItem = true, -- If you want to return the item to the player after picking up the smelter
}
},
},
["Large Furnace"] = {
label = "Large Furnace",
prop = "prop_ind_mech_01c", -- Global prop to access the smelter
slots = 6, -- Material input/output slots
smeltTimer = 3, -- Seconds to wait before smelting everything once
fuel = { -- As long as the 'from' item and amount is inside the machine, it can be turned on
from = { item = "gold", amount = 10 },
to = { item = "stone", amount = 5 }, -- Remove this line if u don't want any output item
},
smeltings = {
{
from = { item = "gold", amount = 1 },
to = { item = "stone", amount = 3 },
},
},
locations = { -- Locations to spawn a smelter on server start
vector4(1880.8346, 284.4971, 163.2741, 238.1256),
},
placeable = {
enabled = true, -- If you want to allow players to place smelters
item = "large_furnace", -- Item to place a smelter
pickup = {
enabled = true, -- If you want to allow players to pick up smelters
placerOnly = true, -- If you want only the placer to be able to pick up the smelter
returnItem = true, -- If you want to return the item to the player after picking up the smelter
}
},
},
["BBQ"] = {
label = "BBQ Grill",
prop = "prop_bbq_5", -- Global prop to access the smelter
slots = 3, -- Input/output slots
smeltTimer = 3, -- Seconds to wait before smelting everything once
fuel = { -- As long as the 'from' item and amount is inside the machine, it can be turned on
from = { item = "wood", amount = 10 },
to = { item = "charcoal", amount = 5 }, -- Remove this line if u don't want any output item
},
smeltings = {
{
from = { item = "tosti", amount = 1 },
to = { item = "sandwich", amount = 1 },
},
{
from = { item = "twerks_candy", amount = 1 },
to = { item = "snikkel_candy", amount = 1 },
},
},
locations = { -- Locations to spawn a smelter on server start
vector4(1877.8315, 279.1890, 163.2741, 244.8476),
},
placeable = {
enabled = true, -- If you want to allow players to place smelters
item = "bbq", -- Item to place a smelter
pickup = {
enabled = true, -- If you want to allow players to pick up smelters
placerOnly = true, -- If you want only the placer to be able to pick up the smelter
returnItem = true, -- If you want to return the item to the player after picking up the smelter
}
},
}
}
Opensource files
--[[
BY RX Scripts Š rxscripts.xyz
--]]
function GetPlacingSmelterCoords(cfgSmelterKey)
local smelter = Config.Smelters[cfgSmelterKey]
local prop = smelter.prop
local coords = GetEntityCoords(PlayerPedId())
local forward = GetEntityForwardVector(PlayerPedId())
coords = (coords + forward) - vector3(0, 0, 1)
local heading = GetEntityHeading(PlayerPedId())
return coords, heading
end
function Notify(msg, type)
if Core == 'ESX' then
CoreObj.ShowNotification(msg, type)
elseif Core == 'QB' then
CoreObj.Functions.Notify(msg, type)
end
end
function InitSmelter(smelter)
local smelterSettings = Config.Smelters[smelter]
if Target == 'OX' then
exports.ox_target:addModel(smelterSettings.prop, {
{
name = "Open "..smelterSettings.label,
label = string.format(Locales['open_label'], smelterSettings.label),
icon = "fas fa-fire-flame-curved",
iconColor = "orange",
distance = 2.5,
onSelect = function(data)
local obj = GetClosestObjectOfType(data.coords, data.distance + 1.0, GetHashKey(smelterSettings.prop), false, false, false)
if obj == 0 then
obj = GetClosestObjectOfType(data.coords, data.distance + 1.0, GetHashKey(smelterSettings.prop), true, false, false)
end
if obj then
OpenSmelter(smelter, GetEntityCoords(obj))
end
end,
},
})
elseif Target == 'QB' then
exports['qb-target']:AddTargetModel(smelterSettings.prop, {
options = {
{
num = 1,
event = "smelters:openSmelter",
icon = "fas fa-fire-flame-curved",
label = string.format(Locales['open_label'], smelterSettings.label),
action = function(entity)
OpenSmelter(smelter, GetEntityCoords(entity))
end
},
},
distance = 2.5
})
end
end
function InitPickupSmelterTarget(key, smelter, entity)
if Target == 'OX' then
exports.ox_target:addLocalEntity(entity, {
{
name = "Pick up "..smelter.label,
label = "Pick up "..smelter.label,
icon = "fas fa-fire-flame-curved",
iconColor = "orange",
distance = 2.5,
onSelect = function()
PickupSmelter(key, smelter.label)
end,
},
})
elseif Target == 'QB' then
exports['qb-target']:AddTargetEntity(entity, {
options = {
{
icon = "fas fa-fire-flame-curved",
label = "Pick up "..smelter.label,
action = function()
PickupSmelter(key, smelter.label)
end
},
},
distance = 2.5
})
end
end
--[[
BY RX Scripts Š rxscripts.xyz
--]]
function GetPlayerFromSrc(src)
if Core == 'ESX' then
return CoreObj.GetPlayerFromId(src)
elseif Core == 'QB' then
return CoreObj.Functions.GetPlayer(src)
end
return nil
end
function GetIdentifier(src)
local player = GetPlayerFromSrc(src)
if player then
if Core == 'ESX' then
return player.getIdentifier()
elseif Core == 'QB' then
return player.PlayerData.citizenid
end
end
return nil
end
function GetItemLabel(item)
if Core == 'ESX' then
return CoreObj.GetItemLabel(item)
elseif Core == 'QB' then
return CoreObj.Shared.Items[item].label
end
end
function RemoveItemFromPlayer(src, item, amount)
local player = GetPlayerFromSrc(src)
if player then
if Core == 'ESX' then
player.removeInventoryItem(item, amount)
elseif Core == 'QB' then
player.Functions.RemoveItem(item, amount)
end
end
end
function AddItemToPlayer(src, item, amount)
local player = GetPlayerFromSrc(src)
if player then
if Core == 'ESX' then
if not player.canCarryItem(item, amount) then return false end
player.addInventoryItem(item, amount)
return true
elseif Core == 'QB' then
return player.Functions.AddItem(item, amount)
end
end
end
function GetInventoryItem(src, item)
local player = GetPlayerFromSrc(src)
if player then
if Core == 'ESX' then
return player.getInventoryItem(item)
elseif Core == 'QB' then
return player.Functions.GetItemByName(item)
end
end
return nil
end
function GetInventoryItemCount(src, item)
item = GetInventoryItem(src, item)
if item then
if Core == 'ESX' then
return item.count
elseif Core == 'QB' then
return item.amount
end
end
return 0
end
function Notify(src, msg, type)
if Core == 'ESX' then
TriggerClientEvent('esx:showNotification', src, msg, type)
elseif Core == 'QB' then
TriggerClientEvent('QBCore:Notify', src, msg, type)
end
end
function RegisterUsableItem(item, cb)
if Core == 'ESX' then
CoreObj.RegisterUsableItem(item, cb)
elseif Core == 'QB' then
CoreObj.Functions.CreateUseableItem(item, cb)
end
end
```
Last updated