fix(qb-core): post-update recovery + centralizare notify 17mov_Hud
Restaurat jobs.lua din git (Quasar fork a suprascris joburile 17mov). Adăugat item map în items.lua (lipsea, rupt rv-maphold). Setat licences.driver = false în config.lua. Override QBCore.Functions.Notify + QBCore:Notify event → 17mov_Hud:ShowNotification (toate notificările merg automat prin 17mov_Hud).
This commit is contained in:
Binary file not shown.
@@ -6,12 +6,19 @@
|
||||
|
||||
-- Add car keys
|
||||
function WSB.giveCarKeys(plate, _model, _vehicle)
|
||||
exports['qs-vehiclekeys']:GiveKeys(plate, _model, true)
|
||||
if GetResourceState('wasabi_carlock') == 'started' then
|
||||
return exports.wasabi_carlock:GiveKey(plate) -- Leave like this if using wasabi_carlock
|
||||
end
|
||||
|
||||
if GetResourceState('qb-vehiclekeys') == 'started' then
|
||||
return TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
|
||||
end
|
||||
end
|
||||
|
||||
function WSB.removeCarKeys(plate, _model, _vehicle)
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, _model)
|
||||
if GetResourceState('wasabi_carlock') == 'started' then
|
||||
return exports.wasabi_carlock:RemoveKey(plate)
|
||||
end
|
||||
end
|
||||
|
||||
exports('giveCarKeys', WSB.giveCarKeys) -- Export for use in other scripts
|
||||
|
||||
@@ -12,11 +12,57 @@ if wasabi_uikit == 'started' or wasabi_uikit == 'starting' then uikitFound = tru
|
||||
|
||||
-- Notifications
|
||||
function WSB.showNotification(title, desc, style, icon, id)
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local message = desc and (title .. ' - ' .. desc) or title
|
||||
local notifyType = style or 'primary'
|
||||
|
||||
QBCore.Functions.Notify(message, notifyType)
|
||||
-- Edit code below to use your own notification system
|
||||
|
||||
-- (This supports wasabi_notify, bridge's built-in notify, and ox_lib is commented out if desired!)
|
||||
-- Get wasabi_notify here: https://wasabiscripts.com/product/6215100
|
||||
|
||||
if GetResourceState('wasabi_notify') == 'started' then -- If using wasabi_notify, automatic detection
|
||||
if style == 'inform' or style == 'primary' then style = 'info' end
|
||||
|
||||
return exports.wasabi_notify:notify(title, desc, Config.Notifications.defaults.time or 3500, style or 'info',
|
||||
Config.NotificationSound or Config.Notifications.defaults.sound or false, icon, id)
|
||||
end
|
||||
|
||||
if uikitFound then
|
||||
return exports.wasabi_uikit:Notification(title, desc, style or 'info', id, icon)
|
||||
end
|
||||
|
||||
--[[ Remove this line if you are using lation_ui: https://lationscripts.com/product/modern-ui
|
||||
if GetResourceState('lation_ui') == 'started' then -- If using lation_ui and not wasabi_notify automatic detection
|
||||
if style == 'inform' or style == 'primary' then style = 'info' end
|
||||
|
||||
return exports.lation_ui:notify({
|
||||
title = title,
|
||||
message = desc or nil,
|
||||
id = id or nil,
|
||||
position = 'top-right',
|
||||
icon = icon or nil,
|
||||
duration = 3500,
|
||||
type = style or 'info'
|
||||
})
|
||||
end
|
||||
]] -- Remove this line if you are using lation_ui
|
||||
|
||||
--[[
|
||||
if GetResourceState('ox_lib') == 'started' then -- If using ox_lib and not wasabi_notfy automatic detection
|
||||
if style == 'info' then style = 'inform' end
|
||||
exports.ox_lib:notify({
|
||||
title = title,
|
||||
description = desc or false,
|
||||
id = id or false,
|
||||
position = 'top-right',
|
||||
icon = icon or false,
|
||||
duration = 3500,
|
||||
type = style or 'inform'
|
||||
})
|
||||
return
|
||||
end
|
||||
]] --
|
||||
|
||||
return ShowNotification(title, desc, style, icon, id) -- Default bridge built-in notification system
|
||||
|
||||
-- Edit Code above to use your own notification system
|
||||
end
|
||||
|
||||
RegisterNetEvent('wasabi_bridge:notify', function(title, desc, style, icon, id)
|
||||
|
||||
@@ -15,25 +15,38 @@ if wasabi_uikit == 'started' or wasabi_uikit == 'starting' then uikitFound = tru
|
||||
---@param data table Same data as used in ox_lib progress bar/circle. Subject to change.
|
||||
---@return boolean
|
||||
function WSB.progressUI(data, type)
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local success = false
|
||||
|
||||
QBCore.Functions.Progressbar(data.name or 'progress', data.label or 'Loading...', data.duration or 5000, data.useWhileDead or false, data.canCancel or false, {
|
||||
disableMovement = data.disable and data.disable.move or false,
|
||||
disableCarMovement = data.disable and data.disable.car or false,
|
||||
disableMouse = data.disable and data.disable.mouse or false,
|
||||
disableCombat = data.disable and data.disable.combat or false,
|
||||
}, data.anim or {}, data.prop or {}, data.propTwo or {}, function()
|
||||
success = true
|
||||
end, function()
|
||||
success = false
|
||||
end)
|
||||
|
||||
while success == false do
|
||||
Wait(100)
|
||||
|
||||
-- Remove under this line to use your own progress bar/circle system or ox_lib
|
||||
if not data.color then data.color = Config.DefaultColor end
|
||||
if uikitFound then
|
||||
type = type == 'progressCircle' and 'circle' or 'bar'
|
||||
return exports.wasabi_uikit:ProgressBar(data, type) or false
|
||||
end
|
||||
|
||||
return success
|
||||
return ProgressUI(data, type) or false
|
||||
-- Remove above this line if you are using your own progress bar/circle system or ox_lib
|
||||
|
||||
--[[ Remove this line if you are using lation_ui: https://lationscripts.com/product/modern-ui
|
||||
local lation_ui = GetResourceState('lation_ui')
|
||||
if lation_ui ~= 'started' and lation_ui ~= 'starting' then
|
||||
print('^0[^3WARNING^0] ^1lation_ui^0 is not running, please ensure it is started before using ^wsb.progressUI or use default!^0')
|
||||
return false
|
||||
end
|
||||
return exports.lation_ui:progressBar(data)
|
||||
]] -- Remove this line if you are using lation_ui
|
||||
|
||||
--[[
|
||||
local oxLib = GetResourceState('ox_lib')
|
||||
if oxLib ~= 'started' and oxLib ~= 'starting' then
|
||||
print(
|
||||
'^0[^3WARNING^0] ^1ox_lib^0 is not running, please ensure it is started before using ^wsb.progressUI or use default!^0')
|
||||
return false
|
||||
end
|
||||
if type == 'progressBar' then
|
||||
return exports.ox_lib:progressBar(data)
|
||||
else
|
||||
return exports.ox_lib:progressCircle(data)
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
-- Compatibility functions for ox_lib
|
||||
|
||||
@@ -40,7 +40,7 @@ function WSB.skillCheck(data)
|
||||
if not data.keys then data.keys = 'e' end
|
||||
|
||||
if uikitFound then
|
||||
return exports.wasabi_uikit:SkillCircle(data.difficulty, type(data.keys) == 'table' and data.keys or {data.keys}) or false
|
||||
return exports.wasabi_uikit:SkillCircle({data.difficulty}, type(data.keys) == 'table' and data.keys or {data.keys}) or false
|
||||
end
|
||||
|
||||
return SkillCheck(data.difficulty, data.keys, data.color) or false
|
||||
|
||||
@@ -14,16 +14,88 @@ local textUI = false
|
||||
|
||||
-- Show text UI
|
||||
function WSB.showTextUI(msg, options)
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
-- Customize this logic with your own text UI or ox_lib
|
||||
-- msg = string, the message to display
|
||||
-- options = { -- Optional, data to pass to text UI system
|
||||
-- position = string - either 'right-center', 'left-center', 'top-center', or bottom-center,
|
||||
-- icon = string - icon name,
|
||||
-- iconColor = string - icon color,
|
||||
-- textColor = string - text color,
|
||||
-- backgroundColor = string - background color,
|
||||
-- iconAnimation = 'pulse', -- currently only pusle available
|
||||
-- }
|
||||
|
||||
-- Remove under this to use your own text UI --
|
||||
textUI = msg
|
||||
exports["17mov_Hud"]:ShowHelpNotification(msg)
|
||||
if uikitFound then
|
||||
-- Function to extract a single key in the format [E] - Text or [E] Text
|
||||
local function extractKeyAndText(str)
|
||||
if type(str) ~= "string" then return nil, str end
|
||||
local key, rest = str:match("^%[([%w])%]%s*%-?%s*(.+)$")
|
||||
if key and rest then
|
||||
return key, rest
|
||||
end
|
||||
return nil, str
|
||||
end
|
||||
local key, text = extractKeyAndText(msg)
|
||||
return exports.wasabi_uikit:OpenTextUI(text, key)
|
||||
end
|
||||
return ShowTextUI(msg, options)
|
||||
-- Remove above this if you are using your own menu system / want to use ox_lib
|
||||
|
||||
--[[ Remove this line if you are using lation_ui: https://lationscripts.com/product/modern-ui
|
||||
local lation_ui = GetResourceState('lation_ui')
|
||||
if lation_ui ~= 'started' and lation_ui ~= 'starting' then
|
||||
print('^0[^3WARNING^0] ^1lation_ui^0 is not running, please ensure it is started before using ^wsb.showTextUI or use default!^0')
|
||||
return
|
||||
end
|
||||
exports.lation_ui:showText({description = msg})
|
||||
textUI = msg
|
||||
]] -- Remove this line if you are using lation_ui
|
||||
|
||||
|
||||
--[[
|
||||
local oxLib = GetResourceState('ox_lib')
|
||||
if oxLib ~= 'started' and oxLib ~= 'starting' then
|
||||
print(
|
||||
'^0[^3WARNING^0] ^1ox_lib^0 is not running, please ensure it is started before using ^wsb.showTextUI or use default!^0')
|
||||
return
|
||||
end
|
||||
exports.ox_lib:showTextUI(msg)
|
||||
textUI = msg
|
||||
]]
|
||||
end
|
||||
|
||||
-- Hide text UI
|
||||
function WSB.hideTextUI()
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
-- Remove under this to use your own text UI --
|
||||
textUI = false
|
||||
exports["17mov_Hud"]:HideHelpNotification()
|
||||
if uikitFound then
|
||||
return exports.wasabi_uikit:CloseTextUI()
|
||||
end
|
||||
return HideTextUI()
|
||||
-- Remove above this if you are using your own menu system / want to use ox_lib
|
||||
|
||||
--[[ Remove this line if you are using lation_ui: https://lationscripts.com/product/modern-ui
|
||||
local lation_ui = GetResourceState('lation_ui')
|
||||
if lation_ui ~= 'started' and lation_ui ~= 'starting' then
|
||||
print('^0[^3WARNING^0] ^1lation_ui^0 is not running, please ensure it is started before using ^wsb.hideTextUI or use default!^0')
|
||||
return
|
||||
end
|
||||
exports.lation_ui:hideText()
|
||||
textUI = false
|
||||
]] -- Remove this line if you are using lation_ui
|
||||
|
||||
--[[
|
||||
local oxLib = GetResourceState('ox_lib')
|
||||
if oxLib ~= 'started' and oxLib ~= 'starting' then
|
||||
print(
|
||||
'^0[^3WARNING^0] ^1ox_lib^0 is not running, please ensure it is started before using ^wsb.showTextUI or use default!^0')
|
||||
return
|
||||
end
|
||||
exports.ox_lib:hideTextUI()
|
||||
textUI = false
|
||||
]]
|
||||
end
|
||||
|
||||
-- Checking for text UI
|
||||
|
||||
@@ -61,39 +61,33 @@ end)
|
||||
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
function WSB.serverCallback(name, cb, ...)
|
||||
Callback(name, false, cb, ...)
|
||||
lib.callback(name, false, cb, ...)
|
||||
end
|
||||
|
||||
function WSB.awaitServerCallback(name, ...)
|
||||
local results = { Callback.awaitResponse(name, false, ...) }
|
||||
return table.unpack(results)
|
||||
return lib.callback.await(name, false, ...)
|
||||
end
|
||||
|
||||
function WSB.registerCallback(name, fn)
|
||||
Callback.register(name, function(source, ...)
|
||||
local responded = false
|
||||
local response = nil
|
||||
|
||||
local cb = function(...)
|
||||
responded = true
|
||||
response = {...}
|
||||
end
|
||||
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
end, ...)
|
||||
|
||||
if responded then
|
||||
return table.unpack(response)
|
||||
elseif ret ~= nil then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
|
||||
if not ok then
|
||||
print(("[wsb] callback %s threw an error: %s"):format(name, ret))
|
||||
end
|
||||
end)
|
||||
end
|
||||
lib.callback.register(name, function(...)
|
||||
local results = nil
|
||||
local cb = function(...)
|
||||
results = {...}
|
||||
end
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(nil, cb, ...))
|
||||
end, ...)
|
||||
if not ok then
|
||||
error(ret)
|
||||
end
|
||||
if results then
|
||||
return table.unpack(results)
|
||||
end
|
||||
if ret and ret.n then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function WSB.hasGroup(filter)
|
||||
if not WSB.playerData or not WSB.playerData.job then return end
|
||||
|
||||
@@ -54,32 +54,26 @@ function WSB.getAllJobs()
|
||||
end
|
||||
|
||||
function WSB.awaitClientCallback(name, source, ...)
|
||||
local results = { Callback.awaitResponse(name, source, ...) }
|
||||
return table.unpack(results)
|
||||
return lib.callback.await(name, source, ...)
|
||||
end
|
||||
|
||||
function WSB.registerCallback(name, fn)
|
||||
Callback.register(name, function(source, ...)
|
||||
local responded = false
|
||||
local response = nil
|
||||
|
||||
lib.callback.register(name, function(source, ...)
|
||||
local results = nil
|
||||
local cb = function(...)
|
||||
responded = true
|
||||
response = {...}
|
||||
results = {...}
|
||||
end
|
||||
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
end, ...)
|
||||
|
||||
if responded then
|
||||
return table.unpack(response)
|
||||
elseif ret ~= nil then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
|
||||
if not ok then
|
||||
print(("[wsb] callback %s threw an error: %s"):format(name, ret))
|
||||
error(ret)
|
||||
end
|
||||
if results then
|
||||
return table.unpack(results)
|
||||
end
|
||||
if ret and ret.n then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -188,10 +182,31 @@ function WSB.getNameFromPlayerObj(player)
|
||||
end
|
||||
|
||||
function WSB.registerUsableItem(item, cb)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
exports['jaksam_inventory']:registerUsableItem(item, cb)
|
||||
return
|
||||
end
|
||||
ESX.RegisterUsableItem(item, cb)
|
||||
end
|
||||
|
||||
function WSB.getPlayerInventory(source)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local inv = exports['jaksam_inventory']:getInventory(source)
|
||||
if not inv or not inv.items then return {} end
|
||||
local cleanedItems, count = {}, 0
|
||||
for _, item in pairs(inv.items) do
|
||||
if item and item.name then
|
||||
count = count + 1
|
||||
cleanedItems[count] = {
|
||||
name = item.name,
|
||||
amount = item.amount or 0,
|
||||
count = item.amount or 0,
|
||||
metadata = item.metadata or {}
|
||||
}
|
||||
end
|
||||
end
|
||||
return cleanedItems
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
local inventory = player.getInventory()
|
||||
@@ -208,6 +223,9 @@ function WSB.getPlayerInventory(source)
|
||||
end
|
||||
|
||||
function WSB.hasItem(source, _item)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
return exports['jaksam_inventory']:getTotalItemAmount(source, _item) or 0
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
|
||||
@@ -226,6 +244,10 @@ function WSB.hasItem(source, _item)
|
||||
end
|
||||
|
||||
function WSB.addItem(source, item, count, slot, metadata)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local ok = exports['jaksam_inventory']:addItem(source, item, count or 1, metadata, slot)
|
||||
return ok
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
if metadata and not WSB.inventory then
|
||||
@@ -236,12 +258,19 @@ function WSB.addItem(source, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
function WSB.addWeapon(source, weapon, ammo)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
return exports['jaksam_inventory']:addItem(source, weapon, 1, nil, nil)
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
player.addWeapon(weapon, ammo)
|
||||
end
|
||||
|
||||
function WSB.removeItem(source, item, count, slot, metadata)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local ok = exports['jaksam_inventory']:removeItem(source, item, count or 1, metadata, slot)
|
||||
return ok
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
player.removeInventoryItem(item, count, metadata, slot)
|
||||
|
||||
@@ -55,40 +55,33 @@ end)
|
||||
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
function WSB.serverCallback(name, cb, ...)
|
||||
Callback(name, false, cb, ...)
|
||||
lib.callback(name, false, cb, ...)
|
||||
end
|
||||
|
||||
|
||||
function WSB.awaitServerCallback(name, ...)
|
||||
local results = { Callback.awaitResponse(name, false, ...) }
|
||||
return table.unpack(results)
|
||||
return lib.callback.await(name, false, ...)
|
||||
end
|
||||
|
||||
function WSB.registerCallback(name, fn)
|
||||
Callback.register(name, function(source, ...)
|
||||
local responded = false
|
||||
local response = nil
|
||||
|
||||
local cb = function(...)
|
||||
responded = true
|
||||
response = {...}
|
||||
end
|
||||
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
end, ...)
|
||||
|
||||
if responded then
|
||||
return table.unpack(response)
|
||||
elseif ret ~= nil then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
|
||||
if not ok then
|
||||
print(("[wsb] callback %s threw an error: %s"):format(name, ret))
|
||||
end
|
||||
end)
|
||||
end
|
||||
lib.callback.register(name, function(...)
|
||||
local results = nil
|
||||
local cb = function(...)
|
||||
results = {...}
|
||||
end
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(nil, cb, ...))
|
||||
end, ...)
|
||||
if not ok then
|
||||
error(ret)
|
||||
end
|
||||
if results then
|
||||
return table.unpack(results)
|
||||
end
|
||||
if ret and ret.n then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- function WSB.awaitServerCallback(name, ...)
|
||||
-- local args = { ... }
|
||||
|
||||
@@ -78,32 +78,26 @@ function WSB.getAllJobs()
|
||||
end
|
||||
|
||||
function WSB.awaitClientCallback(name, source, ...)
|
||||
local results = { Callback.awaitResponse(name, source, ...) }
|
||||
return table.unpack(results)
|
||||
return lib.callback.await(name, source, ...)
|
||||
end
|
||||
|
||||
function WSB.registerCallback(name, fn)
|
||||
Callback.register(name, function(source, ...)
|
||||
local responded = false
|
||||
local response = nil
|
||||
|
||||
lib.callback.register(name, function(source, ...)
|
||||
local results = nil
|
||||
local cb = function(...)
|
||||
responded = true
|
||||
response = {...}
|
||||
results = {...}
|
||||
end
|
||||
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
local ok, ret = pcall(function(...)
|
||||
return table.pack(fn(source, cb, ...))
|
||||
end, ...)
|
||||
|
||||
if responded then
|
||||
return table.unpack(response)
|
||||
elseif ret ~= nil then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
|
||||
if not ok then
|
||||
print(("[wsb] callback %s threw an error: %s"):format(name, ret))
|
||||
error(ret)
|
||||
end
|
||||
if results then
|
||||
return table.unpack(results)
|
||||
end
|
||||
if ret and ret.n then
|
||||
return table.unpack(ret, 1, ret.n)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -236,6 +230,10 @@ function WSB.getNameFromPlayerObj(player)
|
||||
end
|
||||
|
||||
function WSB.registerUsableItem(item, cb)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
exports['jaksam_inventory']:registerUsableItem(item, cb)
|
||||
return
|
||||
end
|
||||
if qboxFound then
|
||||
exports.qbx_core:CreateUseableItem(item, cb)
|
||||
else
|
||||
@@ -244,6 +242,23 @@ function WSB.registerUsableItem(item, cb)
|
||||
end
|
||||
|
||||
function WSB.getPlayerInventory(source)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local inv = exports['jaksam_inventory']:getInventory(source)
|
||||
if not inv or not inv.items then return {} end
|
||||
local cleanedItems, count = {}, 0
|
||||
for _, item in pairs(inv.items) do
|
||||
if item and item.name then
|
||||
count = count + 1
|
||||
cleanedItems[count] = {
|
||||
name = item.name,
|
||||
amount = item.amount or 0,
|
||||
count = item.amount or 0,
|
||||
metadata = item.metadata or {}
|
||||
}
|
||||
end
|
||||
end
|
||||
return cleanedItems
|
||||
end
|
||||
local player = WSB.getPlayer(source)
|
||||
if not player then return end
|
||||
local cleanedItems, count = {}, 0
|
||||
@@ -256,10 +271,12 @@ function WSB.getPlayerInventory(source)
|
||||
end
|
||||
end
|
||||
return cleanedItems or {}
|
||||
|
||||
end
|
||||
|
||||
function WSB.hasItem(source, _item)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
return exports['jaksam_inventory']:getTotalItemAmount(source, _item) or 0
|
||||
end
|
||||
if qboxFound or oxFound then
|
||||
return exports.ox_inventory:GetItem(source, _item, nil, true) or 0
|
||||
end
|
||||
@@ -274,6 +291,10 @@ local qsFound = qsInventory == 'started' or qsInventory == 'starting' or false
|
||||
|
||||
|
||||
function WSB.addItem(source, item, count, slot, metadata)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local ok = exports['jaksam_inventory']:addItem(source, item, count or 1, metadata, slot)
|
||||
return ok
|
||||
end
|
||||
if qboxFound or oxFound then
|
||||
return exports.ox_inventory:AddItem(source, item, count, metadata, slot)
|
||||
end
|
||||
@@ -290,6 +311,9 @@ function WSB.addItem(source, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
function WSB.addWeapon(source, weapon, ammo)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
return exports['jaksam_inventory']:addItem(source, weapon, 1, nil, nil)
|
||||
end
|
||||
if qboxFound or oxFound then
|
||||
return exports.ox_inventory:AddItem(source, weapon, 1)
|
||||
end
|
||||
@@ -300,6 +324,10 @@ function WSB.addWeapon(source, weapon, ammo)
|
||||
end
|
||||
|
||||
function WSB.removeItem(source, item, count, slot, metadata)
|
||||
if WSB.inventorySystem == 'jaksam_inventory' then
|
||||
local ok = exports['jaksam_inventory']:removeItem(source, item, count or 1, metadata, slot)
|
||||
return ok
|
||||
end
|
||||
if qboxFound or oxFound then
|
||||
return exports.ox_inventory:RemoveItem(source, item, count, metadata, slot)
|
||||
end
|
||||
|
||||
@@ -7,15 +7,14 @@ lua54 'yes'
|
||||
|
||||
description 'A library of functions used to ease the bridge between Wasabi Scripts'
|
||||
author 'wasabirobby'
|
||||
version '1.6.6'
|
||||
version '1.6.9'
|
||||
|
||||
ui_page 'ui/index.html'
|
||||
files { 'ui/*', 'ui/**/*' }
|
||||
|
||||
shared_script {'config.lua', 'callback/shared.lua' }
|
||||
shared_script {'config.lua', '@ox_lib/init.lua' }
|
||||
|
||||
client_scripts {
|
||||
'callback/client.lua',
|
||||
'frameworks/**/client.lua',
|
||||
'targets/*.lua',
|
||||
'inventories/**/client.lua',
|
||||
@@ -24,7 +23,6 @@ client_scripts {
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'callback/server.lua',
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'frameworks/**/server.lua',
|
||||
'inventories/**/server.lua',
|
||||
@@ -33,7 +31,7 @@ server_scripts {
|
||||
|
||||
files { 'import.lua' }
|
||||
|
||||
dependencies { 'oxmysql' }
|
||||
dependencies { 'oxmysql', 'ox_lib' }
|
||||
|
||||
escrow_ignore {
|
||||
'config.lua',
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
-----------------For support, scripts, and more----------------
|
||||
--------------- https://discord.gg/wasabiscripts -------------
|
||||
---------------------------------------------------------------
|
||||
|
||||
local found = GetResourceState('jaksam_inventory')
|
||||
if found ~= 'started' and found ~= 'starting' then return end
|
||||
|
||||
WSB.inventorySystem = 'jaksam_inventory'
|
||||
WSB.inventory = {}
|
||||
|
||||
function WSB.inventory.openPlayerInventory(targetId)
|
||||
exports['jaksam_inventory']:openInventory(targetId)
|
||||
end
|
||||
|
||||
function WSB.inventory.openStash(data)
|
||||
-- data = { name = name, unique = true, maxWeight = maxWeight, slots = slots }
|
||||
if data.unique then
|
||||
data.name = ('%s_%s'):format(data.name, WSB.getIdentifier())
|
||||
end
|
||||
TriggerServerEvent('wasabi_bridge:openStash', data)
|
||||
end
|
||||
|
||||
function WSB.inventory.openShop(data)
|
||||
--[[
|
||||
Shops must be registered on the server via 'wasabi_bridge:registerShop'.
|
||||
See server.lua of this inventory for details.
|
||||
]]
|
||||
TriggerServerEvent('wasabi_bridge:openShop', data)
|
||||
end
|
||||
@@ -0,0 +1,118 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
-----------------For support, scripts, and more----------------
|
||||
--------------- https://discord.gg/wasabiscripts -------------
|
||||
---------------------------------------------------------------
|
||||
|
||||
local found = GetResourceState('jaksam_inventory')
|
||||
if found ~= 'started' and found ~= 'starting' then return end
|
||||
|
||||
WSB.inventory = {}
|
||||
WSB.inventorySystem = 'jaksam_inventory'
|
||||
|
||||
local jaksam = exports['jaksam_inventory']
|
||||
local registeredShops = {}
|
||||
local registeredStashes = {}
|
||||
|
||||
---Convert bridge shop data to stash/inventory for jaksam (no native shop type)
|
||||
local function ensureShopStash(data)
|
||||
if registeredShops[data.identifier] then return end
|
||||
local items = {}
|
||||
for _, row in ipairs(data.inventory or {}) do
|
||||
items[#items + 1] = { row.name, row.amount or 1, row.metadata or {} }
|
||||
end
|
||||
jaksam:createInventory(data.identifier, data.name or data.identifier, {
|
||||
maxSlots = math.max(50, #items),
|
||||
maxWeight = 1000,
|
||||
}, items, 'stash', nil)
|
||||
registeredShops[data.identifier] = true
|
||||
end
|
||||
|
||||
AddEventHandler('wasabi_bridge:registerStash', function(data)
|
||||
local invokingResource = GetInvokingResource()
|
||||
if not invokingResource then return end
|
||||
if invokingResource:sub(1, 7) ~= 'wasabi_' then return end
|
||||
if registeredStashes[data.name] then return end
|
||||
jaksam:registerStash({
|
||||
id = data.name,
|
||||
label = data.name,
|
||||
maxWeight = data.maxWeight or 100,
|
||||
maxSlots = data.slots or 50,
|
||||
runtimeOnly = true,
|
||||
})
|
||||
registeredStashes[data.name] = true
|
||||
end)
|
||||
|
||||
AddEventHandler('wasabi_bridge:registerShop', function(data)
|
||||
local invokingResource = GetInvokingResource()
|
||||
if not invokingResource then return end
|
||||
if invokingResource:sub(1, 7) ~= 'wasabi_' then return end
|
||||
ensureShopStash(data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('wasabi_bridge:openShop', function(data)
|
||||
if not data or not data.identifier or not registeredShops[data.identifier] then return end
|
||||
if data.groups and not WSB.hasGroup(source, data.groups) then return end
|
||||
jaksam:forceOpenInventory(source, data.identifier)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('wasabi_bridge:openStash', function(data)
|
||||
local src = source
|
||||
-- Client already sets data.name to unique (name_identifier) when data.unique
|
||||
local stashId = data.name
|
||||
jaksam:registerStash({
|
||||
id = stashId,
|
||||
label = data.label or stashId,
|
||||
maxWeight = data.maxWeight or 100,
|
||||
maxSlots = data.slots or 50,
|
||||
runtimeOnly = true,
|
||||
})
|
||||
jaksam:forceOpenInventory(src, stashId)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('wasabi_bridge:openPlayerInventory', function(targetId)
|
||||
jaksam:forceOpenInventory(source, targetId)
|
||||
end)
|
||||
|
||||
function WSB.inventory.getItemSlot(source, itemName)
|
||||
local item, slotId = jaksam:getItemByName(source, itemName)
|
||||
return slotId or false
|
||||
end
|
||||
|
||||
function WSB.inventory.getItemSlots(source, itemName)
|
||||
local inv = jaksam:getInventory(source)
|
||||
if not inv or not inv.items then return {} end
|
||||
local slots = {}
|
||||
for slotKey, item in pairs(inv.items) do
|
||||
if item and item.name == itemName then
|
||||
local n = tonumber(slotKey:match('%d+')) or slotKey
|
||||
slots[#slots + 1] = n
|
||||
end
|
||||
end
|
||||
return slots
|
||||
end
|
||||
|
||||
function WSB.inventory.getItemMetadata(source, slot)
|
||||
local item = jaksam:getItemFromSlot(source, slot)
|
||||
return item and item.metadata or nil
|
||||
end
|
||||
|
||||
function WSB.inventory.setItemMetadata(source, slot, metadata)
|
||||
if not slot or not metadata then return false end
|
||||
local item = jaksam:getItemFromSlot(source, slot)
|
||||
if not item then return false end
|
||||
return jaksam:setItemMetadataInSlot(source, slot, metadata)
|
||||
end
|
||||
|
||||
---Clears specified inventory
|
||||
---@param source number
|
||||
---@param identifier string|number|nil
|
||||
---@param keepItems string|table|nil
|
||||
function WSB.inventory.clearInventory(source, identifier, keepItems)
|
||||
local exclude = keepItems
|
||||
if type(keepItems) == 'string' then
|
||||
exclude = { keepItems }
|
||||
elseif type(keepItems) ~= 'table' or not next(keepItems) then
|
||||
exclude = nil
|
||||
end
|
||||
return jaksam:clearInventory(identifier or source, exclude)
|
||||
end
|
||||
@@ -19,7 +19,8 @@
|
||||
<div class="header">
|
||||
<div class="title">EMS Menu</div>
|
||||
</div>
|
||||
<div class="menu-contents"></div>
|
||||
<div class="menu-contents">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="context-menu-container">
|
||||
@@ -31,7 +32,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-contents"></div>
|
||||
<div class="menu-contents">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-dialog-container">
|
||||
@@ -53,6 +55,11 @@
|
||||
<div class="header">Alert Dialog</div>
|
||||
<div class="seperator"></div>
|
||||
<div class="alert-dialog-contents">
|
||||
<b>This</b> is a <u>test</u>!<br>
|
||||
For the alert Dialog
|
||||
<list>
|
||||
<li>item test</li>
|
||||
</list>
|
||||
</div>
|
||||
<div class="nav-button-container">
|
||||
<div class="cancel-button">Cancel</div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user