SCBA script fdtow cad
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
usedScbaItem = {}
|
||||
usedRopeItem = {}
|
||||
|
||||
if Config.JobCheck.ESX.Enabled or Config.Inventory.ESX then
|
||||
ESX = exports["es_extended"]:getSharedObject()
|
||||
end
|
||||
|
||||
if Config.JobCheck.vRP.Enabled or Config.Inventory.vRP then
|
||||
local Tunnel = module("vrp", "lib/Tunnel")
|
||||
local Proxy = module("vrp", "lib/Proxy")
|
||||
vRP = Proxy.getInterface("vRP")
|
||||
vRPclient = Tunnel.getInterface("vRP","vRP")
|
||||
end
|
||||
|
||||
if Config.JobCheck.QBCore.Enabled or Config.Inventory.qbCore then
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
end
|
||||
|
||||
local itemEnabled = Config.Inventory.qbCore or Config.Inventory.vRP or Config.Inventory.ESX or Config.Inventory.coreInventory or Config.Inventory.oxInventory
|
||||
|
||||
function UserHasPermission(source, location)
|
||||
|
||||
if not location.EnablePermissions then
|
||||
return true
|
||||
end
|
||||
|
||||
if location.AcePermissions.Enabled then
|
||||
if IsPlayerAceAllowed(source, location.AcePermissions.Permission) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- ESX Permissions
|
||||
if location.ESX.Enabled then
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
if location.ESX.CheckJob.Enabled then
|
||||
for k, v in pairs(location.ESX.CheckJob.Jobs) do
|
||||
if xPlayer.job.name == v then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- vRP Permission
|
||||
if location.vRP.Enabled then
|
||||
if location.vRP.CheckPermission.Enabled then
|
||||
for k, v in pairs(location.vRP.CheckPermission.Permissions) do
|
||||
if vRP.hasPermission({vRP.getUserId({source}),v}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if location.vRP.CheckGroup.Enabled then
|
||||
for k, v in pairs(location.vRP.CheckGroup.Groups) do
|
||||
if vRP.hasGroup({vRP.getUserId({source}),v}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- QBCore Permission
|
||||
if location.QBCore.Enabled then
|
||||
local player = QBCore.Functions.GetPlayer(source)
|
||||
if location.QBCore.CheckJob.Enabled then
|
||||
for k, v in pairs(location.QBCore.CheckJob.Jobs) do
|
||||
if player.PlayerData.job.name == v then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if location.QBCore.CheckPermission.Enabled then
|
||||
for k, v in pairs(location.QBCore.CheckPermission.Permissions) do
|
||||
if QBCore.Functions.HasPermission(source, v) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if location.QBX.Enabled then
|
||||
local player = exports.qbx_core:GetPlayer(source)
|
||||
if location.QBX.CheckJob.Enabled then
|
||||
for k, v in pairs(location.QBX.CheckJob.Jobs) do
|
||||
if player.PlayerData.job.name == v then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function HandleInventoryItems(source, itemName, give)
|
||||
if Config.Inventory.vRP then
|
||||
local userID = vRP.getUserId({source})
|
||||
if give then
|
||||
vRP.giveInventoryItem({userId, itemName, 1, false})
|
||||
else
|
||||
if vRP.tryGetInventoryItem({userID, itemName, 1, false}) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
elseif Config.Inventory.qbCore then
|
||||
if give then
|
||||
exports['qb-inventory']:AddItem(source, itemName, 1, false, false, GetCurrentResourceName())
|
||||
else
|
||||
local successful = exports['qb-inventory']:RemoveItem(source, itemName, 1, false, GetCurrentResourceName())
|
||||
|
||||
return successful
|
||||
end
|
||||
elseif Config.Inventory.ESX then
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
if give then
|
||||
xPlayer.addInventoryItem(itemName, 1)
|
||||
else
|
||||
local returnedItem = xPlayer.getInventoryItem(itemName)
|
||||
|
||||
if returnedItem.canRemove then
|
||||
xPlayer.removeInventoryItem(itemName, 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
elseif Config.Inventory.oxInventory then
|
||||
if give then
|
||||
exports.ox_inventory:AddItem(source, itemName, 1)
|
||||
else
|
||||
local successful = exports.ox_inventory:RemoveItem(source, itemName, 1)
|
||||
|
||||
return successful
|
||||
end
|
||||
elseif Config.Inventory.coreInventory then
|
||||
if give then
|
||||
exports.core_Inventory:addItem(source, itemName, 1)
|
||||
else
|
||||
local successful = exports.core_Inventory:removeItem(source, itemName, 1)
|
||||
|
||||
return successful
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if Config.Inventory.qbCore then
|
||||
QBCore.Functions.CreateUseableItem(Config.Inventory.scbaItemName, function(src)
|
||||
TriggerEvent("Server:ScbaWithItem", src)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateUseableItem(Config.Inventory.ropeItemName, function(src)
|
||||
TriggerEvent("Server:RopeWithItem", src)
|
||||
end)
|
||||
end
|
||||
|
||||
if Config.Inventory.ESX then
|
||||
ESX.RegisterUsableItem(Config.Inventory.scbaItemName, function(src)
|
||||
TriggerEvent("Server:ScbaWithItem", src)
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem(Config.Inventory.ropeItemName, function(src)
|
||||
TriggerEvent("Server:RopeWithItem", src)
|
||||
end)
|
||||
end
|
||||
|
||||
if Config.Inventory.oxInventory then
|
||||
exports('OxUseSCBA', function(event, _, inventory)
|
||||
if event == 'usingItem' then
|
||||
usedScbaItem[inventory.player.source] = true
|
||||
TriggerClientEvent('scba:client:useScba', inventory.player.source)
|
||||
end
|
||||
end)
|
||||
|
||||
exports('OxUseRope', function(event, _, inventory)
|
||||
if event == 'usingItem' then
|
||||
usedRopeItem[inventory.player.source] = true
|
||||
TriggerClientEvent('scba:client:useRope', inventory.player.source)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user