dom asked for optimization lol

This commit is contained in:
Kakarot
2026-04-20 18:34:22 -05:00
parent 36d8986b42
commit 83152ac815
+15 -15
View File
@@ -55,9 +55,9 @@ end
---@param citizenid string ---@param citizenid string
---@return table? ---@return table?
function QBCore.Functions.GetPlayerByCitizenId(citizenid) function QBCore.Functions.GetPlayerByCitizenId(citizenid)
for src in pairs(QBCore.Players) do for _, Player in pairs(QBCore.Players) do
if QBCore.Players[src].PlayerData.citizenid == citizenid then if Player.PlayerData.citizenid == citizenid then
return QBCore.Players[src] return Player
end end
end end
return nil return nil
@@ -81,9 +81,9 @@ end
---@param number number ---@param number number
---@return table? ---@return table?
function QBCore.Functions.GetPlayerByPhone(number) function QBCore.Functions.GetPlayerByPhone(number)
for src in pairs(QBCore.Players) do for _, Player in pairs(QBCore.Players) do
if QBCore.Players[src].PlayerData.charinfo.phone == number then if Player.PlayerData.charinfo.phone == number then
return QBCore.Players[src] return Player
end end
end end
return nil return nil
@@ -93,9 +93,9 @@ end
---@param account string ---@param account string
---@return table? ---@return table?
function QBCore.Functions.GetPlayerByAccount(account) function QBCore.Functions.GetPlayerByAccount(account)
for src in pairs(QBCore.Players) do for _, Player in pairs(QBCore.Players) do
if QBCore.Players[src].PlayerData.charinfo.account == account then if Player.PlayerData.charinfo.account == account then
return QBCore.Players[src] return Player
end end
end end
return nil return nil
@@ -106,10 +106,10 @@ end
---@param value string ---@param value string
---@return table? ---@return table?
function QBCore.Functions.GetPlayerByCharInfo(property, value) function QBCore.Functions.GetPlayerByCharInfo(property, value)
for src in pairs(QBCore.Players) do for _, Player in pairs(QBCore.Players) do
local charinfo = QBCore.Players[src].PlayerData.charinfo local charinfo = Player.PlayerData.charinfo
if charinfo[property] ~= nil and charinfo[property] == value then if charinfo[property] ~= nil and charinfo[property] == value then
return QBCore.Players[src] return Player
end end
end end
return nil return nil
@@ -450,7 +450,7 @@ function QBCore.Functions.TriggerClientCallback(name, source, ...)
table.remove(args, 1) table.remove(args, 1)
end end
QBCore.ClientCallbacks[name..source] = { QBCore.ClientCallbacks[name .. source] = {
callback = cb, callback = cb,
promise = promise.new() promise = promise.new()
} }
@@ -458,8 +458,8 @@ function QBCore.Functions.TriggerClientCallback(name, source, ...)
TriggerClientEvent('QBCore:Client:TriggerClientCallback', source, name, table.unpack(args)) TriggerClientEvent('QBCore:Client:TriggerClientCallback', source, name, table.unpack(args))
if cb == nil then if cb == nil then
Citizen.Await(QBCore.ClientCallbacks[name..source].promise) Citizen.Await(QBCore.ClientCallbacks[name .. source].promise)
return QBCore.ClientCallbacks[name..source].promise.value return QBCore.ClientCallbacks[name .. source].promise.value
end end
end end