Fix anims, make some anim utils

This commit is contained in:
Vortrex
2022-01-06 13:32:47 -06:00
parent 9148b05dd2
commit 0d0ad33ebc

View File

@@ -8,8 +8,9 @@
// =========================================================================== // ===========================================================================
function makePedPlayAnimation(pedId, animGroup, animId, animType, animSpeed, loop, loopNoControl, freezeLastFrame, returnToOriginalPosition, freezePlayer) { 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(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) { if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) {
getElementFromId(pedId).clearAnimations(); getElementFromId(pedId).clearAnimations();
} else { } else {
@@ -43,6 +44,29 @@ function forcePedAnimation(pedId, animGroup, animId, animType, animSpeed, loop,
setLocalPlayerControlState(false, false); setLocalPlayerControlState(false, false);
getElementFromId(pedId).position = getElementFromId(pedId).position; getElementFromId(pedId).position = getElementFromId(pedId).position;
getElementFromId(pedId).addAnimation(animGroup, animId); 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);
} }
} }