From 19357a512b65c4f85fb0b6917a87f1c015da69b7 Mon Sep 17 00:00:00 2001 From: Fabian Wessels Date: Wed, 7 Apr 2021 20:49:43 +0200 Subject: [PATCH 1/6] datum und uhrzeit vertauscht --- ReallifeGamemode.Client/Gui/infobox.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/infobox.ts b/ReallifeGamemode.Client/Gui/infobox.ts index be4c2555..74f48eeb 100644 --- a/ReallifeGamemode.Client/Gui/infobox.ts +++ b/ReallifeGamemode.Client/Gui/infobox.ts @@ -202,7 +202,7 @@ export default function (globalData: IGlobalData): void { centre: false }) - mp.game.graphics.drawText(dateString + "\n" + timeString, [0.938, 0.381], + mp.game.graphics.drawText(timeString + "\n" + dateString, [0.938, 0.381], { font: 4, color: [255, 255, 255, 255], @@ -219,7 +219,7 @@ export default function (globalData: IGlobalData): void { outline: true, centre: false }) - mp.game.graphics.drawText("~r~Datum: ", [0.89, 0.381], + mp.game.graphics.drawText("~r~Datum: ", [0.891, 0.411], { font: 4, color: [255, 255, 255, 255], @@ -227,7 +227,7 @@ export default function (globalData: IGlobalData): void { outline: true, centre: false }) - mp.game.graphics.drawText("~r~Uhrzeit: ", [0.891, 0.411], + mp.game.graphics.drawText("~r~Uhrzeit: ", [0.89, 0.381], { font: 4, color: [255, 255, 255, 255], From 347f3823a73a3ae2fd8231846acbef129c2fa7c4 Mon Sep 17 00:00:00 2001 From: kookroach Date: Wed, 7 Apr 2021 21:07:22 +0200 Subject: [PATCH 2/6] Fix animationSync on Cuff Closes #16 --- ReallifeGamemode.Client/util/animationSync.ts | 25 +++++++++---------- .../Extensions/ClientExtension.cs | 2 ++ ReallifeGamemode.Server/Util/AnimationSync.cs | 20 +++++++++++---- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index 2270a15d..f98abe12 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -73,7 +73,7 @@ let currentAnim = animationSyncData.animations[index]; let { id, name, animDict, animName, duration, loop, flag } = currentAnim; - if (loop && !player.isPlayingAnim(animDict, animName, 3)) { + if (loop == true && !player.isPlayingAnim(animDict, animName, 3)) { loadAnimDict(animDict, function () { mp.players.exists(player) && 0 !== player.handle && player.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) }); @@ -104,22 +104,21 @@ mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) }); - if (mp.players.local == entity && loop) { - animationBreakTimer = setInterval(() => breakAnimation(entity, id), 120000); - } + if (mp.players.local == entity) { + if (loop == true) { + animationBreakTimer = setInterval(() => breakAnimation(id), 120000); + } else { + let a = setInterval(function () { + mp.events.callRemote("CLIENT:ClearAnimationData", true); - if (!loop) { - let a = setInterval(function () { - mp.events.callRemote("CLIENT:ClearAnimationData", entity); - mp.events.callRemote("CLIENT:AnimPairTransition"); - - clearInterval(a); - }, duration); + clearInterval(a); + }, duration); + } } }); - function breakAnimation(entity, id) { - mp.events.callRemote("CLIENT:ClearAnimationData", entity); + function breakAnimation(id) { + mp.events.callRemote("CLIENT:ClearAnimationData", false); let { animName, msg } = animationBreakMessage.find(c => mp.game.joaat(c.animName) == id) if (msg) diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index f6d06d3a..99bdb97a 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; @@ -340,6 +341,7 @@ namespace ReallifeGamemode.Server.Extensions nearestCuffPlayer.AddAttachment("handcuffs", true); player.SyncAnimation("doUncuff"); nearestCuffPlayer.SyncAnimation("getUncuff"); + PositionManager.cuffPoints.Remove(nearestCuffPlayer); } } } diff --git a/ReallifeGamemode.Server/Util/AnimationSync.cs b/ReallifeGamemode.Server/Util/AnimationSync.cs index d4ae704c..efb0c32d 100644 --- a/ReallifeGamemode.Server/Util/AnimationSync.cs +++ b/ReallifeGamemode.Server/Util/AnimationSync.cs @@ -35,11 +35,17 @@ namespace ReallifeGamemode.Server.Util List nextAnimations = animations.Skip(1).ToList(); player.SyncAnimation(animationName); - if (nextAnimations.Count != 0) + if (nextAnimations.Count is 0) { - player.TriggerEvent("SERVER:QueueAnimation", animationName); - animationPair.Add(player, nextAnimations); + animationPair.Remove(player); + return; } + + player.TriggerEvent("SERVER:QueueAnimation", animationName); + if (animationPair.ContainsKey(player)) + animationPair[player] = nextAnimations; + else + animationPair.Add(player, nextAnimations); } /// Check if Player has any Animation playing. @@ -55,6 +61,8 @@ namespace ReallifeGamemode.Server.Util /// Name of requested animation public static bool HasAnimation(this Player player, dynamic animationName) { + string data = player.GetData("Animation"); + bool x = player.GetData("Animation") == animationName; return player.HasData("Animation") && (player.GetData("Animation") == animationName); } @@ -82,9 +90,11 @@ namespace ReallifeGamemode.Server.Util } [RemoteEvent("CLIENT:ClearAnimationData")] - public void ClearAnimationData(Player player, Player target) + public void ClearAnimationData(Player player, bool checkTransition) { - target.ClearAnimation(); + player.ClearAnimation(); + if (checkTransition) + AnimPairTransition(player); } [ServerEvent(Event.PlayerWeaponSwitch)] From c9452c0fca896bf4ff8485d5ba7cfc7a7639622a Mon Sep 17 00:00:00 2001 From: Fabian Wessels Date: Wed, 7 Apr 2021 21:20:34 +0200 Subject: [PATCH 3/6] sigas mangelnde deutschkenntnisse korrigiert --- ReallifeGamemode.Server/Managers/InventoryManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index c8befc54..c8a88470 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -74,7 +74,7 @@ namespace ReallifeGamemode.Server.Managers { if (player.IsInVehicle) { - player.TriggerEvent("Error", "Du kannst dein Kofferraum nicht betätigen."); + player.TriggerEvent("Error", "Du kannst deinen Kofferraum gerade nicht öffnen."); } Vehicle veh = NAPI.Pools.GetAllVehicles().ToList().Where(v => v.Position.DistanceTo(player.Position) <= 2).FirstOrDefault(); if (veh == null) From e93db47d8e07cc149f9940f247cd842c988c7c79 Mon Sep 17 00:00:00 2001 From: Fabian Wessels Date: Wed, 7 Apr 2021 21:49:47 +0200 Subject: [PATCH 4/6] sanitaeter koennen onduty keine sanitaeter rufen --- ReallifeGamemode.Client/Login/main.ts | 3 +++ ReallifeGamemode.Server/Managers/InteractionManager.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Client/Login/main.ts b/ReallifeGamemode.Client/Login/main.ts index 3fe6e020..c0aa02b1 100644 --- a/ReallifeGamemode.Client/Login/main.ts +++ b/ReallifeGamemode.Client/Login/main.ts @@ -51,6 +51,9 @@ export default function (globalData: IGlobalData): void { }); mp.events.add('CEF:Login_RegisterRequest', (password: string) => { + if (password.length < 6) { + return; + } mp.events.callRemote('CLIENT:Login_RegisterRequest', password); }); diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 5072f79c..b6542171 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -809,7 +809,7 @@ namespace ReallifeGamemode.Server.Managers [RemoteEvent("CLIENT:InteractionMenu_CallService_Sani")] public void CallServiceSani(Player player) { - if (player.GetUser().FactionId == 2) + if (player.GetUser().FactionId == 2 && player.IsDuty()) { player.SendNotification("~r~[Fehler] ~w~Du kannst keinen Sanitäter rufen."); return; From dffe845a954c3c6a9a5540ed458f7277fd3a796b Mon Sep 17 00:00:00 2001 From: Fabian Wessels Date: Wed, 7 Apr 2021 21:57:25 +0200 Subject: [PATCH 5/6] passwort muss aus mindestens 6 zeichen bestehen --- ReallifeGamemode.Client/Login/main.ts | 3 --- ReallifeGamemode.Server/Events/Register.cs | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Client/Login/main.ts b/ReallifeGamemode.Client/Login/main.ts index c0aa02b1..3fe6e020 100644 --- a/ReallifeGamemode.Client/Login/main.ts +++ b/ReallifeGamemode.Client/Login/main.ts @@ -51,9 +51,6 @@ export default function (globalData: IGlobalData): void { }); mp.events.add('CEF:Login_RegisterRequest', (password: string) => { - if (password.length < 6) { - return; - } mp.events.callRemote('CLIENT:Login_RegisterRequest', password); }); diff --git a/ReallifeGamemode.Server/Events/Register.cs b/ReallifeGamemode.Server/Events/Register.cs index 3a18f8a7..28ecacc0 100644 --- a/ReallifeGamemode.Server/Events/Register.cs +++ b/ReallifeGamemode.Server/Events/Register.cs @@ -20,11 +20,18 @@ namespace ReallifeGamemode.Server.Events string username = player.Name; using (var dbContext = new DatabaseContext()) { + if (password.Length < 6) + { + player.TriggerEvent("SERVER:Login_Error", "Das Passwort muss aus mindestens 6 Zeichen bestehen."); + return; + } if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3) { player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert."); + return; } - else if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim())) + + if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim())) { var user = new User { From 26fa0ba2aafe9f2df71abff79e5129fae461b334 Mon Sep 17 00:00:00 2001 From: kookroach Date: Wed, 7 Apr 2021 21:58:36 +0200 Subject: [PATCH 6/6] Done Closes #15, #13 --- ReallifeGamemode.Client/util/animationSync.ts | 40 ++++++++++--------- .../Commands/UserCommands.cs | 6 +-- .../Events/EnterVehicleAttempt.cs | 11 ++--- ReallifeGamemode.Server/Events/Key.cs | 14 +------ .../Extensions/ClientExtension.cs | 17 ++++++++ ReallifeGamemode.Server/Util/AnimationSync.cs | 4 ++ 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index f98abe12..22b39721 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -1,15 +1,17 @@ -export default function animationSync() { +import { debug } from "util"; + +export default function animationSync() { let blockInput = false; let animationBreakTimer; mp.events.add("SERVER:LoadAnimations", () => { - animationSyncData.register("Cuffed", "mp_arresting", "idle", -1, true, 50); - animationSyncData.register("doArrest", "mp_arrest_paired", "cop_p2_back_right", 3760, false, 0); - animationSyncData.register("getArrest", "mp_arrest_paired", "crook_p2_back_right", 3760, false, 0); - animationSyncData.register("doUncuff", "mp_arresting", "a_uncuff", 5500, false, 0); - animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0); - animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50); - animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50); + animationSyncData.register("Cuffed", "mp_arresting", "idle", -1, true, 50, false); + animationSyncData.register("doArrest", "mp_arrest_paired", "cop_p2_back_right", 3760, false, 0, false); + animationSyncData.register("getArrest", "mp_arrest_paired", "crook_p2_back_right", 3760, false, 0, false); + animationSyncData.register("doUncuff", "mp_arresting", "a_uncuff", 5500, false, 0, false); + animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0, false); + animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50, true); + animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50, true); }); const animationBreakMessage = [ @@ -20,7 +22,7 @@ { animations: [], - register: function (name, animDict, animName, duration, loop, flag) { + register: function (name, animDict, animName, duration, loop, flag, endless) { let id = mp.game.joaat(name); if (!this.animations.hasOwnProperty(id)) { @@ -32,7 +34,8 @@ animName: animName, duration: duration, loop: loop, - flag: flag + flag: flag, + endless: endless }; } else { mp.game.graphics.notify("Animation Sync Error: ~r~Duplicate Entry"); @@ -98,34 +101,35 @@ let animData = animationSyncData.animations[index]; - let { id, name, animDict, animName, duration, loop, flag } = animData; + let { id, name, animDict, animName, duration, loop, flag, endless } = animData; loadAnimDict(animDict, function () { mp.players.exists(entity) && 0 !== entity.handle && entity.taskPlayAnim(animDict, animName, 1, 0, duration, parseInt(flag), 0, !1, !1, !1) }); + if (!endless) { + animationBreakTimer = setInterval(() => breakAnimation(name), 120000); + } if (mp.players.local == entity) { - if (loop == true) { - animationBreakTimer = setInterval(() => breakAnimation(id), 120000); - } else { + if (!loop) { let a = setInterval(function () { mp.events.callRemote("CLIENT:ClearAnimationData", true); clearInterval(a); }, duration); - } + } } }); - function breakAnimation(id) { - mp.events.callRemote("CLIENT:ClearAnimationData", false); - let { animName, msg } = animationBreakMessage.find(c => mp.game.joaat(c.animName) == id) + function breakAnimation(name) { + let { animName, msg } = animationBreakMessage.find(c => c.animName == name) if (msg) mp.events.call("renderTextOnScreen", msg); clearInterval(animationBreakTimer); animationBreakTimer = null; + mp.events.callRemote("CLIENT:ClearAnimationData", false); } mp.events.add("render", () => { diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 6880fd52..d4dde10e 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -106,11 +106,7 @@ namespace ReallifeGamemode.Server.Commands [Command("hup")] public void CmdAnim(Player player) { - if (player.HasAnimation("hup")) { player.ClearAnimation(); return; } - if (player.HasAnimation()) - return; - - player.SyncAnimation("hup"); + player.ToggleSurrender(); } [Command("event", "~m~Benutzung: ~s~/event [Nachricht]", GreedyArg = true)] diff --git a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs index 46e58036..b63b7661 100644 --- a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs +++ b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs @@ -15,17 +15,15 @@ namespace ReallifeGamemode.Server.Events public class EnterVehicleAttempt : Script { public static GTANetworkAPI.Vehicle Roller; + [ServerEvent(Event.PlayerEnterVehicleAttempt)] public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat) { - if ((VehicleHash)vehicle.Model == VehicleHash.Dune3) - { - if (seat == 1) seat = 0; - else if (seat == 0) seat = 1; - } - if (seat != 0) return; + if (player.HasAnimation()) + player.StopAnimation(); + User u = player.GetUser(); if (vehicle.GetServerVehicle() is FactionVehicle veh) @@ -84,7 +82,6 @@ namespace ReallifeGamemode.Server.Events return; } } - } if (vehicle.GetServerVehicle() is SchoolVehicle sVeh) { diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 1643b7ac..8cba9c05 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -974,19 +974,7 @@ namespace ReallifeGamemode.Server.Events [RemoteEvent("keyPress:ControllH")] public void KeyPressControllH(Player player) { - if (player.HasAnimation("hup")) - { - PositionManager.cuffPoints.Remove(player); - player.ClearAnimation(); - return; - } - if (player.HasAnimation()) - return; - - player.SyncAnimation("hup"); - - if (player.GetUser().Wanteds > 0) - PositionManager.cuffPoints.Add(player); + player.ToggleSurrender(); } #endregion User Key diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 99bdb97a..42305180 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -344,5 +344,22 @@ namespace ReallifeGamemode.Server.Extensions PositionManager.cuffPoints.Remove(nearestCuffPlayer); } } + + public static void ToggleSurrender(this Player player) + { + if (player.HasAnimation("hup")) + { + PositionManager.cuffPoints.Remove(player); + player.ClearAnimation(); + return; + } + if (player.HasAnimation()) + return; + + player.SyncAnimation("hup"); + + if (player.GetUser().Wanteds > 0) + PositionManager.cuffPoints.Add(player); + } } } diff --git a/ReallifeGamemode.Server/Util/AnimationSync.cs b/ReallifeGamemode.Server/Util/AnimationSync.cs index efb0c32d..6d10d672 100644 --- a/ReallifeGamemode.Server/Util/AnimationSync.cs +++ b/ReallifeGamemode.Server/Util/AnimationSync.cs @@ -13,6 +13,9 @@ namespace ReallifeGamemode.Server.Util public static void SyncAnimation(this Player player, dynamic animationName) { + if (player.IsInVehicle) + return; + if (!player.HasData("Animation")) player.SetData("Animation", String.Empty); @@ -71,6 +74,7 @@ namespace ReallifeGamemode.Server.Util if (!player.HasData("Animation")) return; + player.ClearAttachments(); player.ResetData("Animation"); player.ResetSharedData("AnimationData"); }