beifahrer fahrer waypoint

This commit is contained in:
Fabian
2021-05-04 17:45:28 +02:00
parent d135fe7559
commit c62a9a0a88
2 changed files with 63 additions and 1 deletions

View File

@@ -1,5 +1,24 @@
export default function waypointUtil() { 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.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
});
} }

View File

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