Optimizations

This commit is contained in:
EinS4ckZwiebeln
2024-03-28 12:56:32 +01:00
parent 5c60c94197
commit 868600197d
3 changed files with 21 additions and 12 deletions
+8 -11
View File
@@ -265,15 +265,13 @@ end
function QBCore.Functions.GetPeds(ignoreList)
local pedPool = GetGamePool('CPed')
local peds = {}
local ignoreTable = {}
ignoreList = ignoreList or {}
for i = 1, #pedPool, 1 do
local found = false
for j = 1, #ignoreList, 1 do
if ignoreList[j] == pedPool[i] then
found = true
end
end
if not found then
for i = 1, #ignoreList do
ignoreTable[ignoreList[i]] = true
end
for i = 1, #pedPool do
if not ignoreTable[pedPool[i]] then
peds[#peds + 1] = pedPool[i]
end
end
@@ -353,9 +351,8 @@ function QBCore.Functions.GetPlayersFromCoords(coords, distance)
end
distance = distance or 5
local closePlayers = {}
for _, player in pairs(players) do
local target = GetPlayerPed(player)
local targetCoords = GetEntityCoords(target)
for _, player in ipairs(players) do
local targetCoords = GetEntityCoords(GetPlayerPed(player))
local targetdistance = #(targetCoords - coords)
if targetdistance <= distance then
closePlayers[#closePlayers + 1] = player
+1 -1
View File
@@ -522,7 +522,7 @@ end
---@return boolean, string?
function QBCore.Functions.IsPlayerBanned(source)
local plicense = QBCore.Functions.GetIdentifier(source, 'license')
local result = MySQL.single.await('SELECT * FROM bans WHERE license = ?', { plicense })
local result = MySQL.single.await('SELECT id, reason, expire FROM bans WHERE license = ?', { plicense })
if not result then return false end
if os.time() < result.expire then
local timeTable = os.date('*t', tonumber(result.expire))
+12
View File
@@ -59,6 +59,18 @@ function QBCore.Player.GetOfflinePlayer(citizenid)
end
function QBCore.Player.GetPlayerByLicense(license)
if license then
local source = QBCore.Functions.GetSource(license)
if source > 0 then
return QBCore.Players[source]
else
return QBCore.Player.GetOfflinePlayerByLicense(license)
end
end
return nil
end
function QBCore.Player.GetOfflinePlayerByLicense(license)
if license then
local PlayerData = MySQL.prepare.await('SELECT * FROM players where license = ?', { license })
if PlayerData then