From c62a9a0a88a093493b784b3e4469be21cc0fb9f7 Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 4 May 2021 17:45:28 +0200 Subject: [PATCH] beifahrer fahrer waypoint --- ReallifeGamemode.Client/util/waypoint.ts | 21 ++++++++++- ReallifeGamemode.Server/Events/Waypoint.cs | 43 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 ReallifeGamemode.Server/Events/Waypoint.cs diff --git a/ReallifeGamemode.Client/util/waypoint.ts b/ReallifeGamemode.Client/util/waypoint.ts index f7293d13..8ac5d28a 100644 --- a/ReallifeGamemode.Client/util/waypoint.ts +++ b/ReallifeGamemode.Client/util/waypoint.ts @@ -1,5 +1,24 @@ export default function waypointUtil() { - mp.events.add("SERVER:Util_setWaypoint", (x, y) => { + + let x_saved: number; + let y_saved: number; + let z_saved: number; + + mp.events.add("SERVER:Util_setWaypoint", (x, y, z) => { mp.game.ui.setNewWaypoint(x, y); }); + + mp.events.add("playerCreateWaypoint", (position) => { + x_saved = position.x; + y_saved = position.y; + z_saved = position.z; + mp.events.callRemote("SERVER:waypointToDriver", position.x, position.y); + }); + + mp.events.add("gotoWaypoint", () => { + mp.gui.chat.push("xyz: " + x_saved + " " + y_saved + " " + z_saved); + mp.players.local.position = new mp.Vector3(x_saved, y_saved, z_saved); + + //coord.z = mp.game.gameplay.getGroundZFor3dCoord(coord.x, coord.y, i * 50, 0, false); // try calcualte Z + }); } \ No newline at end of file diff --git a/ReallifeGamemode.Server/Events/Waypoint.cs b/ReallifeGamemode.Server/Events/Waypoint.cs new file mode 100644 index 00000000..ed2ccfa0 --- /dev/null +++ b/ReallifeGamemode.Server/Events/Waypoint.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Database.Entities; +using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Services; + +namespace ReallifeGamemode.Server.Events +{ + class Waypoint : Script + { + [RemoteEvent("SERVER:waypointToDriver")] + public void setWaypointToDriver(Player player, float x, float y) + { + if (!player.IsInVehicle) + { + return; + } + + if (player.VehicleSeat == 0) + { + return; + } + ChatService.Broadcast("a"); + + Entity entity = NAPI.Vehicle.GetVehicleDriver(player.Vehicle); + Player target = PlayerService.GetPlayerByNameOrId(entity.Value.ToString()); + + + ChatService.Broadcast("b"); + + if (target == null) + { + return; + } + + ChatService.Broadcast("c"); + + target.TriggerEvent("SERVER:Util_setWaypoint", x, y); + } + } +}