Jump to content

Vehicle Damageproof


isa_Khamdan

Recommended Posts

Thats also possible, using the isElementAttached function you can see if an element is attached. :)

That's the code ( it's in another resource )

so how can I check if this element is attached and if yes destroy it? ( check from another resource )

                local x, y, z = getElementPosition ( Vehicle ) 
  
                marker = createObject ( 1318, x, y, z + 2, 0, 0, 0 ) 
  
                attachElements ( marker, Vehicle, 0, 0, 2 ) 

Link to comment
Well if you set data to it, you can retrieve different elements in an area and see if it has the data you're looking for. There might be another way but I'm not sure what way. :(

Okay thanks , can you help me to make this function work when you type a command " start " and when you type it again it will stop.

addEventHandler("onVehicleEnter", Nexus1, 
    function(thePlayer, seat) 
        if seat == 0 then 
            timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) 
        end 
    end 
) 

and if the command is used these two functions will start be enabled

addEventHandler("onVehicleExit", Nexus1, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(timers[source]) then 
                killTimer(timers[source]) 
                timers[source] = nil 
                if isElement(objects[source]) then 
                    destroyElement(objects[source]) 
                    objects[source] = nil 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if isTimer(timers[source]) then 
            killTimer(timers[source]) 
            timers[source] = nil 
            if isElement(objects[source]) then 
                destroyElement(objects[source]) 
                objects[source] = nil 
            end 
        end 
    end 
) 

Link to comment

try this;

addCommandHandler("start", 
    function(thePlayer, command) 
        local v = getPedOccupiedVehicle( thePlayer ) 
        if ( v ) then 
            seat = getPedOccupiedVehicleSeat( thePlayer ) 
            if ( seat == 0 ) then 
                if isTimer(timers[source]) then 
                    killTimer(timers[source]) 
                    timers[source] = nil 
                    if isElement(objects[source]) then 
                        destroyElement(objects[source]) 
                        objects[source] = nil 
                    end 
                else                 
                    timers[thePlayer] = setTimer( D5, 1000, 0, source, thePlayer ) 
                end 
            end 
        else 
            outputChatBox("You've to be in a vehicle to do this!", thePlayer ); 
        end 
    end 
); 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...