[Release] Speedcamera


@Cosmo you are amazing!!!
Should I be able to just paste the GetNearPlayerSpeed into the .lua file for Speed Cam or do i need separate resource folders?




this should be my last bothersome post to you Cosmo :wink: you’ve been most helpful. Is there a way to extend the area of effect for the scanner? It seems the original has a very small range and requires being close proximity to use.


change the 10.0 to like 40.0


For me nothing happen when i press caps lock :confused:


same, I’ve been trying aswell


My bad… shoulda tested it first lol. The problem is in line 2.

local radar = {shown = false, freeze - false, info = "none", minSpeed = 10.0, maxSpeed = 40.0}

Should be freeze = false, I accidently typed - (minus). I’ll update the code I posted above. Also the position is a little off which I will change and I’ll add a wait to Caps Lock because if you hold it down it freaks out.

Besides that, it seems to be working great. @Ryan68 @Twitter_Tweets


Hi guys does this works on player’s cars? cause last time i tried it, it was only working on ped’s cars


@Cosmo Here’s a link to the .lua I made by pasting the script. Can you please take a look and make sure it’s correct. I’m not a programmer and i have no scripting experience. Thanks in advance!



The link you provided is for delete vehicle?


@Cosmo yes it should be

EDIT: I was very busy and not paying attention apparently (to the file i posted, or the message you sent for that matter). I’m happy to report that this was user error. If i push [Cap Lock] a gray box appears at the top of the screen and appears to be bugged. But after around 30 seconds it starts working properly and automatically after scanning a moving vehicle (AI). I’m not sure exactly where the scan player portion should go in the script.



Trying with this but no success :

	while true do
		if IsControlPressed(1, 217) then
			local play = GetEntityPlayerIsFreeAimingAt(GetPlayerPed(-1))
			local pos = GetEntityCoords(play)
			local carM = GetClosestVehicle(pos['x'], pos['y'], pos['z'], 10.0,0,70)
			if carM ~=nil then
				local plate=GetVehicleNumberPlateText(carM)
				local SpeedKm= GetEntitySpeed(carM)*(3.6)
				if SpeedKm > minSpeed then		
					info = string.format("~b~Plaque :~w~ %s ~n~~y~Km/h : ~r~%s",plate,math.ceil(SpeedKm))
				drawTxt(0.12,1.03,0.185,0.206, 0.40, info, 255,255,255,255)


That worked great @Cosmo , i can scan 4 lanes of US 13


Hey @Cosmo Where at in the speedcamera.lua would I drop the lines of code for the getnearplayerspeed?
Thanks in advance


So this is fixed for players now?? Ain’t no way


can everyone on the server use this? how can it be restricted to police only if it isn’t already?


@Clod_TIF is there any reason why it looks like you abandoned this? Did you ever get it working for players?


I changed the way it detects vehicles, I think it should fix the problem with players cars.

I used the solution provided here:

--script by devilkkw
local maxSpeed= 40.0
local minSpeed= 10.0
local info ="nope"

function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(1, 0, 0, 0, 255)
    DrawText(x - width/2, y - height/2 + 0.005)

    while true do
          if IsControlPressed(1, 217)then	-- 217 	INPUT_FRONTEND_SELECT (CapsLock)
            local pos = GetEntityCoords(GetPlayerPed(-1))
             local carM = GetCurrentTargetCar()
             if carM ~=nil then
                  local plate=GetVehicleNumberPlateText(carM)
                  local herSpeedKm= GetEntitySpeed(carM)*3.6
                  local herSpeedMph= GetEntitySpeed(carM)*2.236936
             if herSpeedKm > minSpeed then             
                if herSpeedKm < maxSpeed then
                  info = string.format("~b~Plate:~w~ %s ~n~~y~Km/h: ~g~%s~n~~y~Mph: ~g~%s",plate,math.ceil(herSpeedKm),math.ceil(herSpeedMph) )
                  info = string.format("~b~Plate:~w~ %s ~n~~y~Km/h: ~r~%s~n~~y~Mph: ~r~%s",plate,math.ceil(herSpeedKm),math.ceil(herSpeedMph) )
                 drawTxt(0.55,0.1,0.185,0.206, 0.40, info, 255,255,255,255)

function GetCurrentTargetCar()
    local ped = GetPlayerPed(-1)
    local coords = GetEntityCoords(ped)
    local entityWorld = GetOffsetFromEntityInWorldCoords(ped, 0.0, 120.0, 0.0)
    local rayHandle = CastRayPointToPoint(coords.x, coords.y, coords.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, ped, 0)
    local a, b, c, d, vehicleHandle = GetRaycastResult(rayHandle)

    return vehicleHandle

It uses GetRaycastResult (you need to target the vehicle) instead of GetClosestVehicle.

Scripts idea for police role playing communities

very nice it work pefectly


seems to work but disappears so fast anyway to get it to scan then freeze at highest speed. also how to set distance to pick up speed?


You can set the distance by changing the value 120.0 in this line:

local entityWorld = GetOffsetFromEntityInWorldCoords(ped, 0.0, 120.0, 0.0)

The smaller, the shorter.
As I can see, this script wasn’t designed to hold the speed, you need to see the car and hold the key to get informations.