diff --git a/ReallifeGamemode.Client/Player/handsup.ts b/ReallifeGamemode.Client/Player/handsup.ts new file mode 100644 index 00000000..ca29ae5f --- /dev/null +++ b/ReallifeGamemode.Client/Player/handsup.ts @@ -0,0 +1,13 @@ +export default function handsup() { + mp.events.add("SERVER:Handsup_CheckIfPlayerCanHandsup", () => { + var player = mp.players.local; + + var isStopped = player.isStopped(); + + mp.gui.chat.push("isStopped = " + isStopped); + + if (isStopped) { + mp.events.callRemote("CLIENT:Handsup_TogglePlayerHup"); + } + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index abcbd11e..1632f768 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -265,6 +265,9 @@ antiAfk(globalData); import ammunation from './Interaction/ammunation/ammunation'; ammunation(globalData); +import handsup from './Player/handsup'; +handsup(); + require('./Gui/policedepartment'); require('./Gui/helptext'); require('./admin/spectate'); diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 913122b0..7b4bc1c7 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -135,7 +135,7 @@ namespace ReallifeGamemode.Server.Commands [Command("hup")] public void CmdUserHup(Player player) { - player.ToggleSurrender(); + player.CheckToggleSurrender(); } [Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)] diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 92a7af80..ed27acef 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -904,7 +904,7 @@ namespace ReallifeGamemode.Server.Events [RemoteEvent("keyPress:ControllH")] public void KeyPressControllH(Player player) { - player.ToggleSurrender(); + player.CheckToggleSurrender(); } #endregion User Key diff --git a/ReallifeGamemode.Server/Events/PlayerEvent.cs b/ReallifeGamemode.Server/Events/PlayerEvent.cs index 2aba02d8..cdce4ffe 100644 --- a/ReallifeGamemode.Server/Events/PlayerEvent.cs +++ b/ReallifeGamemode.Server/Events/PlayerEvent.cs @@ -24,5 +24,11 @@ namespace ReallifeGamemode.Server.Events player.SendNotification("Du wurdest ~b~AFK~s~ gesetzt", true); } } + + [RemoteEvent("CLIENT:Handsup_TogglePlayerHup")] + public void PlayerToggleHandsupEvent(Player player) + { + player.ToggleSurrender(); + } } } diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 3a665dd0..25f9c0a4 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -138,7 +138,7 @@ namespace ReallifeGamemode.Server.Extensions public static bool IsAfk(this Player player) { - if(!player.HasSharedData("isAfk")) + if (!player.HasSharedData("isAfk")) { return false; } @@ -339,7 +339,7 @@ namespace ReallifeGamemode.Server.Extensions int nameTagColor = 0; Player player = user.Player; - if(player == null || !player.IsLoggedIn()) + if (player == null || !player.IsLoggedIn()) { return; } @@ -347,7 +347,7 @@ namespace ReallifeGamemode.Server.Extensions bool duty = user.GetData("duty"); bool adminUnshow = user.GetData("adminUnshow"); - if(adminUnshow) + if (adminUnshow) { blipColor = -1; nameTagColor = -3; @@ -437,6 +437,11 @@ namespace ReallifeGamemode.Server.Extensions } } + public static void CheckToggleSurrender(this Player player) + { + player.TriggerEvent("SERVER:Handsup_CheckIfPlayerCanHandsup"); + } + public static void ToggleSurrender(this Player player) { if (player.HasAnimation("hup"))