Added extra player checks

- changed to dist <=
- added distance to the player infos (only updates when you open the register)
- added extra check to be sure it doesn't add someone whos too far
This commit is contained in:
jimathy
2022-02-06 13:42:56 +00:00
committed by GitHub
parent e0321c51c6
commit 412267a5c8

View File

@@ -68,9 +68,10 @@ QBCore.Functions.CreateCallback('jim-payments:server:GetCurrentPlayers', functio
local SPlayer = QBCore.Functions.GetPlayer(source)
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local Player = QBCore.Functions.GetPlayer(v)
if Player ~= nil and v ~= source then
if Player ~= nil then
local dist = #(vector3(Player.PlayerData.position.x, Player.PlayerData.position.y, Player.PlayerData.position.z) - vector3(SPlayer.PlayerData.position.x, SPlayer.PlayerData.position.y, SPlayer.PlayerData.position.z))
if dist < Config.PaymentRadius then onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname } end
if dist <= Config.PaymentRadius then onlineList[#onlineList+1] = { value = tonumber(v), text = "["..v.."] - "..Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname..' ('..dist..'m)' }
elseif dist > Config.PaymentRadius then end
end
end
cb(onlineList)