I created "RepairMarkers" and when player hits any of them, their car's health must to increase. But I don't know, how to check every marker here:
if isElementWithinMarker( getLocalPlayer(), RepairMarker[1] ) then
Instead of "RepairMarker[1]" I want to check every marker
Source:
function CreateMarkers( thePlayer, seat )
if thePlayer == getLocalPlayer() and seat == 0 then
BaysideRM = createMarker( -2259.027, 2386.142, 3.897, "cylinder", 3, 233, 96, 21, 100 )
Area69SkyRM = createMarker( 307.876, 2051.747, 16.587, "cylinder", 5, 233, 96, 21, 100 )
RepairMarker = { BaysideRM, Area69SkyRM }
end
end
function RepairVehicle( hitPlayer, matchingDimension )
if hitPlayer == getLocalPlayer() and matchingDimension == true then
local theVehicle = getPedOccupiedVehicle( getLocalPlayer() )
local VehicleHealth = getElementHealth( theVehicle )
local RepairHealth = math.floor( VehicleHealth )
function Repair()
if isElementWithinMarker( getLocalPlayer(), RepairMarker[1] ) then
if RepairHealth < 1000 then
RepairHealth = RepairHealth + 1
setElementHealth( theVehicle, RepairHealth )
else
fixVehicle( theVehicle )
playSFX( "script", 11, 1, false )
end
else
killTimer( RepairTimer )
end
end
if VehicleHealth < 1000 then
RepairTimer = setTimer( Repair, 100, 1001 - math.floor( VehicleHealth ) )
end
end
end
function DestroyMarkers( thePlayer, seat )
if thePlayer == getLocalPlayer() and seat == 0 then
for i, v in ipairs( RepairMarker ) do
destroyElement( RepairMarker[i] )
end
end
end
addEventHandler( "onClientMarkerHit", getRootElement(), RepairVehicle )
addEventHandler( "onClientVehicleEnter", getRootElement(), CreateMarkers )
addEventHandler( "onClientVehicleExit", getRootElement(), DestroyMarkers )