mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Remove inventory code from the core (#784)
* tweak(config): remove inventory code * tweak(client/functions): remove inventory code * cleanup(server/commands): remove inventory command * cleanup(server/events): remove hasitem callback * cleanup(server/functions): remove inventory code * cleanup(server/player): remove inventory code * feat(server/player): QBCore:Player:SetPlayerData server side Removed QBCore:Server:PlayerLoaded for PR that will be merged before me that adds it * feat(server/player): QBCore:Server:OnGangUpdate * fix(shared/items): remove duplicate snowball * fix(server/events): warn for exploitable event * fix(server/functions): startup error * feat(server/player): some backwards compatibility * fix(server/events): warn for exploitable event * feat(server/player): Player.Functions.AddField * feat(server/exports): SetField and AddField * fix(server/player): inventory state check
This commit is contained in:
+5
-33
@@ -8,38 +8,12 @@ function QBCore.Functions.GetPlayerData(cb)
|
||||
end
|
||||
|
||||
function QBCore.Functions.GetCoords(entity)
|
||||
return vector4(GetEntityCoords(entity), GetEntityHeading(entity))
|
||||
local coords = GetEntityCoords(entity)
|
||||
return vector4(coords.x, coords.y, coords.z, GetEntityHeading(entity))
|
||||
end
|
||||
|
||||
function QBCore.Functions.HasItem(items, amount)
|
||||
local isTable = type(items) == 'table'
|
||||
local isArray = isTable and table.type(items) == 'array' or false
|
||||
local totalItems = #items
|
||||
local count = 0
|
||||
local kvIndex = 2
|
||||
if isTable and not isArray then
|
||||
totalItems = 0
|
||||
for _ in pairs(items) do totalItems += 1 end
|
||||
kvIndex = 1
|
||||
end
|
||||
for _, itemData in pairs(QBCore.PlayerData.items) do
|
||||
if isTable then
|
||||
for k, v in pairs(items) do
|
||||
local itemKV = {k, v}
|
||||
if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) or (not isArray and itemData.amount >= v) or (not amount and isArray)) then
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
if count == totalItems then
|
||||
return true
|
||||
end
|
||||
else -- Single item as string
|
||||
if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
return exports['qb-inventory']:HasItem(items, amount)
|
||||
end
|
||||
|
||||
-- Utility
|
||||
@@ -84,8 +58,8 @@ function QBCore.Functions.RequestAnimDict(animDict)
|
||||
end
|
||||
|
||||
function QBCore.Functions.PlayAnim(animDict, animName, upperbodyOnly, duration)
|
||||
local flags = upperbodyOnly == true and 16 or 0
|
||||
local runTime = duration ~= nil and duration or -1
|
||||
local flags = upperbodyOnly and 16 or 0
|
||||
local runTime = duration or -1
|
||||
QBCore.Functions.RequestAnimDict(animDict)
|
||||
TaskPlayAnim(PlayerPedId(), animDict, animName, 8.0, 1.0, runTime, flags, 0.0, false, false, true)
|
||||
RemoveAnimDict(animDict)
|
||||
@@ -158,8 +132,6 @@ function QBCore.Functions.TriggerCallback(name, cb, ...)
|
||||
TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function QBCore.Functions.Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
if GetResourceState('progressbar') ~= 'started' then error('progressbar needs to be started in order for QBCore.Functions.Progressbar to work') end
|
||||
exports['progressbar']:Progress({
|
||||
|
||||
Reference in New Issue
Block a user