88 lines
2.0 KiB
Lua
88 lines
2.0 KiB
Lua
local alwaysRoll = true
|
|
local ifp = engineLoadIFP("VRolling.ifp","insanity.roll")
|
|
local falling = 0
|
|
local fallingThreshold = 2000
|
|
|
|
function replaceAnims(ped)
|
|
engineReplaceAnimation(ped,"ped","FALL_collapse","insanity.roll","VRolling_Front")
|
|
end
|
|
|
|
function restoreAnims(ped)
|
|
engineRestoreAnimation(ped,"ped","FALL_collapse")
|
|
end
|
|
|
|
addEventHandler("onClientPlayerJoin",root,function()
|
|
replaceAnims(source)
|
|
end)
|
|
|
|
addEventHandler("onClientPlayerSpawn",root,function()
|
|
replaceAnims(source)
|
|
end)
|
|
|
|
addEventHandler("onClientElementStreamIn",root,function()
|
|
if getElementType(source) == "ped" then
|
|
replaceAnims(source)
|
|
end
|
|
end)
|
|
|
|
addEventHandler("onClientResourceStart",resourceRoot,function()
|
|
for _,ped in ipairs(getElementsByType("ped")) do
|
|
replaceAnims(ped)
|
|
end
|
|
|
|
for _,ped in ipairs(getElementsByType("player")) do
|
|
replaceAnims(ped)
|
|
end
|
|
end)
|
|
|
|
|
|
addEventHandler("onClientResourceStop",resourceRoot,function()
|
|
for _,ped in ipairs(getElementsByType("ped")) do
|
|
restoreAnims(ped)
|
|
end
|
|
|
|
for _,ped in ipairs(getElementsByType("player")) do
|
|
restoreAnims(ped)
|
|
end
|
|
end)
|
|
|
|
if alwaysRoll then
|
|
addEventHandler("onClientPlayerDamage",root,function(attacker,damageType)
|
|
if damageType ~= 54 then return end
|
|
setPedAnimation(source,"insanity.roll","VRolling_Front",-1,false,true,false,false,0,true)
|
|
falling = 0
|
|
end)
|
|
|
|
addEventHandler("onClientPreRender",root,function(slice)
|
|
for _,ped in ipairs(getElementsByType("player")) do
|
|
setPedAnimationSpeed(localPlayer,"VRolling_Front",1.4)
|
|
if isPedWearingJetpack(localPlayer) then
|
|
falling = 0
|
|
return
|
|
end
|
|
|
|
if isPedDead(localPlayer) then
|
|
falling = 0
|
|
return
|
|
end
|
|
|
|
if isElementInWater(localPlayer) then
|
|
falling = 0
|
|
return
|
|
end
|
|
|
|
if getPedMoveState(localPlayer) == "fall" then
|
|
falling = falling + slice
|
|
return
|
|
end
|
|
|
|
if getPedMoveState(localPlayer) ~= "climb" then
|
|
if falling > fallingThreshold then
|
|
setPedAnimation(localPlayer,"insanity.roll","VRolling_Front",-1,false,true,false,false,0,true)
|
|
end
|
|
end
|
|
|
|
falling = 0
|
|
end
|
|
end)
|
|
end |