mgdmgd Posted June 11, 2016 Share Posted June 11, 2016 Hey guys, can somebody give me the resource for anti-bunnyhopping? like when you jump while running you fall on the ground, to add it in roleplay server and thanks. Link to comment
Dimos7 Posted June 12, 2016 Share Posted June 12, 2016 I think that is you ask for function bunnyhope() if isWorldSpecialPropertyEnabled("extrabuny") then --- put that amunations or what you want here end end Link to comment
mgdmgd Posted June 12, 2016 Author Share Posted June 12, 2016 Made it like that but didn't work function bunnyhope() if isWorldSpecialPropertyEnabled("extrabuny") then setPedAnimation( ped1, "ped", "FALL_front") end end Link to comment
Dimos7 Posted June 12, 2016 Share Posted June 12, 2016 function bunnyhope() if isWorldSpecialPropertyEnabled("extrabuny") then setPedAnimation(localPlayer, "ped", "FALL_front") end end Link to comment
Discord Moderators AlexTMjugador Posted June 13, 2016 Discord Moderators Share Posted June 13, 2016 I don't know what resource you are talking about, but you can use the following scripting functions to achieve the effect you describe pretty easily: getPedMoveState -- To get if the player is running/jumping/falling/whatever toggleControl -- To block the player ability to jump and/or move and restore it setPedAnimation -- To apply a falling animation if you want to By the way, that special world property is related to additional bike jump height and NOT to jumping over and over while running to go faster. Link to comment
Dimos7 Posted June 13, 2016 Share Posted June 13, 2016 function antiBunnyHoppe() if getPedMoveState(localPlayer) == "Jamp" and getPedMoveState(localPlayer) == "Sprint" then setPedAnimation(localPlayer, "ped', "FALL_front") end end Link to comment
Discord Moderators AlexTMjugador Posted June 13, 2016 Discord Moderators Share Posted June 13, 2016 Your code has a syntax error and it won't work even if you fix it because getPedMoveState can't return two different values at the same time. Use something like this instead: local wasSprinting local function antiBunnyHopping() local moveState = getPedMoveState(localPlayer) if moveState == "sprint" then -- The player is sprinting wasSprinting = true return elseif wasSprinting and moveState == "jump" then -- The player was sprinting and now jumps. Don't let him do that setPedAnimation(localPlayer, "ped", "FALL_front") end -- If we get here, the player is not sprinting, so take that into account or the next frame wasSprinting = nil end addEventHandler("onClientPreRender", root, antiBunnyHopping) Link to comment
mgdmgd Posted June 14, 2016 Author Share Posted June 14, 2016 Your code has a syntax error and it won't work even if you fix it because getPedMoveState can't return two different values at the same time. Use something like this instead: local wasSprinting local function antiBunnyHopping() local moveState = getPedMoveState(localPlayer) if moveState == "sprint" then -- The player is sprinting wasSprinting = true return elseif wasSprinting and moveState == "jump" then -- The player was sprinting and now jumps. Don't let him do that setPedAnimation(localPlayer, "ped", "FALL_front") end -- If we get here, the player is not sprinting, so take that into account or the next frame wasSprinting = nil end addEventHandler("onClientPreRender", root, antiBunnyHopping) Used it and still when i run and jump i don't fall or anything Link to comment
Dimos7 Posted June 14, 2016 Share Posted June 14, 2016 local Sprinting = nil function antiBunnyHopping() local moveState = getPedMoveState(localPlayer) if moveState == "sprint" then Sprinting = true elseif Sprinting == true and moveState == "jump" then setPedAnimation(localPlayer, "ped", "FALL_front") end Sprinting = false setPedAnimation(localPlayer, false) end addEventHandler("onClientPreRender", root, antiBunnyHopping) Link to comment
Discord Moderators AlexTMjugador Posted June 14, 2016 Discord Moderators Share Posted June 14, 2016 The code structure I posted works, but for some reason the animation isn't applied properly and therefore it seems that the script is not working. However, using a timer properly seems to fix this. Try this code: local wasSprinting local function antiBunnyHopping() local moveState = getPedMoveState(localPlayer) if moveState == "sprint" then -- The player is sprinting wasSprinting = true return elseif wasSprinting and moveState == "jump" then -- The player was sprinting and now jumps. Don't let him do that by applying an animation -- (Delaying the animation a bit seems necessary to achieve the effect we want) setTimer(setPedAnimation, 50, 1, localPlayer, "ped", "FALL_collapse", -1, false, true, false, false) end -- If we get here, the player is not sprinting, so take that into account or the next frame and remove animations if we should wasSprinting = nil end addEventHandler("onClientPreRender", root, antiBunnyHopping) It blocks the player from sprinting and jumping altogether, but you can modify it so it suits your personal preferences better. For example, you could let the player jump some times but block them from doing so if they do it too much, or things like that. Link to comment
mgdmgd Posted June 14, 2016 Author Share Posted June 14, 2016 Can you add me skype @AlexTMjugador? mgd.azam3 Link to comment
Discord Moderators AlexTMjugador Posted June 14, 2016 Discord Moderators Share Posted June 14, 2016 I won't, I don't like adding unknown people to Skype. Sorry. I tested again the script under various FPS limits (25 FPS cap, 50 FPS cap and 100 FPS cap) and it works just fine. Check that you have defined the script as clientside in the meta.xml file, like this: <script src="script_name_here.lua" type="client"/> Other than that, I don't really know what could be preventing the code from doing its job in your computer (providing that you know what a resource is and where to put that code, of course). Link to comment
mgdmgd Posted June 14, 2016 Author Share Posted June 14, 2016 I had the type server lol, Thanks man you're really awesome <3 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