Jump to content

Anybody can help me with this?


mgdmgd

Recommended Posts

  • Discord Moderators

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
  • Discord Moderators

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

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
  • Discord Moderators

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

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