Jump to content

Fixing help


Timiimit

Recommended Posts

Hi!

i'm making today yet another topic.

This one is about Fixing vehicles.

So this is what i have:

  
 function vehFix ( source ) 
    theVehicle = getVehicleOccupant ( source ) 
    fixVehicle ( theVehicle ) 
end 
  
setTimer ( vehFix, 3000, 0 ) 
  

its not working!

it should fix vehicle player is in every 3 sec(if you know how to make it when vehicle gets damaged please tell me).

Link to comment

not working.

errors:

  
[2012-01-27 16:43:32] WARNING: myscripts\vehFix.lua:2: Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1) 
[2012-01-27 16:43:32] WARNING: myscripts\vehFix.lua:4: Bad argument @ 'getElementHealth' 
[2012-01-27 16:43:32] ERROR: myscripts\vehFix.lua:4: attempt to perform arithmetic on a boolean value 
  

Link to comment
    function vehFix ( thePlayer) 
    theVehicle = getPedOccupiedVehicle ( thePlayer )--Checks if the player is in the vehicle. 
    if (theVehicle) then --If it is in the vehicle fix it 
        fixVehicle(theVehicle) 
    end  
    end 
    addEventHandler("onVehicleDamage",getRootElement(),vehFix)-- Turining on vehFix when vehicle crash 
    setTimer(vehFix, 1000, 1) -- Will be fix the vehicle every second. 

Link to comment

Like that ?

  
function vehFix(thePlayer) 
    if thePlayer then 
        theVehicle = getPedOccupiedVehicle(thePlayer) 
        if theVehicle then 
            local domage = getElementHealth ( theVehicle ) 
            if domage < 100 then 
                fixVehicle(theVehicle) 
            end 
        end 
    end 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function() 
    for i, player in ipairs(getElementsByType("player"))do 
        setTimer(vehFix, 1000, 0, player) 
    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...