joedajoester Posted December 7, 2011 Share Posted December 7, 2011 So my script i need to perform the function, Breakoff when the mph is at 0 I get error: then expected near = local parachute = createObject(3131, 0, 0, 0) function Break(thePlayer) if (not isPedInVehicle(thePlayer)) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local handling = getVehicleHandling(vehicle) setElementData(vehicle, "slowing", vehicle) setVehicleHandling(vehicle, "brakeDeceleration", 20.08) setVehicleHandling(vehicle, "tractionMultiplier", 1.08) attachElements(parachute, vehicle, 0, -1.2, -0.1, 80, 0, 0) end addCommandHandler ( "break", Break ) function Breakoff(vehicle) getElementVelocity(vehicle) if mph = 0 then local handling = getElementData(vehicle, "slowing") setVehicleHandling(vehicle, "brakeDeceleration", slowing) setVehicleHandling(vehicle, "tractionMultiplier", slowing) detachElements(parachute) end end Link to comment
Castillo Posted December 7, 2011 Share Posted December 7, 2011 (edited) function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end local parachute = createObject(3131, 0, 0, 0) function Break(thePlayer) if (not isPedInVehicle(thePlayer)) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local handling = getVehicleHandling(vehicle) setElementData(vehicle, "slowing", vehicle) setVehicleHandling(vehicle, "brakeDeceleration", 20.08) setVehicleHandling(vehicle, "tractionMultiplier", 1.08) attachElements(parachute, vehicle, 0, -1.2, -0.1, 80, 0, 0) end addCommandHandler ( "break", Break ) function Breakoff(vehicle) local mph = getElementSpeed(vehicle, "mph") if (tonumber(mph) == 0) then local handling = getElementData(vehicle, "slowing") setVehicleHandling(vehicle, "brakeDeceleration", slowing) setVehicleHandling(vehicle, "tractionMultiplier", slowing) detachElements(parachute) end end Edited December 8, 2011 by Guest Link to comment
joedajoester Posted December 8, 2011 Author Share Posted December 8, 2011 error ) expected near = Link to comment
Castillo Posted December 8, 2011 Share Posted December 8, 2011 I wonder some times if people is just stupid or just cannot think. How I'm supposed to fix it if you don't tell me in what line is the error...? Link to comment
joedajoester Posted December 8, 2011 Author Share Posted December 8, 2011 It doesnt say what line. Link to comment
Evil-Cod3r Posted December 8, 2011 Share Posted December 8, 2011 if (unit =="mph" or unit ==1 or unit =='1') then Link to comment
Castillo Posted December 8, 2011 Share Posted December 8, 2011 if (unit =="mph" or unit ==1 or unit =='1') then That makes no sense, no offense but it has nothing to do with that. @joedajoester: Copy my code again, I found the error. P.S: It does say the line here. Link to comment
joedajoester Posted December 8, 2011 Author Share Posted December 8, 2011 The object does not disappear. And was it line 30? It usually says error at line __ this time it didnt. Link to comment
Castillo Posted December 8, 2011 Share Posted December 8, 2011 It should detach it, not destroy it. Link to comment
joedajoester Posted December 8, 2011 Author Share Posted December 8, 2011 It stays attached to the car. Link to comment
Castillo Posted December 8, 2011 Share Posted December 8, 2011 function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end local parachute = createObject(3131, 0, 0, 0) function Break(thePlayer) if (not isPedInVehicle(thePlayer)) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local handling = getVehicleHandling(vehicle) setElementData(vehicle, "slowing", vehicle) setVehicleHandling(vehicle, "brakeDeceleration", 20.08) setVehicleHandling(vehicle, "tractionMultiplier", 1.08) attachElements(parachute, vehicle, 0, -1.2, -0.1, 80, 0, 0) end addCommandHandler ( "break", Break ) function Breakoff(vehicle) local mph = getElementSpeed(vehicle, "mph") if (tonumber(mph) == 0) then local handling = getElementData(vehicle, "slowing") setVehicleHandling(vehicle, "brakeDeceleration", slowing) setVehicleHandling(vehicle, "tractionMultiplier", slowing) detachElements(parachute, vehicle) end end Link to comment
joedajoester Posted December 8, 2011 Author Share Posted December 8, 2011 It doesnt remove parachute or change the handling back to normal. 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