Jump to content

help


joedajoester

Recommended Posts

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
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 by Guest
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...