Don't permasync non-looped anims

This commit is contained in:
Vortrex
2022-12-18 15:21:39 -06:00
parent 59d41f8482
commit e1f6f62ada
3 changed files with 23 additions and 15 deletions

View File

@@ -44,8 +44,10 @@ function playPlayerAnimationCommand(command, params, client) {
return false;
}
if (hasPlayerSeenActionTip(client, "AnimationStop")) {
messagePlayerTip(client, getGroupedLocaleString(client, "ActionTips", "AnimationStop", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
if (getAnimationData(animationSlot).loop == true) {
if (hasPlayerSeenActionTip(client, "AnimationStop")) {
messagePlayerTip(client, getGroupedLocaleString(client, "ActionTips", "AnimationStop", "{ALTCOLOUR}/stopanim{MAINCOLOUR}"));
}
}
makePlayerPlayAnimation(client, animationSlot, animationPositionOffset);
}
@@ -95,11 +97,13 @@ function isPlayerInForcedAnimation(client) {
// ===========================================================================
function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
if (getAnimationData(animationSlot).loop == true) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = false;
}
makePedPlayAnimation(getPlayerPed(client), animationSlot, offsetPosition);
//setEntityData(getPlayerPed(client), "agrp.anim", animationSlot, true);
@@ -113,11 +117,13 @@ function makePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
// ===========================================================================
function forcePlayerPlayAnimation(client, animationSlot, offsetPosition = 1) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
if (getAnimationData(animationSlot).loop == true) {
getPlayerData(client).currentAnimation = animationSlot;
getPlayerData(client).currentAnimationPositionOffset = offsetPosition;
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp();
getPlayerData(client).animationForced = true;
}
setPlayerControlState(client, false);
forcePedAnimation(getPlayerPed(client), animationSlot, offsetPosition);

View File

@@ -1012,7 +1012,9 @@ function sendPlayerEnterPropertyKey(client, key) {
// ===========================================================================
function makePedPlayAnimation(ped, animationSlot, positionOffset) {
setEntityData(ped, "agrp.anim", animationSlot, true);
if (getAnimationData(animationSlot).loop == true) {
setEntityData(ped, "agrp.anim", animationSlot, true);
}
sendNetworkEventToPlayer("agrp.anim", null, getPedForNetworkEvent(ped), animationSlot, positionOffset);
}

View File

@@ -16,8 +16,8 @@ class AnimationData {
this.animType = (typeof data.animType != "undefined") ? data.animType : AGRP_ANIMTYPE_NORMAL;
this.animSpeed = (typeof data.animSpeed != "undefined") ? data.animSpeed : 0.0;
this.moveType = (typeof data.moveType != "undefined") ? data.moveType : AGRP_ANIMMOVE_NONE;
this.duration = -1;
this.loop = true;
this.loop = (typeof data.moveType != "undefined") ? data.moveType : false;
this.duration = (typeof data.duration != "undefined") ? data.duration : -1;
// GTA IV
this.infiniteLoop = (typeof data.infiniteLoop != "undefined") ? data.infiniteLoop : false;