Timiimit Posted January 27, 2012 Posted January 27, 2012 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).
BriGhtx3 Posted January 27, 2012 Posted January 27, 2012 function vehFix ( loss ) theVehicle = getPedOccupiedVehicle ( source ) thePlayer = getVehicleOccupant( source ) setElementHealth(theVehicle,getElementHealth(theVehicle)+tonumber(loss)) end addEventHandler("onVehicleDamage",getRootElement(),vehFix)
Timiimit Posted January 27, 2012 Author Posted January 27, 2012 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
BriGhtx3 Posted January 27, 2012 Posted January 27, 2012 function vehFix ( loss ) thePlayer = getVehicleOccupant( source ) theVehicle = getPedOccupiedVehicle ( thePlayer ) setElementHealth(theVehicle,getElementHealth(theVehicle)+tonumber(loss)) end addEventHandler("onVehicleDamage",getRootElement(),vehFix)
Klesh Posted January 27, 2012 Posted January 27, 2012 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.
BriGhtx3 Posted January 27, 2012 Posted January 27, 2012 Klesh, wont work (again) vehFix needs arguments. You cant just use thePlayer without declaring it
FatalTerror Posted January 27, 2012 Posted January 27, 2012 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now