mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +00:00
Optimizations
This commit is contained in:
+8
-11
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user