try AnimSync
This commit is contained in:
@@ -67,6 +67,8 @@
|
||||
}
|
||||
|
||||
let index = mp.game.joaat(player.getVariable("AnimationData"));
|
||||
if (!animationSyncData.animations.hasOwnProperty(index)) return;
|
||||
|
||||
let currentAnim = animationSyncData.animations[index];
|
||||
let { id, name, animDict, animName, duration, loop, flag } = currentAnim;
|
||||
|
||||
@@ -78,6 +80,19 @@
|
||||
});
|
||||
}, 100);
|
||||
|
||||
mp.events.add("SERVER:QueueAnimations", (nextAnimations, 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.events.callRemote("CLIENT:AnimPairTransition", nextAnimations);
|
||||
|
||||
clearInterval(interval);
|
||||
}, duration);
|
||||
});
|
||||
|
||||
mp.events.addDataHandler("AnimationData", (entity: PlayerMp, string) => {
|
||||
entity.clearTasksImmediately();
|
||||
if (string == null) {
|
||||
@@ -96,12 +111,9 @@
|
||||
mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1)
|
||||
});
|
||||
|
||||
let pair = pairData.find(pair => pair.from == string);
|
||||
if (!pair)
|
||||
return;
|
||||
let a = setInterval(function () {
|
||||
if (entity == mp.players.local) {
|
||||
mp.events.callRemote("CLIENT:AnimPairTransition", entity, pair.transitionTo);
|
||||
mp.events.callRemote("CLIENT:ClearAnimationData", entity);
|
||||
}
|
||||
clearInterval(a);
|
||||
}, duration);
|
||||
@@ -126,15 +138,4 @@
|
||||
mp.events.add("SERVER:SetInFrontPosition", (entity) => {
|
||||
mp.events.callRemote("CLIENT:SET_InFrontOfPos", entity.getOffsetFromInWorldCoords(0, 1, 0));
|
||||
});
|
||||
|
||||
mp.events.add("attach to Player", (entity: PlayerMp) => {
|
||||
entity.attachTo(mp.players.local.handle, 0, 0, 1, 0, 0, 0, 0, false, false, false, true, 2, true);
|
||||
});
|
||||
|
||||
function xyInFrontOfPos(pos, heading, dist): Vector3Mp {
|
||||
heading *= Math.PI / 180
|
||||
pos.x += (dist * Math.sin(-heading))
|
||||
pos.y += (dist * Math.cos(-heading))
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
if (!target.HasAnimation("Cuffed"))
|
||||
{
|
||||
player.SyncAnimation("doArrest");
|
||||
target.SyncAnimation("getArrest");
|
||||
target.SyncAnimation(new List<string>() { "getArrest", "Cuffed" });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -8,11 +8,24 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public static class AnimationSync
|
||||
{
|
||||
public static void SyncAnimation(this Player player, dynamic animationName)
|
||||
public static void SyncAnimation(this Player player, dynamic animations)
|
||||
{
|
||||
if (!player.HasData("Animation"))
|
||||
player.SetData("Animation", String.Empty);
|
||||
|
||||
string animationName;
|
||||
|
||||
if (animations is List<string>)
|
||||
{
|
||||
animationName = animations.get(0);
|
||||
List<string> nextAnimations = animations.Skip(1);
|
||||
player.TriggerEvent("SERVER:QueueAnimations", nextAnimations.ToArray(), animationName);
|
||||
}
|
||||
else
|
||||
{
|
||||
animationName = animations;
|
||||
}
|
||||
|
||||
string currentAnimation = player.GetData<string>("Animation");
|
||||
string newAnimation = animationName;
|
||||
|
||||
@@ -52,9 +65,9 @@ namespace ReallifeGamemode.Server.Util
|
||||
public class AnimationSyncEvents : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:AnimPairTransition")]
|
||||
public void AnimPairTransition(Player player, Player target, string transitionTo)
|
||||
public void AnimPairTransition(Player player, string[] transitionTo)
|
||||
{
|
||||
target.SyncAnimation(transitionTo);
|
||||
player.SyncAnimation(transitionTo.ToList<string>());
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ClearAnimationData")]
|
||||
|
||||
Reference in New Issue
Block a user