[HELP] Police GPS

I’m using vRP and making police GPS with blips. I only want the cops to have blips and the cops to see each others blips.

but they aren’t working. Here’s what I’ve got:

__resource.lua

client_script 'client.lua'
server_script 'server.lua'

client.lua

RegisterNetEvent('displayblip')
AddEventHandler('displayblip', function(x, y, z)
    local ped = GetPlayerPed(-1)
    local x,y,z = table.unpack(GetEntityCoords(ped, false))
    local blip1 = AddBlipForCoord(x, y, z)
    local user_id = vRP.getUserId(source)
    local plyPos = GetEntityCoords(GetPlayerPed(-1),  true)
    Citizen.Wait(0)
	if user_id ~= nil and vRP.hasPermission(user_id,"police.paycheck") then
		Citizen.Wait(0)
		vRP.openMenu(source,menu_pc)
		SetBlipSprite(blip1, 1)
		BeginTextCommandSetBlipName("STRING")
		AddTextComponentString('Police GPS')
		SetBlipColour(blip1, 1)
		TriggerServerEvent('activateblip', plyPos.x, plyPos.y, plyPos.z)

	elseif user_id ~= nil and (ped ~= vRP.hasPermission(user_id,"police.paycheck")) then 
		-- MAKE BLIPS INVISABLE
	end    
end)

server.lua:

TriggerClientEvent("displayblip", source)


RegisterServerEvent('activateblip')
AddEventHandler('activateblip', function(mx, my, mz)
	TriggerClientEvent('displayblip', -1, mx, my, mz)
end)

Any ideas?

Also is this line correct to check if the ped doesn’t have the permission, if so how do you make a blips opacity 1?

	elseif user_id ~= nil and (ped ~= vRP.hasPermission(user_id,"police.paycheck")) then 
		-- MAKE BLIPS INVISABLE
	end 

Kind Regards,
Catraz

bump
(20 characters)

2 Likes

i would provably take sighmir’s vrp script thats simular to this as an example

Maybe try to change vRP to ESX. Like local user_id = vRP.getUserId(source) to local user_id = ESX.getUserId(source)

If you make it work please mention me cuz i was always looking after this script

  • I know there is a police script already built in but i don’t wanna use that

I’m afraid the only option for you is to use Cops FiveM [Release] Cops FiveM

You could take the code from there where it uses blips and make it into your own script :slight_smile:

This is really not the “only option”.

What you could do, is code into the police clock in that they get added to a table and that is then given to the client when they connect or when a new officer clocks in/out, then use the client to check if they are in the table and add a blip to the entity, make sure you have a table of the blips you’ve created so you don’t make them over and over.

*I mean the only option without having to code anything.