mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Changed the way debugging hits works
This commit is contained in:
@@ -402,8 +402,8 @@ function RADAR:Test()
|
|||||||
|
|
||||||
-- Check the vehicle actually exists and that the player is in the driver's seat
|
-- Check the vehicle actually exists and that the player is in the driver's seat
|
||||||
if ( DoesEntityExist( plyVeh ) and GetPedInVehicleSeat( plyVeh, -1 ) ) then
|
if ( DoesEntityExist( plyVeh ) and GetPedInVehicleSeat( plyVeh, -1 ) ) then
|
||||||
local startPoint = GetOffsetFromEntityInWorldCoords( plyVeh, 0.0, 5.0, 0.0 )
|
local startPoint = GetOffsetFromEntityInWorldCoords( plyVeh, 0.0, -5.0, 0.0 )
|
||||||
local endPoint = GetOffsetFromEntityInWorldCoords( plyVeh, 0.0, 50.0, 1.0 )
|
local endPoint = GetOffsetFromEntityInWorldCoords( plyVeh, 0.0, -50.0, 1.0 )
|
||||||
DrawLine( startPoint, endPoint, 0, 255, 0, 255 )
|
DrawLine( startPoint, endPoint, 0, 255, 0, 255 )
|
||||||
|
|
||||||
--for veh in EnumerateVehicles() do
|
--for veh in EnumerateVehicles() do
|
||||||
@@ -481,6 +481,9 @@ function RADAR:Test()
|
|||||||
-- end
|
-- end
|
||||||
|
|
||||||
-- Fourth attempt
|
-- Fourth attempt
|
||||||
|
local offset = GetOffsetFromEntityGivenWorldCoords( veh, startPoint )
|
||||||
|
UTIL:DrawDebugText( 0.500, 0.550, 0.50, true, tostring( offset ) )
|
||||||
|
|
||||||
local radius = 10.0
|
local radius = 10.0
|
||||||
local radiusSqr = radius * radius
|
local radiusSqr = radius * radius
|
||||||
|
|
||||||
|
|||||||
44
cl_radar.lua
44
cl_radar.lua
@@ -9,9 +9,12 @@ local next = next
|
|||||||
local dot = dot
|
local dot = dot
|
||||||
local table = table
|
local table = table
|
||||||
local type = type
|
local type = type
|
||||||
|
local tostring = tostring
|
||||||
|
local math = math
|
||||||
|
|
||||||
--[[------------------------------------------------------------------------
|
--[[------------------------------------------------------------------------
|
||||||
Resource Rename Fix
|
Resource Rename Fix - for those muppets who rename the resource and
|
||||||
|
complain that the NUI aspect doesn't work!
|
||||||
------------------------------------------------------------------------]]--
|
------------------------------------------------------------------------]]--
|
||||||
Citizen.CreateThread( function()
|
Citizen.CreateThread( function()
|
||||||
-- Wait for a short period of time to give the resource time to load
|
-- Wait for a short period of time to give the resource time to load
|
||||||
@@ -30,16 +33,22 @@ end )
|
|||||||
------------------------------------------------------------------------]]--
|
------------------------------------------------------------------------]]--
|
||||||
RADAR.vars =
|
RADAR.vars =
|
||||||
{
|
{
|
||||||
-- Player's vehicle speed
|
-- Player's vehicle speed, this is used to update the patrol vehicle speed on the radar
|
||||||
patrolSpeed = 0,
|
patrolSpeed = 0,
|
||||||
|
|
||||||
-- The speed type
|
-- The speed type, this is used when converting speeds to a readable format
|
||||||
|
-- Either "mph" or "kmh"
|
||||||
speedType = "mph",
|
speedType = "mph",
|
||||||
|
|
||||||
-- Antennas
|
-- Antennas, this table contains all of the data needed for operation of the front and rear antennas
|
||||||
antennas = {
|
antennas = {
|
||||||
|
-- Variables for the front antenna
|
||||||
front = {
|
front = {
|
||||||
|
-- Xmit, whether the antenna is on or off
|
||||||
|
-- true of false
|
||||||
xmit = false,
|
xmit = false,
|
||||||
|
|
||||||
|
-- Mode, what the front
|
||||||
mode = 0, -- 0 = off, 1 = same, 2 = opp, 3 = same and opp
|
mode = 0, -- 0 = off, 1 = same, 2 = opp, 3 = same and opp
|
||||||
speed = 0,
|
speed = 0,
|
||||||
dir = nil,
|
dir = nil,
|
||||||
@@ -74,7 +83,8 @@ RADAR.vars =
|
|||||||
-- Radar stage, this is used to tell the system what it should currently be doing, the stages are:
|
-- Radar stage, this is used to tell the system what it should currently be doing, the stages are:
|
||||||
-- - 0 = Gathering vehicles hit by the radar
|
-- - 0 = Gathering vehicles hit by the radar
|
||||||
-- - 1 = Filtering the vehicles caught
|
-- - 1 = Filtering the vehicles caught
|
||||||
-- - 2 = Calculating what vehicle speed to show based on modes
|
-- - 2 = Calculating what vehicle speed to show based on modes and settings
|
||||||
|
-- - 3 = Sending all required data across to the NUI system for display
|
||||||
radarStage = 0,
|
radarStage = 0,
|
||||||
|
|
||||||
-- Ray stage
|
-- Ray stage
|
||||||
@@ -86,7 +96,7 @@ RADAR.vars =
|
|||||||
|
|
||||||
-- Table to store entity IDs of captured vehicles
|
-- Table to store entity IDs of captured vehicles
|
||||||
RADAR.capturedVehicles = {}
|
RADAR.capturedVehicles = {}
|
||||||
RADAR.caughtEnt = 0
|
RADAR.caughtEnt = nil
|
||||||
|
|
||||||
RADAR.rayTraces = {
|
RADAR.rayTraces = {
|
||||||
{ startVec = { x = 0.0, y = 5.0 }, endVec = { x = 0.0, y = 150.0 } },
|
{ startVec = { x = 0.0, y = 5.0 }, endVec = { x = 0.0, y = 150.0 } },
|
||||||
@@ -456,9 +466,9 @@ function RADAR:Main()
|
|||||||
UTIL:DebugPrint( tostring( k ) .. " - " .. tostring( v.veh ) .. " - " .. tostring( v.relPos ) .. " - " .. tostring( v.dist ) .. " - " .. tostring( v.speed ) .. " - " .. tostring( v.size ) )
|
UTIL:DebugPrint( tostring( k ) .. " - " .. tostring( v.veh ) .. " - " .. tostring( v.relPos ) .. " - " .. tostring( v.dist ) .. " - " .. tostring( v.speed ) .. " - " .. tostring( v.size ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
self.caughtEnt = caughtVehs[1].veh
|
self.caughtEnt = caughtVehs[1]
|
||||||
else
|
else
|
||||||
self.caughtEnt = 0
|
self.caughtEnt = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
self:ResetRadarStage()
|
self:ResetRadarStage()
|
||||||
@@ -500,12 +510,24 @@ end )
|
|||||||
|
|
||||||
Citizen.CreateThread( function()
|
Citizen.CreateThread( function()
|
||||||
while ( true ) do
|
while ( true ) do
|
||||||
local pos = GetEntityCoords( RADAR.caughtEnt )
|
-- Caught veh debug printing
|
||||||
local speed = GetEntitySpeed( RADAR.caughtEnt )
|
if ( RADAR.caughtEnt ~= nil ) then
|
||||||
|
local pos = GetEntityCoords( RADAR.caughtEnt.veh )
|
||||||
|
local speed = GetEntitySpeed( RADAR.caughtEnt.veh )
|
||||||
|
|
||||||
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 ) )
|
||||||
|
end
|
||||||
|
|
||||||
UTIL:DrawDebugText( 0.500, 0.700, 0.80, true, "Ent: " .. tostring( RADAR.caughtEnt ) .. "\nSpeed: " .. RADAR:GetVehSpeedFormatted( speed ) .. "mph" )
|
-- Ray line drawing
|
||||||
|
local veh = GetVehiclePedIsIn( PlayerPedId(), false )
|
||||||
|
|
||||||
|
for k, v in pairs( RADAR.rayTraces ) do
|
||||||
|
local startP = GetOffsetFromEntityInWorldCoords( veh, v.startVec.x, 0.0, 0.0 )
|
||||||
|
local endP = GetOffsetFromEntityInWorldCoords( veh, v.endVec.x, v.endVec.y, 0.0 )
|
||||||
|
|
||||||
|
UTIL:DrawDebugLine( startP, endP )
|
||||||
|
end
|
||||||
|
|
||||||
Citizen.Wait( 0 )
|
Citizen.Wait( 0 )
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user