test
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public static class AnimationSync
|
||||
{
|
||||
public static Dictionary<Player, List<string>> animationPair = new Dictionary<Player, List<string>>();
|
||||
|
||||
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<string> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>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<string>());
|
||||
if (!AnimationSync.animationPair.ContainsKey(player))
|
||||
return;
|
||||
|
||||
List<string> animationPairs = AnimationSync.animationPair[player];
|
||||
|
||||
player.SyncAnimation(animationPairs);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ClearAnimationData")]
|
||||
|
||||
Reference in New Issue
Block a user