Hi guys,
I’m creating a new Police Radar system
I’ve got a big problem, when the cars move out from the front of my car i loose istantaneously their speed (if i don’t block it that is a feature that i’m programming now).
I’ve tried to use Wait(1000), but the radar just appear and disappear every 1 second. Can you help me?
Code:
while true do
Wait(0)
if IsControlJustPressed(1, 128) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) and not IsPedInAnyHeli(GetPlayerPed(-1)) then
if radar.shown then
radar.shown = false
radar.info = string.format("--")
radar.info2 = string.format("--")
radar.info3 = string.format("--")
else
radar.shown = true
end
end
if IsControlJustPressed(1, 127) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) and not IsPedInAnyHeli(GetPlayerPed(-1)) then
PlaySoundFrontend(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 0,0,1)
if radar.freeze then
radar.freeze = false
else
radar.freeze = true
end
end
if radar.shown then
if radar.freeze == false then
local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
local coordA = GetOffsetFromEntityInWorldCoords(veh, 0.0, 1.0, 1.0)
local coordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, 105.0, 0.0)
local frontcar = StartShapeTestCapsule(coordA, coordB, 3.0, 10, veh, 7)
local a, b, c, d, e = GetShapeTestResult(frontcar)
if IsEntityAVehicle(e) then
local fmodel = GetDisplayNameFromVehicleModel(GetEntityModel(e))
local fvspeed = GetEntitySpeed(e)*3.6
local fplate = GetVehicleNumberPlateText(e)
radar.info = string.format("%s", math.ceil(fvspeed))
else
local fvspeed = '--'
radar.info = string.format("%s", fvspeed)
end
local bcoordB = GetOffsetFromEntityInWorldCoords(veh, 0.0, -105.0, 0.0)
local rearcar = StartShapeTestCapsule(coordA, bcoordB, 3.0, 10, veh, 7)
local f, g, h, i, j = GetShapeTestResult(rearcar)
if IsEntityAVehicle(j) then
local bmodel = GetDisplayNameFromVehicleModel(GetEntityModel(j))
local bvspeed = GetEntitySpeed(j)*3.6
local bplate = GetVehicleNumberPlateText(j)
radar.info2 = string.format("%s", math.ceil(bvspeed))
else
local bvspeed = '--'
radar.info2 = string.format("%s", bvspeed)
end
end
The plugin is based on another plugin outsurce. I’m just editing it to fit my needs