Animation Sync events
This commit is contained in:
@@ -23,7 +23,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Player player)
|
||||
{
|
||||
player.TriggerEvent("SERVER:LoadAnimations");
|
||||
player.TriggerEvent("CLIENT:StopSound");
|
||||
//player.SetSharedData("vehicleAdminSpeed2", 1.0);
|
||||
player.SetData("isLoggedIn", false);
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public static class AnimationSync
|
||||
{
|
||||
public static void SyncAnimation(this Player player, string animationName)
|
||||
public static void SyncAnimation(this Player player, dynamic animationName)
|
||||
{
|
||||
if (!player.HasData("Animation"))
|
||||
player.SetData("Animation", String.Empty);
|
||||
@@ -22,7 +22,18 @@ namespace ReallifeGamemode.Server.Util
|
||||
player.SetSharedData("AnimationData", newAnimation);
|
||||
}
|
||||
|
||||
public static bool HasAnimation(this Player player, string animationName)
|
||||
/// <summary>Check if Player has any Animation playing.
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
public static bool HasAnimation(this Player player)
|
||||
{
|
||||
return player.HasData("Animation");
|
||||
}
|
||||
|
||||
/// <summary>Check if Player has a specific Animation playing.
|
||||
/// </summary>
|
||||
/// <param name="animationName">Name of requested animation</param>
|
||||
public static bool HasAnimation(this Player player, dynamic animationName)
|
||||
{
|
||||
return player.HasData("Animation") && (player.GetData<string>("AnimationData") == animationName);
|
||||
}
|
||||
@@ -44,5 +55,24 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
target.SyncAnimation(transitionTo);
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerWeaponSwitch)]
|
||||
public void OnPlayerWeaponSwitch(Player player, WeaponHash oldWeapon, WeaponHash newWeapon)
|
||||
{
|
||||
if (!player.HasAnimation()) return;
|
||||
NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed);
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Player player)
|
||||
{
|
||||
player.TriggerEvent("SERVER:LoadAnimations");
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
player.ClearAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user