Fixed a bug that caused boats and aircraft to be detected

This commit is contained in:
Dan
2020-03-25 10:34:42 +00:00
parent f30115d0ac
commit 8bbad1de5d
2 changed files with 51 additions and 4 deletions

View File

@@ -219,7 +219,11 @@ RADAR.vars =
capturedVehicles = {}, capturedVehicles = {},
-- Table for temp id storage to stop unnecessary trace checks -- Table for temp id storage to stop unnecessary trace checks
tempVehicleIDs = {}, -- needs to be redone
-- tempVehicleIDs = {},
-- Table to store the valid vehicle models
validVehicles = {},
-- The current vehicle data for display -- The current vehicle data for display
activeVehicles = {}, activeVehicles = {},
@@ -1291,6 +1295,47 @@ function RADAR:GetVehSpeedConverted( speed )
return UTIL:Round( speed * self.speedConversions[unit], 0 ) return UTIL:Round( speed * self.speedConversions[unit], 0 )
end end
-- Returns the validity of the given vehicle model
function RADAR:GetVehicleValidity( key )
return self.vars.validVehicles[key]
end
-- Sets the validity for the given vehicle model
function RADAR:SetVehicleValidity( key, validity )
self.vars.validVehicles[key] = validity
end
-- Returns if vehicle validity data exists for the given vehicle model
function RADAR:DoesVehicleValidityExist( key )
return self:GetVehicleValidity( key ) ~= nil
end
-- Returns if the given vehicle is valid, as we don't want the radar to detect boats, helicopters, or planes!
function RADAR:IsVehicleValid( veh )
-- Get the model of the vehicle
local mdl = GetEntityModel( veh )
-- Create a key based on the model
local key = tostring( mdl )
-- Check if the vehicle model is valid
local valid = self:GetVehicleValidity( key )
-- If the validity value hasn't been set for the vehicle model, then we do it now
if ( valid == nil ) then
-- If the model is not what we want, then set the validity to false
if ( IsThisModelABoat( mdl ) or IsThisModelAHeli( mdl ) or IsThisModelAPlane( mdl ) ) then
self:SetVehicleValidity( key, false )
return false
else
self:SetVehicleValidity( key, true )
return true
end
end
return valid
end
-- Gathers all of the vehicles in the local area of the player -- Gathers all of the vehicles in the local area of the player
function RADAR:GetAllVehicles() function RADAR:GetAllVehicles()
-- Create a temporary table -- Create a temporary table
@@ -1298,8 +1343,10 @@ function RADAR:GetAllVehicles()
-- Iterate through vehicles -- Iterate through vehicles
for v in UTIL:EnumerateVehicles() do for v in UTIL:EnumerateVehicles() do
-- Insert the vehicle id into the temporary table if ( self:IsVehicleValid( v ) ) then
table.insert( t, v ) -- Insert the vehicle id into the temporary table
table.insert( t, v )
end
end end
-- Return the table -- Return the table

View File

@@ -38,7 +38,7 @@ game "gta5"
name "Wraith ARS 2X" name "Wraith ARS 2X"
description "Police radar and plate reader system for FiveM" description "Police radar and plate reader system for FiveM"
author "WolfKnight" author "WolfKnight"
version "1.1.1" version "1.1.2"
-- Include the files -- Include the files
files { files {