From a0c55cd8460d0f04bd4aade8340413cc09aba50e Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 8 May 2021 02:10:26 +0200 Subject: [PATCH] teleport to waypoint command fick die z coordinate --- ReallifeGamemode.Client/util/waypoint.ts | 44 ++++++++++++++++++- .../Commands/AdminCommands.cs | 11 +++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Client/util/waypoint.ts b/ReallifeGamemode.Client/util/waypoint.ts index b8c5b06c..4fc7e43d 100644 --- a/ReallifeGamemode.Client/util/waypoint.ts +++ b/ReallifeGamemode.Client/util/waypoint.ts @@ -5,7 +5,7 @@ let z_saved: number; let waypointSet: boolean; - mp.events.add("SERVER:Util_setWaypoint", (x, y, z) => { + mp.events.add("SERVER:Util_setWaypoint", (x, y) => { mp.game.ui.setNewWaypoint(x, y); }); @@ -20,4 +20,46 @@ mp.events.add("playerRemoveWaypoint", () => { waypointSet = false; }); + + var timer; + var val: number; + var timeoutConter: number; + + mp.events.add("tpToWaypoint", () => { + if (!waypointSet) { + return; + } + val = 1000; + timeoutConter = 0; + + let getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(x_saved, y_saved, z_saved, 0, false); + + if (getGroundZ == 0) { + mp.players.local.position = new mp.Vector3(x_saved, y_saved, val); + mp.players.local.freezePosition(true); + + timer = setInterval(function () { + getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(x_saved, y_saved, val, 0, false); + mp.players.local.freezePosition(false); + mp.players.local.position = new mp.Vector3(x_saved, y_saved, val); + + if (getGroundZ == 0) { + timeoutConter++; + val -= 100; + mp.players.local.freezePosition(true); + } else { + mp.players.local.position = new mp.Vector3(x_saved, y_saved, getGroundZ); + clearInterval(timer); + } + + if (timeoutConter >= 20) { + mp.players.local.freezePosition(false); + clearInterval(timer); + } + }, 250); + } else { + mp.players.local.position = new mp.Vector3(x_saved, y_saved, getGroundZ); + } + }); + } \ No newline at end of file diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 011fcf67..d781fd18 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -550,6 +550,17 @@ namespace ReallifeGamemode.Server.Commands #endregion Support #region Admin + [Command("towwaypoint", "~m~Benutzung: ~s~/towwaypoint", Alias = "tow")] + public void CmdAdminToWaypoint(Player player) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + player.TriggerEvent("tpToWaypoint"); + } [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]", Alias = "rmss")] public void CmdAdminRmss(Player player, String targetname)