stefutz101 Posted March 4, 2016 Share Posted March 4, 2016 repairTimer = {} function repairVehicle (veh) if repairTimer[veh] then triggerClientEvent (source, "displayClientInfo", source,"Vehicle",getVehicleName(veh).." is currently being repaired!",255,22,0) return end if isElement(veh) and getElementType(veh)=="vehicle" then local health = math.floor(getElementHealth(veh)) repairTimer[veh] = setTimer(fixVehicleDayZ,(1000-health)*120,1,veh,source) setElementFrozen (veh,true) setElementData(veh,"repairer",source) setElementData(source,"repairingvehicle",veh) setPedAnimation (source,"SCRATCHING","sclng_r",nil,true,false) triggerClientEvent (source, "displayClientInfo", source,"Vehicle","You started to repair "..getVehicleName(veh),22,255,0) end end addEvent("repairVehicle",true) addEventHandler("repairVehicle",getRootElement(),repairVehicle) function fixVehicleDayZ(veh,player) setElementHealth(veh,1000) fixVehicle (veh) setPedAnimation(player,false) setElementFrozen (veh,false) repairTimer[veh] = nil setElementData(veh,"repairer",nil) setElementData(player,"repairingvehicle",nil) triggerClientEvent (player, "displayClientInfo", player,"Vehicle","You finished repairing "..getVehicleName(veh),22,255,0) end How i can test if vehicle explode then stop repair process ? With this functions if you start repair a car and it explode it will fix car anyway .. so i want to fix this thing. I try like this ... function stopFixxingWhileMoving(veh) if isElement(veh) and getElementType(veh)=="vehicle" then setPedAnimation(player,false) setElementFrozen (veh,false) repairTimer[veh] = nil setElementData(veh,"repairer",nil) setElementData(player,"repairingvehicle",nil) end end addEventHandler("onVehicleExplode",getRootElement(),stopFixxingWhileMoving) Thanks in advance ! Link to comment
KariiiM Posted March 4, 2016 Share Posted March 4, 2016 "onVehicleExplode" event has no parameters, so what you had done with your code is incorrect. Try that, function stopFixxingWhileMoving() if isElement(source) and getElementType(source)=="vehicle" then setPedAnimation(player,false) setElementFrozen (source,false) repairTimer[source] = nil setElementData(source,"repairer",nil) setElementData(player,"repairingvehicle",nil) end end addEventHandler("onVehicleExplode",getRootElement(),stopFixxingWhileMoving) Link to comment
stefutz101 Posted March 4, 2016 Author Share Posted March 4, 2016 I already try that ... It stopped at that if ... Link to comment
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