From e1f6f62ada58c5d0d15ff08cdf79c001781392d4 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 18 Dec 2022 15:21:39 -0600 Subject: [PATCH] Don't permasync non-looped anims --- scripts/server/animation.js | 30 ++++++++++++++++++------------ scripts/server/netevents.js | 4 +++- scripts/shared/gamedata.js | 4 ++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/scripts/server/animation.js b/scripts/server/animation.js index ce41a7a4..23befe41 100644 --- a/scripts/server/animation.js +++ b/scripts/server/animation.js @@ -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); diff --git a/scripts/server/netevents.js b/scripts/server/netevents.js index 5088731c..a8f31c04 100644 --- a/scripts/server/netevents.js +++ b/scripts/server/netevents.js @@ -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); } diff --git a/scripts/shared/gamedata.js b/scripts/shared/gamedata.js index 082fc057..87f48ca0 100644 --- a/scripts/shared/gamedata.js +++ b/scripts/shared/gamedata.js @@ -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;