joedajoester Posted December 7, 2011 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
Castillo Posted December 7, 2011 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted December 8, 2011 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...? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Evil-Cod3r Posted December 8, 2011 Posted December 8, 2011 if (unit =="mph" or unit ==1 or unit =='1') then My in-game nick is |['Dev-PoinT_SA']| addEventHandler ( "onPlayerSpawn", getRootElement(), function() if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then triggerClientEvent("BlaBlaBla",getRootElement()) DxDrawText("Hi Dev-PoinT") end end)
Castillo Posted December 8, 2011 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
joedajoester Posted December 8, 2011 Author Posted December 8, 2011 The object does not disappear. And was it line 30? It usually says error at line __ this time it didnt.
Castillo Posted December 8, 2011 Posted December 8, 2011 It should detach it, not destroy it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted December 8, 2011 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
joedajoester Posted December 8, 2011 Author Posted December 8, 2011 It doesnt remove parachute or change the handling back to normal.
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