--[[ The DOJ inspired Radar system By BlockBa5her Released and protected under the GPL-3.0 License ]] -- Touch the below up until "the line" --[[ CONTROLS: F9 to open X to freeze PGUP & PGDOWN to change fast speed (simple as that really) (also, must be in a vehicle for it to work) ]] local settings = { minSpeed = 2.0, -- will not count vehicle if under this speed drawDistance = 250.0, -- how far the radar will look for cars ahead of it speedInKmh = false, -- If enabled, then it will display speed in KMH, otherwise, MPH playSound = true, -- Plays a sound if the car in front go above the fast speed limit speedInterval = 5.0 -- Amount that the fast speed changed when you change it in game } local whitelist = { vehs = { -- make sure these are upper, and have quotes "POLICE", "POLICE2", "POLICE3", "POLICE4", "POLICE5", "POLICE6", "POLICE7", "POLICE8", "HWAYCAR", "HWAYCAR2", "HWAYCAR3", "HWAYCAR4", "HWAYCAR5", "HWAYCAR6", "hwaycar7", "HWAYCAR8", "HWAYCAR9", "HWAYCAR10", "PD", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "CVPI", "CVPI2", "CVPI3", "UM5", "UM4", "PRANGER", "SHERIFF", "EXPRESS", "SHERIFF2", "FBI", "FBI2", "POLICEB", }, enable = false -- if enabled, then will check if the vehicle that the player is driving is the same as one of above } --[[ DON'T TOUCH BELOW THE LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ------------------------------------------------------------------------------------------------- ]] -- fields n shit local radar = { shown = false, freeze = false, fastSpeed = 50.0 } local lastVeh = { frwd = { plate = "NULL", model = "NULL", speed = 0.0 }, bckwd = { plate = "NULL", model = "NULL", speed = 0.0 } } local lastVehFast = { plate = "NULL", model = "NULL", speed = 0.0 } -- common funcs that i need function notify(string) SetNotificationTextEntry("STRING") AddTextComponentString(string) DrawNotification(true, false) end local function drawTxt(x,y ,width,height,scale, font, text, r,g,b,a) SetTextFont(font) SetTextProportional(0) SetTextScale(scale, scale) SetTextColour(r, g, b, a) SetTextDropShadow() SetTextOutline() SetTextEntry("STRING") AddTextComponentString(text) DrawText(x - width/2, y - height/2 + 0.005) end local function drawTxt2(xy, wh, scale, font, text, rgba, align) if align == 2 then SetTextRightJustify(true) SetTextWrap(0, xy[1]) end if align == 1 then SetTextCentre(true) end drawTxt(xy[1], xy[2], wh[1], wh[2], scale, font, text, rgba[1], rgba[2], rgba[3], rgba[4]) end local function drawRect(xy, wh, rgba) DrawRect(xy[1], xy[2], wh[1], wh[2], rgba[1], rgba[2], rgba[3], rgba[4]) end local function DrawRaycast(entity) local coords = GetOffsetFromEntityInWorldCoords(entity,0.0,1.0,0.3) local coords2 = GetOffsetFromEntityInWorldCoords(entity, 0.0, settings.drawDistance,0.0) local rayhandle = CastRayPointToPoint(coords, coords2, 10, entity, 0) local _, _, _, _, entityHit = GetRaycastResult(rayhandle) if entityHit>0 and IsEntityAVehicle(entityHit) then return entityHit else return nil end end local function DrawRaycastBackward(entity) local coords = GetOffsetFromEntityInWorldCoords(entity,0.0,1.0,0.3) local coords2 = GetOffsetFromEntityInWorldCoords(entity, 0.0, settings.drawDistance*-1,0.0) local rayhandle = CastRayPointToPoint(coords, coords2, 10, entity, 0) local _, _, _, _, entityHit = GetRaycastResult(rayhandle) if entityHit>0 and IsEntityAVehicle(entityHit) then return entityHit else return nil end end local function has_value (tab, val) for index, value in ipairs(tab) do if value == val then return true end end return false end local function getBoolText(bool) if bool then return "~g~True" else return "~r~False" end end local function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end -- rendering the radar local function renderRadar() local masterDraw = {0.75, 0.9175} local titleDraw = {masterDraw[1], masterDraw[2] - 0.0775} local element1Draw = {masterDraw[1] - 0.175, masterDraw[2] - 0.0475} local element2Draw = {masterDraw[1] - 0.0625, masterDraw[2] - 0.0475} local element3Draw = {masterDraw[1] + 0.0625, masterDraw[2] - 0.0475} local element4Draw = {masterDraw[1] + 0.175, masterDraw[2] - 0.0475} -- main box drawRect({0.846, 0.922}, {0.23, 0.1}, {0,0,0,100}) drawRect({0.926, 0.847}, {0.07, 0.05}, {0,0,0,100}) drawRect({masterDraw[1],masterDraw[2]}, {0.5, 0.165}, {0,0,0,0}) -- pause txt if radar.freeze then drawTxt2({0.999,0.97}, {0.01, 0.01}, 0.45, 4, "PAUSED", {255,255,255,255}, 2) end -- menu text drawTxt2({titleDraw[1], titleDraw[2]}, {0.01, 0.01}, 0.45, 1, "", {255,255,255,255}, 1) -- veh text -- FRWD drawTxt2({0.77, 0.885}, {0.01, 0.01}, 0.4, 4, "~b~FRONT", {255,255,255,255}, 1) -- Speed TXT drawTxt2({0.77, 0.915}, {0.01, 0.01}, 0.7, 4, string.format("%s", tostring(round(lastVeh.frwd.speed, 2))), {255,255,255,255}, 1) -- veh text -- BKWD drawTxt2({0.85, 0.885}, {0.01, 0.01}, 0.4, 4, "~b~BACK", {255,255,255,255}, 1) -- Speed TXT drawTxt2({0.85, 0.915}, {0.01, 0.01}, 0.7, 4, string.format("%s", tostring(round(lastVeh.bckwd.speed, 2))), {255,255,255,255}, 1) -- fast text -- FAST drawTxt2({0.93, 0.885}, {0.01, 0.01}, 0.4, 4, "~r~LOCK", {255,255,255,255}, 1) -- Speed TXT drawTxt2({0.93, 0.915}, {0.01, 0.01}, 0.7, 4, string.format("%s", tostring(round(lastVehFast.speed, 2))), {255,255,255,255}, 1) -- Fast Speed Display drawTxt2({0.93, 0.83}, {0.01, 0.01}, 0.25, 0, "~g~LIMIT", {255,255,255,255}, 1) drawTxt2({0.93, 0.85}, {0.01, 0.01}, 0.25, 0, string.format("~b~%s~w~", radar.fastSpeed), {255,255,255,255}, 1) end -- logic (the musician) Citizen.CreateThread(function() while true do Wait(0) local _whitelist = false if whitelist.enable == true and IsPedInAnyVehicle(GetPlayerPed(-1), false) then if has_value(whitelist.vehs, GetDisplayNameFromVehicleModel(GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(-1), false)))) then _whitelist = true end end if whitelist.enable == false and IsPedInAnyVehicle(GetPlayerPed(-1), false) then _whitelist = true end if IsControlJustReleased(1, 56) and _whitelist then -- G radar.shown = not radar.shown radar.freeze = false Wait(75) end if IsControlJustReleased(1, 73) and _whitelist then -- X radar.freeze = not radar.freeze end if IsControlJustReleased(1, 10) and _whitelist then radar.fastSpeed = radar.fastSpeed + settings.speedInterval end if IsControlJustReleased(1, 11) and _whitelist then radar.fastSpeed = radar.fastSpeed - settings.speedInterval end if radar.shown and _whitelist then if radar.freeze == false then local carM = DrawRaycast(GetPlayerPed(-1)) local carM2 = DrawRaycastBackward(GetPlayerPed(-1)) --[[ FORWARD RAYCAST STUFF ]] if carM ~= nil then local plate = GetVehicleNumberPlateText(carM) local vehSpeedKM = GetEntitySpeed(carM)*3.6 local vehSpeedMph = GetEntitySpeed(carM)*2.236936 if vehSpeedMph > settings.minSpeed then lastVeh.frwd.plate = plate if settings.speedInKmh then lastVeh.frwd.speed = vehSpeedKM else lastVeh.frwd.speed = vehSpeedMph end lastVeh.frwd.model = string.upper(GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(carM)))) if lastVeh.frwd.speed > radar.fastSpeed then if lastVehFast.plate ~= lastVeh.frwd.plate and settings.playSound then -- Prevents from playing sound over and over again PlaySoundFrontend(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS") notify(string.format("~y~%s ~w~/ ~s", "~s~Model: ~y~" .. lastVehFast.model .. " ~s~Plate Num: ~y~" .. lastVehFast.plate .. " ~s~Speed: ~y~" .. lastVehFast.speed)) end lastVehFast.plate = lastVeh.frwd.plate lastVehFast.model = lastVeh.frwd.model lastVehFast.speed = lastVeh.frwd.speed end end end --[[ BACKWARD RAYCAST STUFF ]] if carM2 ~= nil then local plate = GetVehicleNumberPlateText(carM2) local vehSpeedKM = GetEntitySpeed(carM2)*3.6 local vehSpeedMph = GetEntitySpeed(carM2)*2.236936 if vehSpeedMph > settings.minSpeed then lastVeh.bckwd.plate = plate if settings.speedInKmh then lastVeh.bckwd.speed = vehSpeedKM else lastVeh.bckwd.speed = vehSpeedMph end lastVeh.bckwd.model = string.upper(GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(carM2)))) if lastVeh.bckwd.speed > radar.fastSpeed then if lastVehFast.plate ~= lastVeh.bckwd.plate and settings.playSound then -- Prevents from playing sound over and over again PlaySoundFrontend(-1, "Beep_Red", "DLC_HEIST_HACKING_SNAKE_SOUNDS") notify(string.format("~y~%s ~w~/ ~s", "~s~Model: ~y~" .. lastVehFast.model .. " ~s~Plate Num: ~y~" .. lastVehFast.plate .. " ~s~Speed: ~y~" .. lastVehFast.speed)) end lastVehFast.plate = lastVeh.bckwd.plate lastVehFast.model = lastVeh.bckwd.model lastVehFast.speed = lastVeh.bckwd.speed end end end end renderRadar() end end end)