Jump to content

help


joedajoester

Recommended Posts

Posted

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 

Posted (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 by Guest
Posted

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...?

Posted
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.

Posted
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 

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...