49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using GTANetworkAPI;
|
|
|
|
namespace ReallifeGamemode.Server.Util
|
|
{
|
|
public static class AnimationSync
|
|
{
|
|
public static void SyncAnimation(this Player player, string animationName)
|
|
{
|
|
if (!player.HasData("Animation"))
|
|
player.SetData("Animation", String.Empty);
|
|
|
|
string currentAnimation = player.GetData<string>("Animation");
|
|
string newAnimation = animationName;
|
|
|
|
if (currentAnimation.Equals(newAnimation))
|
|
return;
|
|
|
|
player.SetSharedData("AnimationData", newAnimation);
|
|
}
|
|
|
|
public static bool HasAnimation(this Player player, string animationName)
|
|
{
|
|
return player.HasData("Animation") && (player.GetData<string>("AnimationData") == animationName);
|
|
}
|
|
|
|
public static void ClearAnimation(this Player player)
|
|
{
|
|
if (!player.HasData("Animation"))
|
|
return;
|
|
|
|
player.ResetData("Animation");
|
|
player.ResetSharedData("AnimationData");
|
|
}
|
|
}
|
|
|
|
public class AnimationSyncEvents : Script
|
|
{
|
|
[RemoteEvent("CLIENT:AnimPairTransition")]
|
|
public void AnimPairTransition(Player player, Player target, string transitionTo)
|
|
{
|
|
target.SyncAnimation(transitionTo);
|
|
}
|
|
}
|
|
}
|