0.0.1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
local moduleType = "stash" -- Module category
|
||||
local moduleName = "default" -- THIS module name
|
||||
|
||||
-- Don't touch, required to appear in in-game settings
|
||||
Integrations.modules = Integrations.modules or {}
|
||||
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
|
||||
table.insert(Integrations.modules[moduleType], moduleName)
|
||||
@@ -0,0 +1,18 @@
|
||||
local moduleType = "stash" -- Module category
|
||||
local moduleName = "hc_inventory" -- THIS module name
|
||||
|
||||
-- Don't touch, required to appear in in-game settings
|
||||
Integrations.modules = Integrations.modules or {}
|
||||
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
|
||||
Integrations[moduleType] = Integrations[moduleType] or {}
|
||||
Integrations[moduleType][moduleName] = {}
|
||||
table.insert(Integrations.modules[moduleType], moduleName)
|
||||
|
||||
--[[ You can edit below here ]]
|
||||
Integrations[moduleType][moduleName].open =
|
||||
function(type, markerId)
|
||||
local id = type .. "_" .. markerId
|
||||
TriggerServerEvent(
|
||||
Utils.eventsPrefix .. ":hc_inventory:server:stashNew", id)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
local info = {
|
||||
maxweight = 1000000,
|
||||
slots = 50
|
||||
-- label = "Stash" -- Uncomment this line if you want a fixed label
|
||||
}
|
||||
|
||||
-- hc_inventory requirement for stash
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":hc_inventory:server:stashNew",
|
||||
function(stashId)
|
||||
local playerId = source
|
||||
local scriptName = Utils.getScriptName("hc_inventory")
|
||||
exports[scriptName]:openExternalStash(playerId, stashId, info)
|
||||
end)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
local moduleType = "stash" -- Module category
|
||||
local moduleName = "jaksam_inventory" -- THIS module name
|
||||
|
||||
-- Don't touch, required to appear in in-game settings
|
||||
Integrations.modules = Integrations.modules or {}
|
||||
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
|
||||
Integrations[moduleType] = Integrations[moduleType] or {}
|
||||
Integrations[moduleType][moduleName] = {}
|
||||
table.insert(Integrations.modules[moduleType], moduleName)
|
||||
|
||||
--[[ You can edit below here ]]
|
||||
Integrations[moduleType][moduleName].open = function(type, markerId)
|
||||
local id = "job_stash_" .. markerId
|
||||
exports['jaksam_inventory']:openInventory(id)
|
||||
end
|
||||
@@ -0,0 +1,66 @@
|
||||
--[[ You can edit below here ]]
|
||||
local STASH_CONFIG = {
|
||||
slots = 50,
|
||||
weight = 100000,
|
||||
}
|
||||
|
||||
local function extractAllowedJobsFromMarker(marker)
|
||||
if marker.job_name == "public_marker" then return nil end
|
||||
|
||||
if marker.grades_type == "minimumGrade" then
|
||||
return { [marker.job_name] = marker.min_grade }
|
||||
end
|
||||
|
||||
local minGrade = math.huge
|
||||
local grades = json.decode(marker.specific_grades)
|
||||
|
||||
for gradeId, _ in pairs(grades) do
|
||||
gradeId = tonumber(gradeId)
|
||||
|
||||
minGrade = math.min(minGrade, gradeId)
|
||||
end
|
||||
|
||||
if minGrade == math.huge then
|
||||
minGrade = 0
|
||||
end
|
||||
|
||||
return { [marker.job_name] = minGrade }
|
||||
end
|
||||
|
||||
local function isMarkerDifferentForEachPlayer(marker)
|
||||
local markerData = json.decode(marker.data)
|
||||
if marker.type ~= "armory" then return false end
|
||||
|
||||
return markerData?.isShared and true or false
|
||||
end
|
||||
|
||||
local function registerStashes()
|
||||
if(config.modules.stash ~= "jaksam_inventory") then return end
|
||||
|
||||
local scriptName = "jaksam_inventory"
|
||||
|
||||
local results = MySQL.Sync.fetchAll('SELECT id, job_name, type, coords, label, grades_type, specific_grades, min_grade, data FROM jobs_data WHERE type="stash" OR type="safe" OR type="armory"')
|
||||
for i=1, #results do
|
||||
local currentMarker = results[i]
|
||||
local stashId = "job_stash_" .. currentMarker.id
|
||||
local coords = vecFromTable(json.decode(currentMarker.coords) or {})
|
||||
local jobs = extractAllowedJobsFromMarker(currentMarker)
|
||||
|
||||
local stash = {
|
||||
id = stashId,
|
||||
label = currentMarker.label,
|
||||
maxSlots = STASH_CONFIG.slots,
|
||||
maxWeight = STASH_CONFIG.weight,
|
||||
isPrivate = isMarkerDifferentForEachPlayer(currentMarker),
|
||||
coords = vecFromTable(coords),
|
||||
allowedJobs = jobs,
|
||||
}
|
||||
|
||||
exports[scriptName]:registerStash(stash)
|
||||
end
|
||||
|
||||
print("^2" .. #results .. " jaksam_inventory stashes registered^7")
|
||||
end
|
||||
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":refreshMarkers", registerStashes)
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":serverConfigLoadedOnStart", registerStashes)
|
||||
@@ -0,0 +1,17 @@
|
||||
local moduleType = "stash" -- Module category
|
||||
local moduleName = "ox_inventory" -- THIS module name
|
||||
|
||||
-- Don't touch, required to appear in in-game settings
|
||||
Integrations.modules = Integrations.modules or {}
|
||||
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
|
||||
Integrations[moduleType] = Integrations[moduleType] or {}
|
||||
Integrations[moduleType][moduleName] = {}
|
||||
table.insert(Integrations.modules[moduleType], moduleName)
|
||||
|
||||
local scriptName = Utils.getScriptName("ox_inventory") -- DO NOT EDIT! If you want to edit the name, you can do it in-game
|
||||
|
||||
--[[ You can edit below here ]]
|
||||
Integrations[moduleType][moduleName].open = function(type, markerId)
|
||||
local id = "job_stash_" .. markerId
|
||||
exports[scriptName]:openInventory('stash', id)
|
||||
end
|
||||
@@ -0,0 +1,56 @@
|
||||
--[[ You can edit below here ]]
|
||||
local STASH_CONFIG = {
|
||||
slots = 50,
|
||||
weight = 100000,
|
||||
}
|
||||
|
||||
local function extractAllowedJobsFromMarker(marker)
|
||||
if marker.job_name == "public_marker" then return nil end
|
||||
|
||||
if marker.grades_type == "minimumGrade" then
|
||||
return { [marker.job_name] = marker.min_grade }
|
||||
end
|
||||
|
||||
local minGrade = math.huge
|
||||
local grades = json.decode(marker.specific_grades)
|
||||
|
||||
for gradeId, _ in pairs(grades) do
|
||||
gradeId = tonumber(gradeId)
|
||||
|
||||
minGrade = math.min(minGrade, gradeId)
|
||||
end
|
||||
|
||||
if minGrade == math.huge then
|
||||
minGrade = 0
|
||||
end
|
||||
|
||||
return { [marker.job_name] = minGrade }
|
||||
end
|
||||
|
||||
local function isMarkerDifferentForEachPlayer(marker)
|
||||
local markerData = json.decode(marker.data)
|
||||
if marker.type ~= "armory" then return false end
|
||||
|
||||
return markerData?.isShared and true or false
|
||||
end
|
||||
|
||||
local function registerStashes()
|
||||
if(config.modules.stash ~= "ox_inventory") then return end
|
||||
|
||||
local scriptName = Utils.getScriptName("ox_inventory") -- DO NOT EDIT! If you want to edit the name, you can do it in-game
|
||||
|
||||
local results = MySQL.Sync.fetchAll('SELECT id, job_name, type, coords, label, grades_type, specific_grades, min_grade, data FROM jobs_data WHERE type="stash" OR type="safe" OR type="armory"')
|
||||
for i=1, #results do
|
||||
local currentMarker = results[i]
|
||||
local stashId = "job_stash_" .. currentMarker.id
|
||||
local coords = vecFromTable(json.decode(currentMarker.coords) or {})
|
||||
local jobs = extractAllowedJobsFromMarker(currentMarker)
|
||||
|
||||
exports[scriptName]:RegisterStash(stashId, currentMarker.label, STASH_CONFIG.slots, STASH_CONFIG.weight, isMarkerDifferentForEachPlayer(currentMarker), jobs, vecFromTable(coords))
|
||||
end
|
||||
|
||||
print("^2" .. #results .. " OX stashes registered^7")
|
||||
end
|
||||
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":refreshMarkers", registerStashes)
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":serverConfigLoadedOnStart", registerStashes)
|
||||
@@ -0,0 +1,15 @@
|
||||
local moduleType = "stash" -- Module category
|
||||
local moduleName = "qb-inventory" -- THIS module name
|
||||
|
||||
-- Don't touch, required to appear in in-game settings
|
||||
Integrations.modules = Integrations.modules or {}
|
||||
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
|
||||
Integrations[moduleType] = Integrations[moduleType] or {}
|
||||
Integrations[moduleType][moduleName] = {}
|
||||
table.insert(Integrations.modules[moduleType], moduleName)
|
||||
|
||||
--[[ You can edit below here ]]
|
||||
Integrations[moduleType][moduleName].open = function(type, markerId)
|
||||
local id = type .. "_" .. markerId
|
||||
TriggerServerEvent(Utils.eventsPrefix .. ":qb-inventory:server:stashNew", id)
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
local info = {
|
||||
maxweight = 1000000,
|
||||
slots = 50,
|
||||
--label = "Stash" -- Uncomment this line if you want a fixed label
|
||||
}
|
||||
|
||||
-- New qb-inventory requirement for stash
|
||||
RegisterNetEvent(Utils.eventsPrefix .. ":qb-inventory:server:stashNew", function(stashId)
|
||||
local playerId = source
|
||||
local scriptName = Utils.getScriptName("qb-inventory") -- DO NOT EDIT! If you want to edit the name, you can do it in-game
|
||||
exports[scriptName]:OpenInventory(playerId, stashId, info)
|
||||
end)
|
||||
Reference in New Issue
Block a user