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). in game nickname: [GFL]TimiimiT
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) Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
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 in game nickname: [GFL]TimiimiT
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) Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
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. My resources : playerpartFromName: Exported function.
BriGhtx3 Posted January 27, 2012 Posted January 27, 2012 Klesh, wont work (again) vehFix needs arguments. You cant just use thePlayer without declaring it Currently working on gamemodes : Reallife Script 70% Breakout Script 10%
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) Paid developer. Twitter: @willia_am - http://www.williamdasilva.fr
Timiimit Posted January 28, 2012 Author Posted January 28, 2012 Ok i fixed the script thx anyway! in game nickname: [GFL]TimiimiT
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