Finish Cuff using AnimationSync

+ Added Command /cuff for LSPD and FIB (Wanteds can also be cuffed using the Interaction key).
+ Added Command /syncanim for Supporter

* Player can now use CTRL + H to hup (/hup still usable)
* Cuffs break after two minutes.

TODO:
- Players in Animation cannot enter Vehicle as driver neither can drive them.
- Cuffed players will not loose their cuffs after reconnect.
This commit is contained in:
2021-04-07 03:17:02 +02:00
parent d98c742c59
commit 5cea81de72
9 changed files with 97 additions and 55 deletions

View File

@@ -96,6 +96,13 @@
mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1)
}); });
let b = setInterval(function () {
mp.events.callRemote("CLIENT:ClearAnimationData", entity);
if (name == "Cuffed" || name == "cuffed")
mp.events.call("renderTextOnScreen", "Handschellen gebrochen.");
clearInterval(b);
}, 120000);
if (!loop) { if (!loop) {
let a = setInterval(function () { let a = setInterval(function () {
mp.events.callRemote("CLIENT:ClearAnimationData", entity); mp.events.callRemote("CLIENT:ClearAnimationData", entity);

View File

@@ -8,7 +8,7 @@ export default function attachmentManager(game: IGame) {
attachmentMngr.register("weapondeal", "ex_prop_crate_ammo_bc", "chassis_dummy", new mp.Vector3(0.08, -0.9, -0.2), new mp.Vector3(0, 0, 0)); attachmentMngr.register("weapondeal", "ex_prop_crate_ammo_bc", "chassis_dummy", new mp.Vector3(0.08, -0.9, -0.2), new mp.Vector3(0, 0, 0));
attachmentMngr.register("weapondeal1", "ex_office_swag_guns02", "chassis_dummy", new mp.Vector3(0, 0.8, 0), new mp.Vector3(0, 0, 0)); attachmentMngr.register("weapondeal1", "ex_office_swag_guns02", "chassis_dummy", new mp.Vector3(0, 0.8, 0), new mp.Vector3(0, 0, 0));
attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "chassis_dummy", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180)); attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "chassis_dummy", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180));
attachmentMngr.register("handcuffs", "p_cs_cuffs_02_s", 28422, new mp.Vector3(0, 0, 0), new mp.Vector3(0, 0, 0)); attachmentMngr.register("handcuffs", "p_cs_cuffs_02_s", 28422, new mp.Vector3(0, 0, 0), new mp.Vector3(0, 90, 0));
}); });
const attachmentMngr = const attachmentMngr =

View File

@@ -10,6 +10,7 @@
mp.events.add("render", () => { mp.events.add("render", () => {
if (blockInput) { if (blockInput) {
mp.game.controls.disableControlAction(32, 142, true); mp.game.controls.disableControlAction(32, 142, true);
mp.game.controls.disableControlAction(32, 140, true);
mp.game.controls.disableControlAction(32, 263, true); mp.game.controls.disableControlAction(32, 263, true);
} }
}); });

View File

@@ -34,33 +34,6 @@ namespace ReallifeGamemode.Server.Commands
{ {
#region Todo #region Todo
[Command("cuff", "~m~Benutzung: ~s~/cuff [ID]")]
public void CmdCuffTest(Player player, string nameOrId)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
if (target.Id == player.Id)
return;
target.SetInFrontOf(player);
target.Heading = player.Heading;
if (!target.HasAnimation("Cuffed"))
{
player.SyncAnimation("doArrest");
target.SyncAnimation(new List<string>() { "getArrest", "Cuffed" });
}
else
{
player.SyncAnimation("doUncuff");
target.SyncAnimation("getUncuff");
}
}
[Command("syncanim", "~m~Benutzung: ~s~/syncanim [animName]")] [Command("syncanim", "~m~Benutzung: ~s~/syncanim [animName]")]
public void CmdSyncAnim(Player player, string animName = null) public void CmdSyncAnim(Player player, string animName = null)
{ {

View File

@@ -11,6 +11,7 @@ using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
/** /**
@@ -127,7 +128,6 @@ namespace ReallifeGamemode.Server.Commands
#endregion Chat Commands #endregion Chat Commands
#region NewsReporter commands #region NewsReporter commands
[Command("news", "~m~Benutzung: ~s~/news [Nachricht]", GreedyArg = true)] [Command("news", "~m~Benutzung: ~s~/news [Nachricht]", GreedyArg = true)]
@@ -152,11 +152,8 @@ namespace ReallifeGamemode.Server.Commands
} }
} }
#endregion NewsReporter commands #endregion NewsReporter commands
#region Leader Commands #region Leader Commands
[Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)] [Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)]
@@ -408,6 +405,44 @@ namespace ReallifeGamemode.Server.Commands
#region Staatsfraktionen (LSPD / FBI) Commands #region Staatsfraktionen (LSPD / FBI) Commands
[Command("cuff", "~m~Benutzung: ~s~/cuff")]
public void CmdFactionCuff(Player player)
{
User user = player.GetUser();
if (user == null || (user.FactionId != 1 && user.FactionId != 3))
{
ChatService.NotAuthorized(player);
return;
}
if (!player.IsDuty())
{
ChatService.ErrorMessage(player, "Du bist nicht im Dienst");
return;
}
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
if (nearestCuffPlayer is null)
return;
nearestCuffPlayer.SetInFrontOf(player);
nearestCuffPlayer.Heading = player.Heading;
if (!nearestCuffPlayer.HasAnimation("Cuffed"))
{
player.SyncAnimation("doArrest");
nearestCuffPlayer.SyncAnimation(new List<string>() { "getArrest", "Cuffed" });
player.AddAttachment("handcuffs", false);
}
else
{
player.AddAttachment("handcuffs", true);
player.SyncAnimation("doUncuff");
nearestCuffPlayer.SyncAnimation("getUncuff");
}
}
[Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Spieler] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)] [Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Spieler] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)]
public void CmdFactionWanted(Player player, string nameOrId, int amount, string reason) public void CmdFactionWanted(Player player, string nameOrId, int amount, string reason)
{ {
@@ -491,11 +526,12 @@ namespace ReallifeGamemode.Server.Commands
} }
#endregion Staatsfraktionen (LSPD / FBI) Commands #endregion Staatsfraktionen (LSPD / FBI) Commands
#region Weazel News #region Weazel News
[Command("eventchat", "~m~Benutzung: ~s~/eventchat [Typ = ~g~on~s~, ~g~off~s~]", GreedyArg = true)] [Command("eventchat", "~m~Benutzung: ~s~/eventchat [Typ = ~g~on~s~, ~g~off~s~]", GreedyArg = true)]
public void CmdFactionNREventchat(Player player, string onoff) public void CmdFactionNREventchat(Player player, string onoff)
{ {
switch (onoff.ToLower()) switch (onoff.ToLower())
{ {
case "on": case "on":
@@ -513,14 +549,9 @@ namespace ReallifeGamemode.Server.Commands
}); });
player.SendNotification("Der Eventchat ist nun aus."); player.SendNotification("Der Eventchat ist nun aus.");
break; break;
} }
} }
#endregion Weazel News #endregion Weazel News
} }
} }

View File

@@ -111,7 +111,6 @@ namespace ReallifeGamemode.Server.Commands
return; return;
player.SyncAnimation("hup"); player.SyncAnimation("hup");
ChatService.SendInRange(player.Position, 20, $"~m~{player.Name} stellt sich...");
} }
[Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)] [Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)]

View File

@@ -218,6 +218,7 @@ namespace ReallifeGamemode.Server.Events
FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty"))); FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty")));
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6); JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6);
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
if (user?.FactionId != null) if (user?.FactionId != null)
{ {
@@ -507,6 +508,24 @@ namespace ReallifeGamemode.Server.Events
} }
player.TriggerEvent("showJailMenu", JsonConvert.SerializeObject(criminals.ToArray())); player.TriggerEvent("showJailMenu", JsonConvert.SerializeObject(criminals.ToArray()));
} }
if (nearestCuffPlayer != null)
{
nearestCuffPlayer.SetInFrontOf(player);
nearestCuffPlayer.Heading = player.Heading;
if (!nearestCuffPlayer.HasAnimation("Cuffed"))
{
player.SyncAnimation("doArrest");
nearestCuffPlayer.SyncAnimation(new List<string>() { "getArrest", "Cuffed" });
player.AddAttachment("handcuffs", false);
}
else
{
player.AddAttachment("handcuffs", true);
player.SyncAnimation("doUncuff");
nearestCuffPlayer.SyncAnimation("getUncuff");
}
}
} }
if (nearestElevatorPoint != null) if (nearestElevatorPoint != null)
{ {
@@ -969,14 +988,19 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("keyPress:ControllH")] [RemoteEvent("keyPress:ControllH")]
public void KeyPressControllH(Player player) public void KeyPressControllH(Player player)
{ {
if (player.HasAnimation("hup")) { player.ClearAnimation(); player.AddAttachment("handcuffs", true); return; } if (player.HasAnimation("hup"))
{
PositionManager.cuffPoints.Remove(player);
player.ClearAnimation();
return;
}
if (player.HasAnimation()) if (player.HasAnimation())
return; return;
player.AddAttachment("handcuffs", false);
player.SyncAnimation("hup"); player.SyncAnimation("hup");
ChatService.SendInRange(player.Position, 20, $"~m~{player.Name} stellt sich...");
if (player.GetUser().Wanteds > 0)
PositionManager.cuffPoints.Add(player);
} }
#endregion User Key #endregion User Key

View File

@@ -321,5 +321,10 @@ namespace ReallifeGamemode.Server.Extensions
{ {
player.TriggerEvent("SERVER:SetInFrontPosition", entity); player.TriggerEvent("SERVER:SetInFrontPosition", entity);
} }
public static void SetCuffable(this Player player, bool isCuffable)
{
player.SetSharedData("Cuffable", isCuffable);
}
} }
} }

View File

@@ -26,6 +26,8 @@ namespace ReallifeGamemode.Server.Managers
public static List<JobPoint> JobPoints = new List<JobPoint>(); public static List<JobPoint> JobPoints = new List<JobPoint>();
public static List<Player> cuffPoints = new List<Player>();
public static void LoadPositionManager() public static void LoadPositionManager()
{ {
#region DutyPoints #region DutyPoints