test
This commit is contained in:
@@ -80,15 +80,14 @@
|
|||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
mp.events.add("SERVER:QueueAnimations", (JSON_nextAnimations, currentAnimation) => {
|
mp.events.add("SERVER:QueueAnimations", (currentAnimation) => {
|
||||||
let index = mp.game.joaat(currentAnimation);
|
let index = mp.game.joaat(currentAnimation);
|
||||||
if (!animationSyncData.animations.hasOwnProperty(index)) return;
|
if (!animationSyncData.animations.hasOwnProperty(index)) return;
|
||||||
let currentAnim = animationSyncData.animations[index];
|
let currentAnim = animationSyncData.animations[index];
|
||||||
let { id, name, animDict, animName, duration, loop, flag } = currentAnim;
|
let { id, name, animDict, animName, duration, loop, flag } = currentAnim;
|
||||||
|
|
||||||
let interval = setInterval(function () {
|
let interval = setInterval(function () {
|
||||||
mp.gui.chat.push(JSON_nextAnimations);
|
mp.events.callRemote("CLIENT:AnimPairTransition");
|
||||||
mp.events.callRemote("CLIENT:AnimPairTransition", JSON_nextAnimations);
|
|
||||||
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
}, duration);
|
}, duration);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ namespace ReallifeGamemode.Server.Util
|
|||||||
{
|
{
|
||||||
public static class AnimationSync
|
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)
|
public static void SyncAnimation(this Player player, dynamic animationName)
|
||||||
{
|
{
|
||||||
if (!player.HasData("Animation"))
|
if (!player.HasData("Animation"))
|
||||||
@@ -28,10 +30,15 @@ namespace ReallifeGamemode.Server.Util
|
|||||||
{
|
{
|
||||||
string animationName = animations.ElementAt(0);
|
string animationName = animations.ElementAt(0);
|
||||||
List<string> nextAnimations = animations.Skip(1).ToList();
|
List<string> nextAnimations = animations.Skip(1).ToList();
|
||||||
|
player.SendChatMessage(nextAnimations.ToString());
|
||||||
|
|
||||||
player.SyncAnimation(animationName);
|
player.SyncAnimation(animationName);
|
||||||
|
|
||||||
if (nextAnimations.Count != 0)
|
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.
|
/// <summary>Check if Player has any Animation playing.
|
||||||
@@ -63,11 +70,14 @@ namespace ReallifeGamemode.Server.Util
|
|||||||
public class AnimationSyncEvents : Script
|
public class AnimationSyncEvents : Script
|
||||||
{
|
{
|
||||||
[RemoteEvent("CLIENT:AnimPairTransition")]
|
[RemoteEvent("CLIENT:AnimPairTransition")]
|
||||||
public void AnimPairTransition(Player player, string JSON_transitionTo)
|
public void AnimPairTransition(Player player)
|
||||||
{
|
{
|
||||||
string[] transitionTo = (string[])JsonConvert.DeserializeObject(JSON_transitionTo);
|
if (!AnimationSync.animationPair.ContainsKey(player))
|
||||||
player.SendChatMessage(transitionTo.ToString());
|
return;
|
||||||
player.SyncAnimation(transitionTo.ToList<string>());
|
|
||||||
|
List<string> animationPairs = AnimationSync.animationPair[player];
|
||||||
|
|
||||||
|
player.SyncAnimation(animationPairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:ClearAnimationData")]
|
[RemoteEvent("CLIENT:ClearAnimationData")]
|
||||||
|
|||||||
Reference in New Issue
Block a user