Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```lua
- local playerInfo = {}
- --Create a new index into player info about the player.
- function PopulatePlayerInfo(index)
- if NetworkIsPlayerActive(id) and GetPlayerPed(i) ~= PlayerPedId() then
- local serverId = GetPlayerServerId(i)
- local player = GetPlayerFromServerId(serverId)
- playerInfo[i] = {
- pid = i,
- sid = serverId,
- ped = GetPlayerPed(player),
- blip = -1
- }
- end
- end
- Citizen.CreateThread(function()
- local slots = GetConvarInt('sv_maxclients', 32)
- while true do
- for i = 0, slots do
- -- Wew, we found a new player.
- if playerInfo == nil then
- PopulatePlayerInfo(i)
- end
- -- If the server ID differs, then the slot got reassigned probably.
- if playerInfo[i].sid != GetPlayerServerId(i) then
- PopulatePlayerInfo(i)
- end
- end
- -- Do update thingies.
- UpdateRadar()
- Citizen.Wait(1000)
- end
- end)
- function UpdateRadar()
- if RadarEnabled then
- for i=1, #playerInfo, 1 do
- local player = playerInfo[i]
- -- Get the distance between player and target.
- local playerCoords = GetEntityCoords(PlayerPedId())
- local targetCoords = GetEntityCoords(player.ped)
- local distance = Abs(#(playerCoords - targetCoords))
- if distance < 200 then
- -- We don't have a blip yet, create one.
- if player.blip == -1 then
- local blipId = createBlip(serverId);
- player.blip = blipId
- playerInfo[i] = player
- else
- SetBlipCoords(player.blip, targetCoords)
- end
- else
- -- Out of reach, remove the blip.
- RemoveBlip(player.blip)
- player.blip = -1
- playerInfo[i] = player
- end
- end
- end
- Citizen.Wait(100)
- end
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement