Timiimit Posted December 13, 2011 Share Posted December 13, 2011 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
12p Posted December 13, 2011 Share Posted December 13, 2011 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
Cadu12 Posted December 13, 2011 Share Posted December 13, 2011 https://wiki.multitheftauto.com/wiki/IsVehicleOnGround isVehicleOnGround ( vehicle theVehicle ) Take a look Example, that you need vehicle Link to comment
Timiimit Posted December 14, 2011 Author Share Posted December 14, 2011 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
12p Posted December 14, 2011 Share Posted December 14, 2011 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
Timiimit Posted December 19, 2011 Author Share Posted December 19, 2011 ...but it's not. Link to comment
BinSlayer1 Posted December 19, 2011 Share Posted December 19, 2011 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
12p Posted December 19, 2011 Share Posted December 19, 2011 Damn, BinSlayer1 is right 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