Jump to content

Randesady

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Randesady

  1. 14 minutes ago, IIYAMA said:
    
    function isElementWithinMarkers (element, markers)
    	for i=1, #markers do
    		if isElementWithinMarker(element, markers[i]) then
    			return true
    		end 
    	end
    	return false
    end 
    
    
    if isElementWithinMarkers( getLocalPlayer(), RepairMarker ) then
    

     

    Syntax:

    
    bool isElementWithinMarkers( element theElement, table markers )
    

     

    By looping through all markers and check if the element is in one of the markers. If that is true, then break the loop with the return keyword and send true back.

    Note: (different name)

    isElementWithinMarker + s

     

    Like that? It doesn't work

    	function Repair()
                for i = 1, 2 do
                    if isElementWithinMarker( getLocalPlayer(), RepairMarker[i] ) then
                        if RepairHealth < 1000 then
                            RepairHealth = RepairHealth + 1
                            setElementHealth( theVehicle, RepairHealth )
                        else
                            fixVehicle( theVehicle )
                            playSFX( "script", 11, 1, false )
                        end
                        return true
                    else
                        killTimer( RepairTimer )
                        return true
                    end
                    return false
                end
            end

     

  2. 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 )

     

×
×
  • Create New...