Add AnimationSync

This commit is contained in:
2021-04-05 23:40:11 +02:00
parent e0d7dabe50
commit 8f225699c6
4 changed files with 196 additions and 62 deletions

View File

@@ -0,0 +1,34 @@
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 PlaySyncAnimation(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 void ClearAnimation(this Player player)
{
if (!player.HasData("Animation"))
return;
player.ResetData("Animation");
player.ResetSharedData("AnimationData");
}
}
}