Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Issue inside of Loop #224

Open
AvarianKnight opened this issue Jun 3, 2024 · 0 comments
Open

Performance Issue inside of Loop #224

AvarianKnight opened this issue Jun 3, 2024 · 0 comments

Comments

@AvarianKnight
Copy link

Some users inside of the txAdmin discord recently reported performance issues related to qb-adminmenu which was from this loop.

CreateThread(function()
while true do
local tempPlayers = {}
for _, v in pairs(QBCore.Functions.GetPlayers()) do
local targetped = GetPlayerPed(v)
local ped = QBCore.Functions.GetPlayer(v)
tempPlayers[#tempPlayers + 1] = {
name = (ped.PlayerData.charinfo.firstname or '') .. ' ' .. (ped.PlayerData.charinfo.lastname or '') .. ' | (' .. (GetPlayerName(v) or '') .. ')',
id = v,
coords = GetEntityCoords(targetped),
cid = ped.PlayerData.charinfo.firstname .. ' ' .. ped.PlayerData.charinfo.lastname,
citizenid = ped.PlayerData.citizenid,
sources = GetPlayerPed(ped.PlayerData.source),
sourceplayer = ped.PlayerData.source
}
end
-- Sort players list by source ID (1,2,3,4,5, etc) --
table.sort(tempPlayers, function(a, b)
return a.id < b.id
end)
players = tempPlayers
Wait(1500)
end
end)

There are functions that QB already has to deal with this (GetQBPlayers) to prevent constant serialization.

It might also be worth thinking about the data structure used to store player info and offer a "minimal qb player" that only has the users player data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant