docs: add more cl_player.lua comments

This commit is contained in:
Dan
2021-03-16 20:13:32 +00:00
parent 6c28d4d327
commit f6663d8455

View File

@@ -42,6 +42,7 @@ PLY =
vehClassValid = false vehClassValid = false
} }
-- Returns if the current vehicle fits the validity requirements for the radar to work
function PLY:VehicleStateValid() function PLY:VehicleStateValid()
return DoesEntityExist( self.veh ) and self.veh > 0 and self.vehClassValid return DoesEntityExist( self.veh ) and self.veh > 0 and self.vehClassValid
end end
@@ -78,6 +79,7 @@ function PLY:GetOtherPed()
return nil return nil
end end
-- Returns the server ID of the player in the opposite seat (driver/passenger)
function PLY:GetOtherPedServerId() function PLY:GetOtherPedServerId()
local otherPed = self:GetOtherPed() local otherPed = self:GetOtherPed()
@@ -105,18 +107,26 @@ Citizen.CreateThread( function()
end end
end ) end )
-- This thread is used to check when the player is entering a vehicle and then triggers the sync system
Citizen.CreateThread( function() Citizen.CreateThread( function()
while ( true ) do while ( true ) do
-- The sync trigger should only start when the player is getting into a vehicle
if ( IsPedGettingIntoAVehicle( PLY.ped ) ) then if ( IsPedGettingIntoAVehicle( PLY.ped ) ) then
-- Get the vehicle the player is entering
local vehEntering = GetVehiclePedIsEntering( PLY.ped ) local vehEntering = GetVehiclePedIsEntering( PLY.ped )
Citizen.Wait( 2000 ) -- Only proceed if the vehicle the player is entering is an emergency vehicle
if ( GetVehicleClass( vehEntering ) == 18 ) then if ( GetVehicleClass( vehEntering ) == 18 ) then
-- Wait two seconds, this gives enough time for the player to get sat in the seat
Citizen.Wait( 2000 )
local veh = GetVehiclePedIsIn( PLY.ped, false ) -- Get the vehicle the player is now in
local veh = GetVehiclePedIsIn( PLY.ped, false )
if ( veh == vehEntering ) then -- Trigger the main sync data function if the vehicle the player is now in is the same as the one they
SYNC:SyncDataOnEnter() -- began entering
if ( veh == vehEntering ) then
SYNC:SyncDataOnEnter()
end end
end end
end end