mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Active vehicles caught by the radar can now be obtained!
This commit is contained in:
40
cl_radar.lua
40
cl_radar.lua
@@ -99,7 +99,9 @@ RADAR.vars =
|
|||||||
|
|
||||||
-- Table to store entity IDs of captured vehicles
|
-- Table to store entity IDs of captured vehicles
|
||||||
RADAR.capturedVehicles = {}
|
RADAR.capturedVehicles = {}
|
||||||
RADAR.caughtEnt = nil
|
|
||||||
|
-- The current vehicle data for display
|
||||||
|
RADAR.activeVehicles = {}
|
||||||
|
|
||||||
-- These vectors are used in the custom ray tracing system
|
-- These vectors are used in the custom ray tracing system
|
||||||
RADAR.rayTraces = {
|
RADAR.rayTraces = {
|
||||||
@@ -175,6 +177,10 @@ function RADAR:GetCapturedVehicles()
|
|||||||
return self.capturedVehicles
|
return self.capturedVehicles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function RADAR:GetActiveVehicles()
|
||||||
|
return self.activeVehicles
|
||||||
|
end
|
||||||
|
|
||||||
function RADAR:SetPatrolSpeed( speed )
|
function RADAR:SetPatrolSpeed( speed )
|
||||||
if ( type( speed ) == "number" ) then
|
if ( type( speed ) == "number" ) then
|
||||||
self.vars.patrolSpeed = speed
|
self.vars.patrolSpeed = speed
|
||||||
@@ -257,6 +263,12 @@ function RADAR:SetFastLimit( limit )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function RADAR:SetActiveVehicles( t )
|
||||||
|
if ( type( t ) == "table" ) then
|
||||||
|
self.activeVehicles = t
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function RADAR:IncreaseRayTraceState()
|
function RADAR:IncreaseRayTraceState()
|
||||||
self.vars.rayTraceState = self.vars.rayTraceState + 1
|
self.vars.rayTraceState = self.vars.rayTraceState + 1
|
||||||
end
|
end
|
||||||
@@ -646,9 +658,9 @@ function RADAR:Main()
|
|||||||
print( "Rear fast veh: " .. tostring( vehsForDisplay[4] ) )
|
print( "Rear fast veh: " .. tostring( vehsForDisplay[4] ) )
|
||||||
print()
|
print()
|
||||||
|
|
||||||
self.caughtEnt = caughtVehs[1]
|
self:SetActiveVehicles( vehsForDisplay )
|
||||||
else
|
else
|
||||||
self.caughtEnt = nil
|
self:SetActiveVehicles( { nil, nil, nil, nil } )
|
||||||
end
|
end
|
||||||
|
|
||||||
UTIL:DebugPrint( "Reached end of stage 1, increasing to stage 2." )
|
UTIL:DebugPrint( "Reached end of stage 1, increasing to stage 2." )
|
||||||
@@ -678,7 +690,7 @@ Citizen.CreateThread( function()
|
|||||||
while ( true ) do
|
while ( true ) do
|
||||||
RADAR:Main()
|
RADAR:Main()
|
||||||
|
|
||||||
Citizen.Wait( 500 )
|
Citizen.Wait( 50 )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
@@ -691,15 +703,27 @@ Citizen.CreateThread( function()
|
|||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
|
local types = { "FRONT", "FRONT FAST", "REAR", "REAR FAST" }
|
||||||
|
|
||||||
Citizen.CreateThread( function()
|
Citizen.CreateThread( function()
|
||||||
while ( true ) do
|
while ( true ) do
|
||||||
-- Caught veh debug printing
|
-- Caught veh debug printing
|
||||||
if ( RADAR.caughtEnt ~= nil ) then
|
local av = RADAR:GetActiveVehicles()
|
||||||
local pos = GetEntityCoords( RADAR.caughtEnt.veh )
|
|
||||||
local speed = GetEntitySpeed( RADAR.caughtEnt.veh )
|
for i = 1, 4, 1 do
|
||||||
|
UTIL:DrawDebugText( 0.200 + ( 0.125 * i ), 0.650, 0.60, true, types[i] )
|
||||||
|
|
||||||
|
if ( av[i] ~= nil ) then
|
||||||
|
local pos = GetEntityCoords( av[i].veh )
|
||||||
|
local speed = RADAR:GetVehSpeedFormatted( GetEntitySpeed( av[i].veh ) )
|
||||||
|
local veh = av[i].veh
|
||||||
|
local rp = av[i].relPos
|
||||||
|
|
||||||
DrawMarker( 2, pos.x, pos.y, pos.z + 3, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 255, 255, 0, 70, false, true, 2, nil, nil, false )
|
DrawMarker( 2, pos.x, pos.y, pos.z + 3, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 255, 255, 0, 70, false, true, 2, nil, nil, false )
|
||||||
UTIL:DrawDebugText( 0.500, 0.700, 0.80, true, "Ent: " .. tostring( RADAR.caughtEnt.veh ) .. "\nSpeed: " .. RADAR:GetVehSpeedFormatted( speed ) .. "mph" .. "\nRel pos: " .. tostring( RADAR.caughtEnt.relPos ) )
|
UTIL:DrawDebugText( 0.200 + ( 0.125 * i ), 0.700, 0.60, true, "Ent: " .. tostring( veh ) .. "\nSpeed: " .. tostring( speed ) .. "mph" .. "\nRel pos: " .. tostring( rp ) )
|
||||||
|
else
|
||||||
|
UTIL:DrawDebugText( 0.200 + ( 0.125 * i ), 0.700, 0.60, true, "Ent: nil" .. "\nSpeed: nil" .. "\nRel pos: nil" )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ray line drawing
|
-- Ray line drawing
|
||||||
|
|||||||
Reference in New Issue
Block a user