[Release] Speedcamera

Pretty sure if u press “E” When you have it open, it will freeze it, if its not in the original versions then there is an Haddon version I believe in the comments :wink:

Has anyone got this to work on vrp?

Thank you @Cosmo, to contribute to his, I extended it with some features:

--script by devilkkw
--edited by BlockBa5her

--don't touch this stuffz
local radar = 
{
	shown = false, 
	freeze = false, 
	info = "none", 
--touch stuffz here plz if u want idc
	minSpeed = 2.0,
	maxSpeed = 50.0,
	radius = 10.0
--now don't touch below!
}
local lastVeh = 
{
	plate = "NULL", 
	model = "NULL",
	kmh = 0.0, 
	mph = 0.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/2, y - height/2 + 0.005)
end

function setInfo()
	local freezeTxt
	if radar.freeze then
		freezeTxt = "~g~T"
	else
		freezeTxt = "~r~F"
	end
	if lastVeh.mph < radar.maxSpeed then
		radar.info = string.format("~b~Plate:~w~ %s ~n~~y~Km/h: ~g~%s~n~~y~Mph: ~g~%s~n~~w~Model: ~y~%s~n~~w~Frozen: %s", lastVeh.plate, math.ceil(lastVeh.kmh), math.ceil(lastVeh.mph), lastVeh.model, freezeTxt) 
	else
		radar.info = string.format("~b~Plate:~w~ %s ~n~~y~Km/h: ~r~%s~n~~y~Mph: ~r~%s~n~~w~Model: ~y~%s~n~~w~Frozen: %s", lastVeh.plate, math.ceil(lastVeh.kmh), math.ceil(lastVeh.mph), lastVeh.model, freezeTxt) 
	end
end

Citizen.CreateThread(function()
	while true do
		Wait(0)
		if IsControlJustReleased(1, 217)then -- Caps Lock
			radar.shown = not radar.shown
                        Wait(75)
		end
		if IsControlJustReleased(1, 38) and radar.shown then -- E
			radar.freeze = not radar.freeze
		end
		if radar.shown then
			if radar.freeze == false then
				local pos = GetEntityCoords(GetPlayerPed(-1))
				local carM = GetClosestVehicle(pos['x'], pos['y'], pos['z'], radar.radius,0,70)
				if carM ~= nil then
					local plate = GetVehicleNumberPlateText(carM)
					local vehSpeedKM = GetEntitySpeed(carM)*3.6
					local vehSpeedMph = GetEntitySpeed(carM)*2.236936
					
					if vehSpeedMph > radar.minSpeed then			  
						lastVeh.plate = plate
						lastVeh.kmh = vehSpeedKM
						lastVeh.mph = vehSpeedMph
						lastVeh.model = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(carM)))
						
					end
				end
			end
			setInfo()
			DrawRect(0.5,0.0,0.12,0.30,0,10,28,210)
            drawTxt(0.54,0.15,0.185,0.306,0.40,radar.info,255,255,255,255)
		end
	end  
end)

Add-ons

  • Frozen now displays in game
  • Radius now settable
  • Shows the model of the car you are looking at
  • Cleaner code

Installation

Again, just replace speedcamera.lua with the code in this post :slight_smile:

looks like you took a lot of the stuff @DankVybez did and is given him no credit and saying you did the work…

TBH I didn’t even see that thread until you mentioned it. So I didn’t steal anything, I gave credit to who I saw edited on it the original poster’s thread. Sorry that you feel this :neutral_face:.

EDIT: I can tell you really like him tho…

Yea like the comments back from him… Thanks for pointing out that I appreciate his work… You should do the same!

Well I see that he is making script, that is great, I am just telling you that I am not copying his work and stealing his ideas. I am just going off of what @Cosmo said above.

1 Like

Ok, just an observation. I maybe wrong or right! If im wrong my bad, if im right well I said my words. Otherwise im gpne!

1 Like

Hey bud from what I had tested the GetClosestVehicle wasn’t picking up players only AI so I had to change it to Raycast. Just a heads up.

It seemed fine to me. I did work on it some more and change it to raycast so that it only picks up thing infront of the vehicle and not everywhere around it though.

1 Like

If you are using it as a radar that would be used in a police vehicle that is accurate on how a radar would work.

What system are you guys using for the keycodes? I can’t seem to find which one it is, I want to update the buttons but don’t know which keycode is accurate for the button I want.

7 - l
8 - s
9 - d
10 - Page up
11 - Page down
12 - mouse move down
13 - mouse move right
18 - space or enter
19 - L Alt
20 - z
21 - L Shift
23 - f
32 - w
34 - a
36 - L Ctrl
39 - [
40 - ]
44 - q
45 - r
51 - e
56 - F9
57 - F10
58 - g
60 - num pad 5
61 - num pad 8
197 - ]
199 - p
202 - Backspace
205 - q
206 - e
209 - L Shift
211 - tab
213 - home
214 - del
215 - enter
216 - spacebar
217 - Caps lock
224 - L Ctrl
232 - w
233 - s
234 - a
235 - d
236 - v
239 - Cam +
240 - Cam -
241 and 242 for the mouse wheel up and down.
243 - ~
244 - m
245 - t
246 - y
249 - n
329 - LMouseBtn
330 - 331 - RMouseBtn

These should help.

https://wiki.fivem.net/wiki/Controls

1 Like

call in your .yml with “- speedcamera” how do i do this step?

The police can only see this right?

what is the key to active the speed camera

I wish that only those who were in the group of police had access to this radar, and not all players, is it possible? Would you help me?

Scroll up