Jump to content

HELP!!


Timiimit

Recommended Posts

Hi!

i have made script but it doesn't work. it was supose to make that when you are in air and in vehicle when you press f your vehicle starts to fly and when pressed w you are able to hover on water.what i have:

  
function makeSpecial() 
    if isVehicleOnGround == false then 
        if getControlState ( source, "steer_forward" ) = "down" then 
             
            if isWorldSpecialPropertyEnabled ( "hovercars" ) then 
                setWorldSpecialPropertyEnabled ( "hovercars", false ) 
            else 
                setWorldSpecialPropertyEnabled ( "hovercars", enabled ) 
            end 
        end 
    end 
    elseif isVehicleOnGround == false then 
        if  getControlState ( source, "enter_exit" ) = "down" then 
            if isWorldSpecialPropertyEnabled ( "aircars" ) then 
                setWorldSpecialPropertyEnabled ( "aircars", false ) 
            else 
                setWorldSpecialPropertyEnabled ( "aircars", enabled ) 
            end 
        end 
    end 
end 
  

(i dont konw if it works) i get error:

SCRIPT ERROR: myscript\special.lua:3 'then' expected near '='

thx!

Link to comment

Check comment, and I simplified your code.

  
function makeSpecial() 
    if isVehicleOnGround == false then --this function must use arguments! Click on it (it will be highlighted)! 
        if getControlState ( source, "steer_forward" ) == "down" then 
            setWorldSpecialPropertyEnabled ( "hovercars", not isWorldSpecialPropertyEnabled ( "hovercars" ) ) 
        elseif  getControlState ( source, "enter_exit" ) == "down" then 
            setWorldSpecialPropertyEnabled ( "aircars", not isWorldSpecialPropertyEnabled ( "aircars" ) ) 
        end 
    end 
end 
  

Link to comment

I don't understand how this function works or why there must be argumants. please HELP!!

Now i changed script a bit. what I have:

  
function checkVeh ( vehicle, seat, hover ) 
  
    if isVehicleOnGround ( vehicle ) == false then 
                    setWorldSpecialPropertyEnabled ( "hovercars", not isWorldSpecialPropertyEnabled ( "hovercars" ) ) 
                end 
    end 
  
  
    if isVehicleOnGround ( vehicle ) == false then 
                    setWorldSpecialPropertyEnabled ( "aircars", not isWorldSpecialPropertyEnabled ( "aircars" ) ) 
                end 
    end 
  
end 
addEventHandler ( "onPlayerJoin", getRootElement(), bindTheKey) 
function bindTheKey() 
     vehName = getVehicleName ( vehicle ) 
     bind("rshift", "down", checkVeh) 
     bind("rctrl", "down", checkVeh) 
end 
  

it also says that in 9th line needs to be '' near 'end'.

Link to comment

This is client-side only!

function checkVeh ( player, key ) 
    if not getPedOccupiedVehicle ( player ) then return end --Stop if player is not in vehicle 
    if not isVehicleOnGround ( getPedOccupiedVehicle ( player ) ) then 
        if key == "f" then setWorldSpecialPropertyEnabled ( "aircars", not isWorldSpecialPropertyEnabled ( "aircars" ) ) 
        elseif key == "w" then setWorldSpecialPropertyEnabled ( "hovercars", not isWorldSpecialPropertyEnabled ( "hovercars" ) ) end 
    end 
end 
  
function bindTheKey() 
     bindKey ( "f", "down", checkVeh ) 
     bindKey ( "w", "down", checkVeh ) 
end 
addEventHandler ( "onClientPlayerJoin", getRootElement(), bindTheKey) 

It should work...

Link to comment

How could it possibly work?

You need to use the event "onClientResourceStart" instead of "onClientPlayerJoin" because if you'd read the wiki you'd know it isn't fired for the joining player, BUT for the rest of the players in the server

addEventHandler ( "onClientResourceStart", getResourceRootElement(), bindTheKey)

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