From 0d0ad33ebcf73130eb9a75c9c2b285855db09ea7 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Thu, 6 Jan 2022 13:32:47 -0600 Subject: [PATCH] Fix anims, make some anim utils --- scripts/client/animation.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/client/animation.js b/scripts/client/animation.js index 843b3f32..3838fae4 100644 --- a/scripts/client/animation.js +++ b/scripts/client/animation.js @@ -8,8 +8,9 @@ // =========================================================================== function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, freezePlayer) { + logToConsole(LOG_DEBUG, `[VRR.Animation] Playing animation ${animGroup}/${animId} for ped ${pedId}`); if(getGame() < VRR_GAME_GTA_IV) { - if(animType == VRR_ANIMTYPE_ADD) { + if(animType == VRR_ANIMTYPE_NORMAL) { if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { getElementFromId(pedId).clearAnimations(); } else { @@ -43,6 +44,29 @@ function forcePedAnimation(pedId, animGroup, animId, animType, animSpeed, loop, setLocalPlayerControlState(false, false); getElementFromId(pedId).position = getElementFromId(pedId).position; getElementFromId(pedId).addAnimation(animGroup, animId); + + inAnimation = true; + setLocalPlayerControlState(false, false); + localPlayer.collisionsEnabled = false; + } +} + +// =========================================================================== + +function makePedStopAnimation(pedId) { + if(getElementFromId(pedId) == null) { + return false; + } + + if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { + getElementFromId(pedId).clearAnimations(); + } else { + getElementFromId(pedId).clearObjective(); + } + + if(getElementFromId(pedId) == localPlayer) { + localPlayer.collisionsEnabled = true; + setLocalPlayerControlState(true, false); } }