Add utility functions for player data retrieval and enhance existing functions
This commit is contained in:
1 parent
498f8670ee
commit
78bb1f8c05
4 files changed
+17
-13
No files matched your search
@@ -495,6 +495,7 @@ print("Result:", result)
|
|||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
if resource ~= GetCurrentResourceName() then return end
|
if resource ~= GetCurrentResourceName() then return end
|
||||||
for _, blip in pairs(blipIDs) do
|
for _, blip in pairs(blipIDs) do
|
||||||
|
|||||||
@@ -250,7 +250,10 @@ end
|
|||||||
Framework.SetPlayerJob = function(src, name, grade)
|
Framework.SetPlayerJob = function(src, name, grade)
|
||||||
local xPlayer = ESX.GetPlayerFromId(src)
|
local xPlayer = ESX.GetPlayerFromId(src)
|
||||||
if not xPlayer then return end
|
if not xPlayer then return end
|
||||||
if not ESX.DoesJobExist(name, grade) then lib.print.error("Job Does Not Exsist In Framework :NAME "..name.." Grade:"..grade) return end
|
if not ESX.DoesJobExist(name, grade) then
|
||||||
|
lib.print.error("Job Does Not Exsist In Framework :NAME " .. name .. " Grade:" .. grade)
|
||||||
|
return
|
||||||
|
end
|
||||||
return xPlayer.setJob(name, grade, true)
|
return xPlayer.setJob(name, grade, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -351,5 +354,3 @@ Framework.Commands.Add = function(name, help, arguments, argsrequired, callback,
|
|||||||
arguments = arguments
|
arguments = arguments
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
return Framework
|
|
||||||
@@ -413,7 +413,8 @@ end
|
|||||||
Framework.AddItem = function(src, item, amount, slot, metadata)
|
Framework.AddItem = function(src, item, amount, slot, metadata)
|
||||||
local player = QBCore.Functions.GetPlayer(src)
|
local player = QBCore.Functions.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||||
|
{ action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
return player.Functions.AddItem(item, amount, slot, metadata)
|
return player.Functions.AddItem(item, amount, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -422,7 +423,8 @@ end
|
|||||||
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
||||||
local player = QBCore.Functions.GetPlayer(src)
|
local player = QBCore.Functions.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||||
|
{ action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
return player.Functions.RemoveItem(item, amount, slot or nil)
|
return player.Functions.RemoveItem(item, amount, slot or nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -452,7 +454,8 @@ end
|
|||||||
---@return table
|
---@return table
|
||||||
Framework.GetOwnedVehicles = function(src)
|
Framework.GetOwnedVehicles = function(src)
|
||||||
local citizenId = Framework.GetPlayerIdentifier(src)
|
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||||
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" ..
|
||||||
|
citizenId .. "'")
|
||||||
local vehicles = {}
|
local vehicles = {}
|
||||||
for i = 1, #result do
|
for i = 1, #result do
|
||||||
local vehicle = result[i].vehicle
|
local vehicle = result[i].vehicle
|
||||||
@@ -493,5 +496,3 @@ Framework.Commands = {}
|
|||||||
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Framework
|
|
||||||
@@ -375,7 +375,8 @@ end
|
|||||||
Framework.AddItem = function(src, item, amount, slot, metadata)
|
Framework.AddItem = function(src, item, amount, slot, metadata)
|
||||||
local player = QBox:GetPlayer(src)
|
local player = QBox:GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||||
|
{ action = "add", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
return player.Functions.AddItem(item, amount, slot, metadata)
|
return player.Functions.AddItem(item, amount, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -389,7 +390,8 @@ end
|
|||||||
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
||||||
local player = QBox:GetPlayer(src)
|
local player = QBox:GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src,
|
||||||
|
{ action = "remove", item = item, count = amount, slot = slot, metadata = metadata })
|
||||||
return player.Functions.RemoveItem(item, amount, slot)
|
return player.Functions.RemoveItem(item, amount, slot)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -411,7 +413,8 @@ end
|
|||||||
---@return table
|
---@return table
|
||||||
Framework.GetOwnedVehicles = function(src)
|
Framework.GetOwnedVehicles = function(src)
|
||||||
local citizenId = Framework.GetPlayerIdentifier(src)
|
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||||
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" ..
|
||||||
|
citizenId .. "'")
|
||||||
local vehicles = {}
|
local vehicles = {}
|
||||||
for i = 1, #result do
|
for i = 1, #result do
|
||||||
local vehicle = result[i].vehicle
|
local vehicle = result[i].vehicle
|
||||||
@@ -449,5 +452,3 @@ AddEventHandler("playerDropped", function()
|
|||||||
local src = source
|
local src = source
|
||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return Framework
|
|
||||||
Reference in new issue
Block a user