Jump to content

ragdoll


yoya99

Recommended Posts

how to make out of that a ragdoll part when i leave a vehicle with a speed of 50 or more?

local ragdollEnabled = false; 
  
addEventHandler( 'onClientRender', root, 
    function() 
    local a, b, c, d = getPedTask(localPlayer, "primary", 1) 
        if a == "TASK_COMPLEX_IN_AIR_AND_LAND" and b == "TASK_SIMPLE_IN_AIR" then 
            if ragdollEnabled == false then 
                ragdollEnabled = true; 
                addEventHandler('onClientPreRender', root, rotate); 
                addEventHandler('onClientPreRender', root, eliminateProblems); 
            end 
        elseif a == "TASK_COMPLEX_IN_AIR_AND_LAND" and b == "TASK_SIMPLE_FALL" then -- m: TASK_SIMPLE_LAND, TASK_SIMPLE_GET_UP 
            if ragdollEnabled == true then 
                ragdollEnabled = false; 
                setElementHealth(localPlayer, 0) -- kill 
                --local x, y, z = getElementPosition(localPlayer) 
                --setElementPosition(localPlayer, x, y, z+4) 
                local x, y, z = getElementVelocity(localPlayer) 
                removeEventHandler('onClientPreRender', root, rotate); 
                removeEventHandler('onClientPreRender', root, eliminateProblems); 
            end 
        end 
    end 
) 
  
-- just fixes rotation problems 
function eliminateProblems() 
    for k,v in ipairs ( getElementsByType ( "player" ) ) do 
        if not isPedOnGround(v) then 
            local a, b, c, d = getPedTask(v, "primary", 1) 
            if a == "TASK_COMPLEX_IN_AIR_AND_LAND" and b == "TASK_SIMPLE_IN_AIR" then 
                --if isElementStreamedIn ( v ) then 
                    local rx, ry, rz  = getElementRotation(v) 
                    setElementRotation(v, rx, 0, rz) 
                --end 
            end 
        end 
    end 
end 
  
-- our ragdoll imiation simple isn't it?  but effect is cool 
function rotate() 
    for k,v in ipairs ( getElementsByType ( "player" ) ) do 
        if not isPedOnGround(v) then 
            local a, b, c, d = getPedTask(v, "primary", 1) 
            if a == "TASK_COMPLEX_IN_AIR_AND_LAND" and b == "TASK_SIMPLE_IN_AIR" then 
                --if isElementStreamedIn ( v ) then 
                    local rx, ry, rz = getElementRotation(v); 
                    setElementRotation(v, rx + 6.4, ry, rz + math.random(1.1,1.4)); 
                --end 
            end 
        end 
    end 
end; 
  

Link to comment
  • 5 years later...

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