62 lines
1.8 KiB
Lua
62 lines
1.8 KiB
Lua
local ESX = exports['es_extended']:getSharedObject()
|
|
|
|
local blipsActive = false
|
|
local playerBlips = {}
|
|
|
|
RegisterCommand('blips', function()
|
|
if blipsActive then
|
|
removeAllBlips()
|
|
blipsActive = false
|
|
ESX.ShowNotification('~r~Spieler-Blips deaktiviert')
|
|
else
|
|
blipsActive = true
|
|
ESX.ShowNotification('~g~Spieler-Blips aktiviert')
|
|
updateBlips()
|
|
end
|
|
end, false)
|
|
|
|
function removeAllBlips()
|
|
for _, blip in pairs(playerBlips) do
|
|
if DoesBlipExist(blip) then
|
|
RemoveBlip(blip)
|
|
end
|
|
end
|
|
playerBlips = {}
|
|
end
|
|
|
|
function updateBlips()
|
|
if not blipsActive then return end
|
|
|
|
ESX.TriggerServerCallback('mercyv-admin:getPlayers', function(players)
|
|
if not players then
|
|
blipsActive = false
|
|
ESX.ShowNotification('~r~Keine Berechtigung')
|
|
return
|
|
end
|
|
|
|
removeAllBlips()
|
|
|
|
-- Eigene Server-ID abrufen
|
|
local myId = GetPlayerServerId(PlayerId())
|
|
|
|
for _, player in pairs(players) do
|
|
-- Prüfen, ob die ID des Spielers in der Liste NICHT die eigene ID ist
|
|
if tonumber(player.id) ~= myId then
|
|
local blip = AddBlipForCoord(player.x, player.y, player.z)
|
|
SetBlipSprite(blip, 1)
|
|
SetBlipDisplay(blip, 4)
|
|
SetBlipScale(blip, 0.9)
|
|
SetBlipColour(blip, 0)
|
|
SetBlipAsShortRange(blip, false)
|
|
BeginTextCommandSetBlipName('STRING')
|
|
AddTextComponentSubstringPlayerName(player.name .. ' [' .. player.id .. ']')
|
|
EndTextCommandSetBlipName(blip)
|
|
table.insert(playerBlips, blip)
|
|
end
|
|
end
|
|
|
|
if blipsActive then
|
|
SetTimeout(5000, updateBlips)
|
|
end
|
|
end)
|
|
end |