From 50355cf81715e6e64f9c5ad7fa7245f5f472a51b Mon Sep 17 00:00:00 2001 From: kookroach Date: Wed, 7 Apr 2021 00:03:10 +0200 Subject: [PATCH] test --- ReallifeGamemode.Client/util/animationSync.ts | 5 ++--- ReallifeGamemode.Server/Util/AnimationSync.cs | 20 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index a56f8f6f..fdbe366b 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -80,15 +80,14 @@ }); }, 100); - mp.events.add("SERVER:QueueAnimations", (JSON_nextAnimations, currentAnimation) => { + mp.events.add("SERVER:QueueAnimations", (currentAnimation) => { let index = mp.game.joaat(currentAnimation); if (!animationSyncData.animations.hasOwnProperty(index)) return; let currentAnim = animationSyncData.animations[index]; let { id, name, animDict, animName, duration, loop, flag } = currentAnim; let interval = setInterval(function () { - mp.gui.chat.push(JSON_nextAnimations); - mp.events.callRemote("CLIENT:AnimPairTransition", JSON_nextAnimations); + mp.events.callRemote("CLIENT:AnimPairTransition"); clearInterval(interval); }, duration); diff --git a/ReallifeGamemode.Server/Util/AnimationSync.cs b/ReallifeGamemode.Server/Util/AnimationSync.cs index e0a1ab89..1b84b74b 100644 --- a/ReallifeGamemode.Server/Util/AnimationSync.cs +++ b/ReallifeGamemode.Server/Util/AnimationSync.cs @@ -9,6 +9,8 @@ namespace ReallifeGamemode.Server.Util { public static class AnimationSync { + public static Dictionary> animationPair = new Dictionary>(); + public static void SyncAnimation(this Player player, dynamic animationName) { if (!player.HasData("Animation")) @@ -28,10 +30,15 @@ namespace ReallifeGamemode.Server.Util { string animationName = animations.ElementAt(0); List nextAnimations = animations.Skip(1).ToList(); + player.SendChatMessage(nextAnimations.ToString()); + player.SyncAnimation(animationName); if (nextAnimations.Count != 0) - player.TriggerEvent("SERVER:QueueAnimations", nextAnimations.ToArray(), animationName); + { + player.TriggerEvent("SERVER:QueueAnimation", animationName); + animationPair.Add(player, nextAnimations); + } } /// Check if Player has any Animation playing. @@ -63,11 +70,14 @@ namespace ReallifeGamemode.Server.Util public class AnimationSyncEvents : Script { [RemoteEvent("CLIENT:AnimPairTransition")] - public void AnimPairTransition(Player player, string JSON_transitionTo) + public void AnimPairTransition(Player player) { - string[] transitionTo = (string[])JsonConvert.DeserializeObject(JSON_transitionTo); - player.SendChatMessage(transitionTo.ToString()); - player.SyncAnimation(transitionTo.ToList()); + if (!AnimationSync.animationPair.ContainsKey(player)) + return; + + List animationPairs = AnimationSync.animationPair[player]; + + player.SyncAnimation(animationPairs); } [RemoteEvent("CLIENT:ClearAnimationData")]