Bilal135 Posted November 12, 2014 Posted November 12, 2014 Hi guys, I was making a script, that when we press button "z" our vehicle jumps. But I got one error. My code: function vehicleJump() bindKey(source, "z", "down", "jump", local vehicle = getPedOccupiedVehicle(source) if (isVehicleOnGround(vehicle) == true) then local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.4) end end ) addEvent("onSpecialEvent", true) addEventHandler("onSpecialEvent", root, vehicleJump) Error: vehiclejump\vehjump.lua:3: unexpected symbol near 'local' I can't understand what's the error, please tell me what wrong I did. "Get busy living or get busy dying"
SkatCh Posted November 12, 2014 Posted November 12, 2014 lol just add this ')' . function vehicleJump() bindKey(source, "z", "down", "jump", -- like this bindKey(source, "z", "down", jump) local vehicle = getPedOccupiedVehicle(source) if (isVehicleOnGround(vehicle) == true) then local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.4) end end ) addEvent("onSpecialEvent", true) addEventHandler("onSpecialEvent", root, vehicleJump) Failure is simply an opportunity to begin again more intelligently - Henry Ford
Bilal135 Posted November 13, 2014 Author Posted November 13, 2014 function myPlayer(Player) bindKey(source, "z", "down", "jump") local vehicle = getPedOccupiedVehicle(Player) if (isVehicleOnGround(vehicle) == true) then local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.4) end end addEvent("onSpecialEvent", true) addEventHandler("onSpecialEvent", root, vehicleJump) Error: Expected function at argument 3 got nil. "Get busy living or get busy dying"
Anubhav Posted November 13, 2014 Posted November 13, 2014 Dude it's common sense. The vehicleJump is not defined and not is a function. Replace it with myPlayer + remember to trigger Player! See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Bilal135 Posted November 13, 2014 Author Posted November 13, 2014 It doesn't show any error now, but still when I press "z", my car does not jump. function myPlayer(Player) bindKey(Player, "z", "down", "jump") local vehicle = getPedOccupiedVehicle(Player) if (isVehicleOnGround(vehicle) == true) then local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.4) end end addEvent("onSpecialEvent", true) addEventHandler("onSpecialEvent", root, myPlayer) "Get busy living or get busy dying"
Et-win Posted November 13, 2014 Posted November 13, 2014 function myPlayer(Player) bindKey(Player, "z", "down", jumpFunction) end function jumpFunction() --Stuff end ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Bilal135 Posted November 13, 2014 Author Posted November 13, 2014 function myPlayer(Player) bindKey(Player, "z", "down", jumpFunction) end function jumpFunction() local vehicle = getPedOccupiedVehicle(source) local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.7) end Doesn't give any errors, but when I press z, my car doesn't jump. I've tried the same with addCommandHandler which works perfectly. function jumpFunction(player) local vehicle = getPedOccupiedVehicle(player) local sx,sy,sz = getElementVelocity(vehicle) setElementVelocity(vehicle ,sx, sy, sz+0.7) end addCommandHandler("jump", jumpFunction) I think I'm doing something wrong with bindKey? "Get busy living or get busy dying"
Et-win Posted November 13, 2014 Posted November 13, 2014 I hoped you would look into bindKey to atleast know you have to pass the player. function jumpFunction(thePlayer) local vehicle = getPedOccupiedVehicle(thePlayer) ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Bilal135 Posted November 13, 2014 Author Posted November 13, 2014 I hoped you would look into bindKey to atleast know you have to pass the player. function jumpFunction(thePlayer) local vehicle = getPedOccupiedVehicle(thePlayer) Sorry, I didn't get what you wanted to say. "Get busy living or get busy dying"
Anubhav Posted November 13, 2014 Posted November 13, 2014 You din't define source. See bindKey for more information. See the argument's it passes! See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Et-win Posted November 13, 2014 Posted November 13, 2014 If you look what I changed in that two lines then you know.. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
SkatCh Posted November 13, 2014 Posted November 13, 2014 ??? all what you need is function jump() local vehicle = getPedOccupiedVehicle(localPlayer) local Controller = getVehicleController ( localPlayer ) if getVehicleController(getPedOccupiedVehicle(localPlayer)) == localPlayer then if ( isElement(vehicle) ) and (isVehicleOnGround( vehicle )) then local sx,sy,sz = getElementVelocity ( vehicle ) setElementVelocity( vehicle ,sx, sy, sz+0.7) end end end bindKey ( "z","down", jump) Failure is simply an opportunity to begin again more intelligently - Henry Ford
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