đConfigurables
--[[
BY RX Scripts Š rxscripts.xyz
--]]
Config.SearchAnim = {
dict = "mini@repair",
anim = "fixing_a_player",
}
Config.LockItem = 'codelock'
Config.LockProp = 'codelock'
Config.StorageCrates = {
{
label = 'Wooden Storage Big',
prop = "boxonebig",
placeItem = "boxonebig",
slots = 12,
icon = "fas fa-box-open",
iconColor = "#ff0000",
},
{
label = 'Wooden Storage Small',
prop = "boxonesmall",
placeItem = "boxonesmall",
slots = 6,
icon = "fas fa-box-open",
iconColor = "#ff0000",
},
{
label = 'Wooden Storage Small',
prop = "boxtwosmall",
placeItem = "boxtwosmall",
slots = 6,
icon = "fas fa-box-open",
iconColor = "#ff0000",
},
{
label = 'Wooden Storage Big',
prop = "boxtwobig",
placeItem = "boxtwobig",
slots = 12,
icon = "fas fa-box-open",
iconColor = "#ff0000",
},
{
label = 'Wooden Storage Big',
prop = "boxtreebig",
placeItem = "boxtreebig",
slots = 12,
icon = "fas fa-box-open",
iconColor = "#ff0000",
},
}
Config.StorageStackLimits = {
['WEAPON_ASSAULTRIFLE'] = 1,
}
Config.RespawnCrates = {
{
label = 'Supply Crate',
prop = "boxcrate",
locations = {
vector4(3053.4177, -4725.9736, 15.2616, 18.8735),
vector4(3046.7397, -4727.8799, 15.2613, 45.3019),
},
spawning = {
limit = 1, -- How many crates can be spawned at once from locations above
different = false, -- If true, will spawn on different location then previous
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 1, -- Minutes, set to false to disable
spawnDirect = false, -- Spawn crate directly after script start
hacking = {
enabled = true,
time = 1, -- Minutes
minigame = true,
item = 'redkeycard', -- false to disable
removeItem = true, -- Remove item from player after hacking
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 20 },
{ item = 'at_flashlight', amount = 1, chance = 30 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'armour', amount = 1, chance = 20 },
}
},
blip = { -- Remove this if u don't want a blip on crate spawn
sprite = 478,
color = 1,
display = 4,
scale = 1.0,
shortRange = true,
label = 'Supply Crate',
}
},
{
label = 'Ammo Crate',
prop = "crateammo",
locations = {
vector4(3046.7034, -4706.5747, 15.2616, 288.2096),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 1, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = true,
time = 1, -- Minutes
minigame = true,
item = 'bluekeycard', -- Set to false to disable
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 25 },
{ item = 'ammo-shotgun', amount = function() return math.random(20, 50) end, chance = 25 },
{ item = 'ammo-9', amount = function() return math.random(20, 50) end, chance = 25 },
{ item = 'ammo-musket', amount = function() return math.random(20, 50) end, chance = 25 },
}
}
},
{
label = 'Bomb Crate',
prop = "cratec4",
locations = {
vector4(3047.8506, -4709.7803, 15.2616, 281.4715),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = true,
time = 5, -- Minutes
minigame = false,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 3 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 8 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'water', amount = function() return math.random(3, 10) end, chance = 59 },
}
}
},
{
label = 'Basic Crate',
prop = "lootcratebasic",
locations = {
vector4(3049.0000, -4713.0693, 15.2616, 287.8040),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = false,
time = 15, -- Minutes
minigame = true,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 3 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 8 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'water', amount = function() return math.random(3, 10) end, chance = 59 },
}
},
blip = { -- remove this if u don't want a blip on crate spawn
sprite = 478,
color = 1,
display = 4,
scale = 1.0,
shortRange = true,
label = 'Basic Crate',
}
},
{
label = 'Food Crate',
prop = "lootcratefood",
locations = {
vector4(3050.1790, -4716.1348, 15.2616, 270.5500),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = false,
time = 15, -- Minutes
minigame = true,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 3 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 8 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'water', amount = function() return math.random(3, 10) end, chance = 59 },
}
}
},
{
label = 'Medical Crate',
prop = "lootcratemedi",
locations = {
vector4(3051.3313, -4718.6816, 15.2616, 249.9581),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = false,
time = 15, -- Minutes
minigame = true,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 3 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 8 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'water', amount = function() return math.random(3, 10) end, chance = 59 },
}
}
},
{
label = 'Elite Crate',
prop = "crateelite",
locations = {
vector4(3052.4419, -4721.6367, 15.2616, 110.0965),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = false,
time = 15, -- Minutes
minigame = true,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 5 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 10 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 25 },
{ item = 'ammo-shotgun', amount = function() return math.random(20, 50) end, chance = 25 },
{ item = 'ammo-9', amount = function() return math.random(20, 50) end, chance = 20 },
{ item = 'ammo-musket', amount = function() return math.random(20, 50) end, chance = 15 },
}
}
},
{
label = 'Military Crate',
prop = "militarycrates",
locations = {
vector4(3050.1714, -4726.9888, 15.2614, 18.4443),
},
slots = 12,
icon = "fas fa-box-open", -- https://fontawesome.com/icons
iconColor = "#ff0000",
respawnTime = 30, -- Minutes, set to false to disable
spawnDirect = true, -- Spawn crate directly after script start
hacking = {
enabled = false,
time = 15, -- Minutes
minigame = true,
item = false,
},
contents = {
itemsAmount = function() return math.random(3, 6) end,
lootables = { -- Make sure all chances add up to 100
{ item = 'WEAPON_ASSAULTRIFLE', amount = 1, chance = 3 },
{ item = 'WEAPON_PISTOL', amount = 1, chance = 8 },
{ item = 'ammo-rifle2', amount = function() return math.random(20, 50) end, chance = 30 },
{ item = 'water', amount = function() return math.random(3, 10) end, chance = 59 },
}
}
},
}
--[[
BY RX Scripts Š rxscripts.xyz
--]]
-- return true if minigame has been succeeded, false if not
function HackMinigame(crate)
return lib.skillCheck({'easy', 'easy', 'easy'}, {'w', 'a', 's', 'd'})
-- local returnable = nil
-- TriggerEvent("mhacking:show")
-- TriggerEvent("mhacking:start", 7, 35, function(success, timeremaining)
-- if success then
-- returnable = true
-- else
-- returnable = false
-- end
-- TriggerEvent("mhacking:hide")
-- end)
-- while returnable == nil do
-- Wait(0)
-- end
-- return returnable
end
function InitCrateTarget(entity, key, crate)
if Target == 'OX' then
exports.ox_target:addLocalEntity(entity, {
{
name = 'opencrate',
label = 'Open '..crate.label,
icon = crate.icon,
iconColor = crate.iconColor,
distance = 2.5,
canInteract = function()
if crate.hacking and crate.hacking.enabled then
return Crates[key].hacked
else
return true
end
end,
onSelect = function(data)
OpenCrate(key, crate, entity, false)
end
},
{
name = 'pickupstorage',
label = 'Pickup '..crate.label,
icon = crate.icon,
iconColor = crate.iconColor,
distance = 2.5,
canInteract = function()
return crate.storage
end,
onSelect = function(data)
PickupStorage(key, crate)
end
},
{
name = 'hackcrate',
label = 'Hack '..crate.label,
icon = "fas fa-laptop",
iconColor = "#f3f315",
distance = 2.5,
canInteract = function()
if crate.hacking and crate.hacking.enabled and Crates[key].hackTimeLeft == nil then
return not Crates[key].hacked
else
return false
end
end,
onSelect = function(data)
HackCrate(key, crate, entity)
end
},
{
name = 'addlock',
label = 'Add Lock',
icon = "fas fa-lock",
iconColor = "#3f3f3f",
distance = 2.5,
canInteract = function()
if crate.storage and not crate.lock and HasItem(Config.LockItem) then
return true
else
return false
end
end,
onSelect = function(data)
AddLock(key)
end
},
{
name = 'removelock',
label = 'Remove Lock',
icon = "fas fa-lock-open",
iconColor = "#3f3f3f",
distance = 2.5,
canInteract = function()
if crate.storage and crate.lock then
return true
else
return false
end
end,
onSelect = function()
RemoveLock(key, crate)
end,
}
})
elseif Target == 'QB' then
exports['qb-target']:AddTargetEntity(entity, {
options = {
{
num = 1,
label = 'Open '..crate.label,
icon = crate.icon,
targeticon = crate.icon,
canInteract = function()
if crate.hacking and crate.hacking.enabled then
return Crates[key].hacked
else
return true
end
end,
action = function()
OpenCrate(key, crate, entity, false)
end
},
{
num = 2,
label = 'Pickup '..crate.label,
icon = crate.icon,
targeticon = crate.icon,
canInteract = function()
return crate.storage
end,
action = function()
PickupStorage(key, crate)
end
},
{
num = 3,
label = 'Hack '..crate.label,
icon = "fas fa-laptop",
targeticon = "fas fa-laptop",
canInteract = function()
if crate.hacking and crate.hacking.enabled and Crates[key].hackTimeLeft == nil then
return not Crates[key].hacked
else
return false
end
end,
action = function()
HackCrate(key, crate, entity)
end
},
{
num = 4,
label = 'Add Lock',
icon = "fas fa-lock",
targeticon = "fas fa-lock",
canInteract = function()
if crate.storage and not crate.lock and HasItem(Config.LockItem) then
return true
else
return false
end
end,
action = function()
AddLock(key)
end
},
{
num = 5,
label = 'Remove Lock',
icon = "fas fa-lock-open",
targeticon = "fas fa-lock-open",
canInteract = function()
if crate.storage and crate.lock then
return true
else
return false
end
end,
action = function()
RemoveLock(key, crate)
end
}
},
distance = 2.5,
})
end
end
FM = exports['fmLib']:new()
---@return string | nil
function InitLockDialog(correctPin)
local opts = {
title = 'Code Lock',
subtitle = 'Enter the lock code.',
maxNumbers = 4,
hidden = true,
}
if correctPin then
opts.reactiveUI = {
correctPin = correctPin,
}
end
local pin = FM.pin.open(opts)
-- local input = lib.inputDialog('Insert Code', {
-- {
-- type = 'slider',
-- label = 'Number 1',
-- icon = 'lock',
-- required = true,
-- default = 0,
-- min = 0,
-- max = 9,
-- step = 1,
-- },
-- {
-- type = 'slider',
-- label = 'Number 2',
-- icon = 'lock',
-- required = true,
-- default = 0,
-- min = 0,
-- max = 9,
-- step = 1,
-- },
-- {
-- type = 'slider',
-- label = 'Number 3',
-- icon = 'lock',
-- required = true,
-- default = 0,
-- min = 0,
-- max = 9,
-- step = 1,
-- },
-- {
-- type = 'slider',
-- label = 'Number 4',
-- icon = 'lock',
-- required = true,
-- default = 0,
-- min = 0,
-- max = 9,
-- step = 1,
-- }
-- })
-- if input then
-- return input[1] .. input[2] .. input[3] .. input[4]
-- end
return pin
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 HasItem(item)
if Core == 'ESX' then
return CoreObj.SearchInventory(item, 1) > 0
elseif Core == 'QB' then
return CoreObj.Functions.HasItem(item)
end
return false
end
function OpenStash(stashId, slots)
if OXINV then
OXINV:openInventory('stash', stashId)
elseif QBInv or QSInv or PSInv then
TriggerServerEvent('inventory:server:OpenInventory', 'stash', stashId, {
maxweight = 100,
slots = slots,
})
TriggerEvent('inventory:client:SetCurrentStash', stashId)
else
Error("No inventory found for opening stash (client/opensource.lua:OpenStash)")
end
end
RegisterNetEvent('crates:onCrateOpened', function(crate, data)
-- Here you can do something when a crate is opened
end)
--[[
BY RX Scripts Š rxscripts.xyz
--]]
function CanStorageBePlaced(src, crate, coords)
-- Here you can customize a check before the storage is placed to see if the player is allowed to place it
return true
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 GetPlayerFromId(src)
local player = nil
if Core == 'ESX' then
player = CoreObj.GetPlayerFromId(src)
elseif Core == 'QB' then
player = CoreObj.Functions.GetPlayer(src)
else
-- Your own player system
end
return player
end
function AddInventoryItem(src, item, count)
if Core == 'ESX' then
GetPlayerFromId(src).addInventoryItem(item, count)
elseif Core == 'QB' then
GetPlayerFromId(src).Functions.AddItem(item, count)
else
-- Your own inventory system
end
end
function RemoveInventoryItem(src, item, count)
if Core == 'ESX' then
GetPlayerFromId(src).removeInventoryItem(item, count)
elseif Core == 'QB' then
GetPlayerFromId(src).Functions.RemoveItem(item, count)
else
-- Your own inventory system
end
end
function GetInventoryItems(src)
local inventory = {}
local player = GetPlayerFromId(src)
if Core == 'ESX' then
local items = player.getInventory()
for k, v in pairs(items) do
inventory[v.name] = {
amount = v.count,
label = v.label,
}
end
elseif Core == 'QB' then
local items = player.PlayerData.items
for k, v in pairs(items) do
inventory[v.name] = {
amount = v.amount,
label = v.label,
}
end
else
-- Your own inventory system
end
return inventory
end
function HasItem(src, item, amount)
local player = GetPlayerFromId(src)
local hasItem = false
if Core == 'ESX' then
hasItem = player.getInventoryItem(item).count >= amount
elseif Core == 'QB' then
hasItem = player.Functions.GetItemByName(item).amount >= amount
else
-- Your own inventory system
end
return hasItem
end
function GetItemLabel(item)
local label = nil
if Core == 'ESX' then
label = CoreObj.GetItemLabel(item)
elseif Core == 'QB' then
if not CoreObj.Shared.Items[item] then print('Invalid Item: ' .. item) return 'Invalid Item' end
label = CoreObj.Shared.Items[item].label
else
-- Your own inventory system
end
return label
end
function GetPlayerName(src)
local name = nil
if Core == 'ESX' then
name = GetPlayerFromId(src).name
elseif Core == 'QB' then
name = GetPlayerFromId(src).PlayerData.charinfo.firstname .. ' ' .. GetPlayerFromId(src).PlayerData.charinfo.lastname
else
--
end
return name
end
function CanCarryItem(src, item, amount)
if OXINV then
return OXINV:CanCarryItem(src, item, amount)
elseif Core == 'ESX' then
return GetPlayerFromId(src).canCarryItem(item, amount)
end
return true
end
function RegisterStash(storage)
if OXINV then
OXINV:ClearInventory('rxstorage-'..storage.key)
OXINV:RegisterStash('rxstorage-'..storage.key, storage.label, storage.slots, 100, nil, false)
elseif not QBInv and not QSInv and not PSInv then
Error("No inventory found for registering stash (server/opensource.lua:134)")
end
end
Last updated