Radar

Looks like i cant find any patrol radars for cops. Seems like any released are either stationary, or you have to be out of the car, or just dont work at all. Any help is appreciated thanks

1 Like

Here is my edit of the old speedcamera… Use ‘K’ to open radar and ‘E’ to freeze/unfreeze. You must be in a police vehicle for it to work…

[updated] 10-3-17 - Added a freeze on the actual radar when a vehicle is clocked over the maxSpeed instead of the extra pop up for now and other small things. Working on rear radar. I can do one or the other right now so when I have time to add a toggle for both I will.
[[Release] Speedcamera]

– __resource.lua

client_script 'speedcamera.lua'

MPH
TEST
– speedcamera.lua

-- script by devilkkw
-- Edited by DankVybez

-- Don't touch this
local radar = 
{
	shown = false, 
	freeze = false, 
	info = "~g~Radar~n~Active", 
-- Touch this if u want
	minSpeed = 5.0,
	maxSpeed = 75.0,
}
-- The distance to check in front of the player for a vehicle
local distanceToCheckFront = 50.0


function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/1, y - height/2 + 0.005)
end

Citizen.CreateThread(function()
	while true do
		Wait(0)
		if IsControlJustPressed(1, 311) and GetLastInputMethod( 0 ) and not IsPauseMenuActive() and not blockinput and (IsPedInAnyPoliceVehicle(GetPlayerPed(-1)))then -- K
			if radar.shown then radar.shown = false else radar.shown = true end		
                Wait(75)
	    end
		if IsControlJustPressed(1, 311) and GetLastInputMethod( 0 ) and not IsPauseMenuActive() and not blockinput then -- K
		    if radar.shown then radar.shown = false end
				Wait(75)
		end
		if IsControlJustPressed(1, 38)then -- E
			if radar.freeze then radar.freeze = false else radar.freeze = true end
		end
		if radar.shown then
			if radar.freeze == false then
					local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
					local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, distanceToCheckFront, 0.0)
					local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords( vehicle, 0.0, distanceToCheckFront, 0.0 )
					local veh = getVehicleInDirection(coordA, coordB)
				if veh ~= nil then

					local model = GetDisplayNameFromVehicleModel(GetEntityModel(veh));
					local plate = GetVehicleNumberPlateText(veh)
					local vehSpeedMph = GetEntitySpeed(veh)*2.236936
				    if model == "rocoto" then model = "ROCOTO" end
				    if model == "CARNOTFOUND" then model = "" end
					
					if vehSpeedMph > radar.minSpeed then			  
						if vehSpeedMph < radar.maxSpeed then 
							radar.info = string.format("| ~b~Model:~w~ %s ~n~| ~b~Plate:~w~ %s ~n~| ~y~Mph:~g~ %s",model,plate,math.ceil(vehSpeedMph))
						else
							radar.info = string.format("| ~b~Model:~w~ %s ~n~| ~b~Plate:~w~ %s ~n~| ~y~Mph:~r~ %s",model,plate,math.ceil(vehSpeedMph))
						end
							if vehSpeedMph > radar.maxSpeed then
							PlaySoundFrontend(-1,  "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 0,0,1)	
						end
							if vehSpeedMph > radar.maxSpeed then
							radar.freeze = true
						end
					end
				end
			end
            drawTxt(0.360,0.900,0.187,0.215,0.365,radar.info,255,255,255,255)		
		end
	end  
end)

-- From point A to B -- Use GetOffsetFromEntityInWorldCoords for distance
function getVehicleInDirection(coordFrom, coordTo)
	local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
	local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
	return vehicle
end

MPH/KMH
TEST2
– speedcamera.lua

-- script by devilkkw
-- Edited by DankVybez

-- Don't touch this
local radar = 
{
	shown = false, 
	freeze = false, 
	info = "~g~Radar~n~Active", 
-- Touch this if u want
	minSpeed = 5.0,
	maxSpeed = 75.0,
}
-- The distance to check in front of the player for a vehicle
local distanceToCheckFront = 50.0


function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/1, y - height/2 + 0.005)
end

Citizen.CreateThread(function()
	while true do
		Wait(0)
		if IsControlJustPressed(1, 311) and GetLastInputMethod( 0 ) and not IsPauseMenuActive() and not blockinput and (IsPedInAnyPoliceVehicle(GetPlayerPed(-1)))then -- K
			if radar.shown then radar.shown = false else radar.shown = true end		
                Wait(75)
	    end
		if IsControlJustPressed(1, 311) and GetLastInputMethod( 0 ) and not IsPauseMenuActive() and not blockinput then -- K
		    if radar.shown then radar.shown = false end
				Wait(75)
		end
		if IsControlJustPressed(1, 38)then -- E
			if radar.freeze then radar.freeze = false else radar.freeze = true end
		end
		if radar.shown then
			if radar.freeze == false then
					local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
					local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, distanceToCheckFront, 0.0)
					local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords( vehicle, 0.0, distanceToCheckFront, 0.0 )
					local veh = getVehicleInDirection(coordA, coordB)
				if veh ~= nil then

					local model = GetDisplayNameFromVehicleModel(GetEntityModel(veh));
					local plate = GetVehicleNumberPlateText(veh)
					local vehSpeedKmh = GetEntitySpeed(veh)*3.6
					local vehSpeedMph = GetEntitySpeed(veh)*2.236936
				    if model == "rocoto" then model = "ROCOTO" end
				    if model == "CARNOTFOUND" then model = "" end
					
					if vehSpeedMph > radar.minSpeed then			  
						if vehSpeedMph < radar.maxSpeed then 
							radar.info = string.format("| ~b~Model:~w~ %s ~n~| ~b~Plate:~w~ %s ~n~| ~y~Kmh:~g~ %s ~n~~w~| ~y~Mph:~g~ %s",model,plate,math.ceil(vehSpeedKmh),math.ceil(vehSpeedMph))
						else
							radar.info = string.format("| ~b~Model:~w~ %s ~n~| ~b~Plate:~w~ %s ~n~| ~y~Kmh:~r~ %s ~n~~w~| ~y~Mph:~r~ %s",model,plate,math.ceil(vehSpeedKmh),math.ceil(vehSpeedMph))
						end
							if vehSpeedMph > radar.maxSpeed then
							PlaySoundFrontend(-1,  "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 0,0,1)	
						end
							if vehSpeedMph > radar.maxSpeed then
							radar.freeze = true
						end
					end
				end
			end
            drawTxt(0.360,0.900,0.187,0.215,0.365,radar.info,255,255,255,255)		
		end
	end  
end)

-- From point A to B -- Use GetOffsetFromEntityInWorldCoords for distance
function getVehicleInDirection(coordFrom, coordTo)
	local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
	local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
	return vehicle
end

If anybody has any questions feel free to join the Discord… https://discord.gg/RdtYH4E

1 Like

You have to spam caps lock then wait until it kinda pops up the hold it. Can it just be a toggle? Seems a bit buggy.

hmm not when I tested it. It is a toggle. You shouldn’t have to spam just press once and it will come right up. Press again and it will close.
And try the one I just edited. I added a fix so if your out of the vehicle you are able to close the radar.

Is this like the speedcamera thats placed on the ground and stationary? Or will this work while driving and not actually spawn an object like the speed camera?

I see what your saying after retesting. It might be the Caps Lock button doing that because it comes up everytime but sometimes it flashes off screen like you pressed the button twice. Im not busy so I will mess around with it.

Okay thanks alot! (char limit)

1 Like

It works like the laser radars would that are on police vehicles. You can use it while driving or on the side of the road. I like the potential with this but its not perfect yet. I am going to be working on it more and see what I can come up with.

Sorry I forgot to change the if IsControlPressed to if IsControlJustPressed it should not be buggy now. Now I need to figure out how to make the radar close after exiting the vehicle…

Thank you let me know when its updated. Appreciate this.

1 Like

This is looking really good.

I appreciate that. I can add my version too that is by the mini map if you want just let me know.

Yeah i would prefer that if you can im using the same street labels so right above that would be perfect!

1 Like

Sure, that would be nice. I wonder how difficult it would be to add a nice GUI around it, similar to DOJ.

1 Like

Ok do you want both mph and kmh or? Just let me know and i can change it around for ya.

I was thinking the same thing lol then it would be best in the bottom right. I didnt wanna bother you with the idea thats why i didnt mention it lol. Maybe a little gray box, saying Police radar then. Here is an example but just more simple like and sleek https://gyazo.com/4ecab3674afd2a9df6d246656fed593e

1 Like

I am 100% sure you can it is just knowing how to… I was thinking about this myself. When I finish getting it to perform how I want it I will start looking into that side of things.

NICE!!! I like that a lot!!

Yeah love that one but its for singleplayer only im pretty sure. Great UI though

Yea that UI is really nice!! Updated the script to my custom one by the mini map. Im thinking of adding kmh back and raising it up a bit.