local isStaff = false local showHeadIds = false local peds = {} -- Configuratie local Config = { StaffGroups = {'admin', 'superadmin', 'mod', 'helper'}, -- Voeg hier je staff groepen toe PlayerRadius = 100, -- Radius voor spelers (aanpasbaar) PedRadius = 30, -- Radius voor NPCs ToggleKey = 20 -- Left Shift key (20) } -- Check of speler staff is RegisterNetEvent('esx:setGroup') AddEventHandler('esx:setGroup', function(group) isStaff = false for _, staffGroup in pairs(Config.StaffGroups) do if group == staffGroup then isStaff = true break end end end) -- Initial staff check wanneer speler spawnt RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) if xPlayer.group then for _, staffGroup in pairs(Config.StaffGroups) do if xPlayer.group == staffGroup then isStaff = true break end end end end) -- Server event om head IDs te togglen (via /toggleids command) RegisterNetEvent('esx:toggleHeadIds') AddEventHandler('esx:toggleHeadIds', function(radius) if not isStaff then return end showHeadIds = not showHeadIds -- Als radius is meegegeven, stel deze in if radius then Config.PlayerRadius = radius end local status = showHeadIds and 'ingeschakeld' or 'uitgeschakeld' local radiusText = radius and (' (radius: ' .. radius .. 'm)') or '' ESX.ShowNotification('info', 'Head IDs zijn nu ' .. status .. radiusText) end) -- Server event om head IDs radius in te stellen (via /toggleids_radius command) RegisterNetEvent('esx:setHeadIdsRadius') AddEventHandler('esx:setHeadIdsRadius', function(newRadius) if not isStaff then return end Config.PlayerRadius = newRadius ESX.ShowNotification('success', 'Head IDs radius ingesteld op: ' .. newRadius .. ' meter') end) -- Main thread voor het tonen van head IDs Citizen.CreateThread(function() while true do local sleep = 500 -- Default sleep wanneer niet actief -- Alleen uitvoeren als speler staff is en head IDs zijn ingeschakeld if isStaff and showHeadIds then sleep = 0 -- Geen sleep wanneer actief -- Toon speler IDs for _, id in ipairs(GetActivePlayers()) do if NetworkIsPlayerActive(id) then local ownPed = PlayerPedId() local ped = GetPlayerPed(id) local coords = GetEntityCoords(ownPed) local pos = GetEntityCoords(ped) local distance = #(coords - pos) if distance < Config.PlayerRadius then local headPos = GetPedBoneCoords(ped, 'SKEL_Head') local playerId = GetPlayerServerId(id) if DoesEntityExist(ped) and IsEntityVisible(ped) and HasEntityClearLosToEntity(ownPed, ped, 17) and HasEntityClearLosToEntity(ownPed, ped, 256) then local text = NetworkIsPlayerTalking(id) and '~b~[' .. playerId .. ']' or '[' .. playerId .. ']' ESX.Game.Utils.DrawText(headPos.x, headPos.y, headPos.z + 1.0, text) end end end end -- Toon NPC IDs (als je die hebt) for ped, source in pairs(peds) do if DoesEntityExist(ped) then local ownPed = PlayerPedId() local coords = GetEntityCoords(ownPed) local pos = GetEntityCoords(ped) local distance = #(coords - pos) if distance < Config.PedRadius then local headPos = GetPedBoneCoords(ped, 'SKEL_Head') local text = '~r~[' .. source .. ']' ESX.Game.Utils.DrawText(headPos.x, headPos.y, headPos.z + 1.0, text) end else -- Verwijder niet-bestaande peds peds[ped] = nil end end end Wait(sleep) end end) -- Export functie voor het toevoegen van NPCs exports('addPedToHeadId', function(ped, source) if isStaff then peds[ped] = source end end) -- Export functie om te checken of speler staff is exports('isStaff', function() return isStaff end) -- Export functie om head IDs status te krijgen exports('getHeadIdsStatus', function() return showHeadIds end)