ed
This commit is contained in:
parent
26ed285540
commit
4c95214808
53 changed files with 694 additions and 2507 deletions
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
if Config.commands.towing.enabled then
|
||||
RegisterCommand(Config.commands.towing.command, function(source)
|
||||
if Config.jobWhitelist.towing.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.towing.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, false, false)
|
||||
end)
|
||||
end
|
||||
|
||||
if Config.commands.winch.enabled then
|
||||
RegisterCommand(Config.commands.winch.command, function(source)
|
||||
if Config.jobWhitelist.winch.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.winch.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, true, false)
|
||||
end)
|
||||
end
|
||||
85
resources/[carscripts]/kq_towing2/server/editable/esx.lua
Normal file
85
resources/[carscripts]/kq_towing2/server/editable/esx.lua
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
if Config.esxSettings.enabled then
|
||||
ESX = nil
|
||||
|
||||
if Config.esxSettings.useNewESXExport then
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
else
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
end
|
||||
|
||||
ESX.RegisterUsableItem(Config.items.towingRope, function(source)
|
||||
if Config.jobWhitelist.towing.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.towing.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, false, true)
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem(Config.items.winch, function(source)
|
||||
if Config.jobWhitelist.winch.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.winch.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, true, true)
|
||||
end)
|
||||
|
||||
function IsPlayerJobWhitelisted(player, jobs)
|
||||
local xPlayer = ESX.GetPlayerFromId(player)
|
||||
if not xPlayer then
|
||||
return false
|
||||
end
|
||||
local job = xPlayer.getJob()
|
||||
|
||||
return Contains(jobs, job.name)
|
||||
end
|
||||
|
||||
function GetPlayerItemData(player, item)
|
||||
local xPlayer = ESX.GetPlayerFromId(player)
|
||||
|
||||
return xPlayer.getInventoryItem(item)
|
||||
end
|
||||
|
||||
function GetPlayerItemCount(player, item)
|
||||
local data = GetPlayerItemData(player, item)
|
||||
if not data then
|
||||
return 0
|
||||
end
|
||||
return data.count or data.amount or 0
|
||||
end
|
||||
|
||||
function RemovePlayerItem(player, item, amount)
|
||||
if GetPlayerItemCount(player, item) < amount then
|
||||
return false
|
||||
end
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(player)
|
||||
xPlayer.removeInventoryItem(item, amount or 1)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function AddPlayerItem(player, item, amount)
|
||||
local xPlayer = ESX.GetPlayerFromId(tonumber(player))
|
||||
|
||||
-- Support for old esx which didn't use weight for inventory size but rather item limit per item type
|
||||
if Config.esxSettings.oldEsx then
|
||||
local esxItem = xPlayer.getInventoryItem(item)
|
||||
|
||||
if esxItem.limit == -1 or (esxItem.count + amount) <= esxItem.limit then
|
||||
xPlayer.addInventoryItem(item, amount or 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
if xPlayer.canCarryItem(item, amount or 1) then
|
||||
xPlayer.addInventoryItem(item, amount or 1)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
35
resources/[carscripts]/kq_towing2/server/editable/ox.lua
Normal file
35
resources/[carscripts]/kq_towing2/server/editable/ox.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
if Config.oxInventory.enabled then
|
||||
|
||||
-- Usable items
|
||||
-- Export used for ox_inventory
|
||||
exports('UseTowRope', function(event, item, inventory)
|
||||
if event == 'usingItem' then
|
||||
local player = inventory.id
|
||||
TriggerClientEvent('kq_towing:client:startRope', player, false, true)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
exports('UseWinch', function(event, item, inventory)
|
||||
if event == 'usingItem' then
|
||||
local player = inventory.id
|
||||
TriggerClientEvent('kq_towing:client:startRope', player, true, true)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
function IsPlayerJobWhitelisted(player, jobs)
|
||||
return true
|
||||
end
|
||||
|
||||
function AddPlayerItem(player, item, amount, meta)
|
||||
local success, response = exports['ox_inventory']:AddItem(player, item, amount or 1, meta)
|
||||
return success
|
||||
end
|
||||
|
||||
function RemovePlayerItem(player, item, amount)
|
||||
local success, response = exports['ox_inventory']:RemoveItem(player, item, amount or 1)
|
||||
return success
|
||||
end
|
||||
end
|
||||
46
resources/[carscripts]/kq_towing2/server/editable/qb.lua
Normal file
46
resources/[carscripts]/kq_towing2/server/editable/qb.lua
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
if Config.qbSettings.enabled then
|
||||
|
||||
if Config.qbSettings.useNewQBExport then
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
end
|
||||
|
||||
QBCore.Functions.CreateUseableItem(Config.items.towingRope, function(source)
|
||||
if Config.jobWhitelist.towing.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.towing.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, false, true)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateUseableItem(Config.items.winch, function(source)
|
||||
if Config.jobWhitelist.winch.enabled then
|
||||
if not IsPlayerJobWhitelisted(source, Config.jobWhitelist.winch.jobs) then
|
||||
return TriggerClientEvent('kq_towing:client:notify', source, L('~r~You may not use this item'))
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('kq_towing:client:startRope', source, true, true)
|
||||
end)
|
||||
|
||||
|
||||
function IsPlayerJobWhitelisted(player, jobs)
|
||||
local xPlayer = QBCore.Functions.GetPlayer(player)
|
||||
if not xPlayer then
|
||||
return false
|
||||
end
|
||||
|
||||
local job = xPlayer.PlayerData.job
|
||||
|
||||
return Contains(jobs, job.name)
|
||||
end
|
||||
|
||||
function RemovePlayerItem(player, item, amount)
|
||||
local xPlayer = QBCore.Functions.GetPlayer(tonumber(player))
|
||||
return xPlayer.Functions.RemoveItem(item, amount or 1)
|
||||
end
|
||||
|
||||
function AddPlayerItem(player, item, amount)
|
||||
local xPlayer = QBCore.Functions.GetPlayer(tonumber(player))
|
||||
return xPlayer.Functions.AddItem(item, amount or 1)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue