teleport to waypoint command fick die z coordinate

This commit is contained in:
Fabian
2021-05-08 02:10:26 +02:00
parent 2c42aa6123
commit a0c55cd846
2 changed files with 54 additions and 1 deletions

View File

@@ -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);
}
});
}

View File

@@ -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)