Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop

This commit is contained in:
2021-04-11 02:15:40 +02:00
22 changed files with 341 additions and 54 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Admin
{
public class AntiCheat : Script
{
private static TimeSpan antiCheatMessageCooldown = new TimeSpan(0, 0, 30);
private static Dictionary<(string, string), DateTime> lastAntiCheatBroadcastTime = new Dictionary<(string, string), DateTime>();
[ServerEvent(Event.PlayerWeaponSwitch)]
public void OnAntiCheatPlayerWeeaponSwitch(Player player, WeaponHash oldWeapon, WeaponHash newWeapon)
{
player.TriggerEvent("SERVER:AntiCheat:weaponSwap");
}
[RemoteEvent("CLIENT:CheatDetection")]
public void OnAntiCheatCheatDetected(Player cheater, string cheat)
{
if (!cheater.IsLoggedIn())
{
cheater.Kick();
}
if(cheater.IsAdminDuty())
{
return;
}
if (lastAntiCheatBroadcastTime.Any(a => a.Key.Item1 == cheater.Name && a.Key.Item2 == cheat)
&& DateTime.Now - lastAntiCheatBroadcastTime[(cheater.Name, cheat)] < antiCheatMessageCooldown)
{
return;
}
lastAntiCheatBroadcastTime[(cheater.Name, cheat)] = DateTime.Now;
ChatService.BroadcastAdmin($"~r~[ANTICHEAT]~s~ Verdacht auf ~y~{cheat}~s~ bei ~y~{cheater.Name}~s~ (~y~{cheater.Handle.Value}~s~)", AdminLevel.ADMIN);
}
internal static void NoTpAntiCheatForPlayer(string name)
{
lastAntiCheatBroadcastTime[(name, "Flyhack/Teleport")] = DateTime.Now.Subtract(antiCheatMessageCooldown).Add(TimeSpan.FromSeconds(5));
}
}
}

View File

@@ -390,7 +390,7 @@ namespace ReallifeGamemode.Server.Commands
player.Vehicle.Position = target.Position;
NAPI.Entity.SetEntityVelocity(player.Vehicle, new Vector3());
}
else player.Position = target.Position;
else player.SafeTeleport(target.Position);
ChatService.SendMessage(player, "~c~* Du hast dich teleportiert.");
}
@@ -416,7 +416,7 @@ namespace ReallifeGamemode.Server.Commands
target.Vehicle.Position = player.Position;
NAPI.Entity.SetEntityVelocity(target.Vehicle, new Vector3());
}
else target.Position = player.Position;
else target.SafeTeleport(player.Position);
ChatService.SendMessage(target, "~c~* Du wurdest teleportiert.");
}
@@ -611,7 +611,7 @@ namespace ReallifeGamemode.Server.Commands
}
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = player.GetData<Vector3>("mark");
else player.Position = player.GetData<Vector3>("mark");
else player.SafeTeleport(player.GetData<Vector3>("mark"));
}
[Command("flip", "")]
@@ -648,7 +648,7 @@ namespace ReallifeGamemode.Server.Commands
}
else
{
player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z + value);
player.SafeTeleport(new Vector3(player.Position.X, player.Position.Y, player.Position.Z + value));
}
}
@@ -667,7 +667,7 @@ namespace ReallifeGamemode.Server.Commands
}
else
{
player.Position = new Vector3(player.Position.X, player.Position.Y, player.Position.Z - value);
player.SafeTeleport(new Vector3(player.Position.X, player.Position.Y, player.Position.Z - value));
}
}
@@ -686,25 +686,25 @@ namespace ReallifeGamemode.Server.Commands
{
Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
else if (playerHeading < 315 && playerHeading >= 225)
{
Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
elseplayer.SafeTeleport(playerPosition);
}
else if (playerHeading >= 135 && playerHeading < 225)
{
Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
else if (playerHeading >= 45 && playerHeading < 135)
{
Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
}
@@ -723,25 +723,25 @@ namespace ReallifeGamemode.Server.Commands
{
Vector3 playerPosition = new Vector3(player.Position.X - value, player.Position.Y, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
else if (playerHeading < 315 && playerHeading >= 225)
{
Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y + value, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
else if (playerHeading >= 135 && playerHeading < 225)
{
Vector3 playerPosition = new Vector3(player.Position.X + value, player.Position.Y, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
else if (playerHeading >= 45 && playerHeading < 135)
{
Vector3 playerPosition = new Vector3(player.Position.X, player.Position.Y - value, player.Position.Z);
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = playerPosition;
else player.Position = playerPosition;
else player.SafeTeleport(playerPosition);
}
}
@@ -976,7 +976,7 @@ namespace ReallifeGamemode.Server.Commands
player.Vehicle.Position = new Vector3(p.X, p.Y, p.Z);
NAPI.Entity.SetEntityVelocity(player.Vehicle, new Vector3());
}
else player.Position = new Vector3(p.X, p.Y, p.Z);
else player.SafeTeleport(new Vector3(p.X, p.Y, p.Z));
}
}
@@ -1091,7 +1091,7 @@ namespace ReallifeGamemode.Server.Commands
return;
}
if (player.IsInVehicle && player.VehicleSeat == 0) player.Vehicle.Position = new Vector3(x, y, z);
else player.Position = new Vector3(x, y, z);
else player.SafeTeleport(new Vector3(x, y, z));
}
[Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")]
@@ -1112,7 +1112,7 @@ namespace ReallifeGamemode.Server.Commands
Vector3 oldPos = target.Position;
target.Position = new Vector3(oldPos.X, oldPos.Y, oldPos.Z + wert);
target.SafeTeleport(new Vector3(oldPos.X, oldPos.Y, oldPos.Z + wert));
ChatService.SendMessage(player, "Du hast " + target.Name + " geslappt. Höhe: " + wert + "");
}
@@ -1151,7 +1151,7 @@ namespace ReallifeGamemode.Server.Commands
return;
}
player.Position = v.Position.Add(new Vector3(0, 0, 2));
player.SafeTeleport(v.Position.Add(new Vector3(0, 0, 2)));
}
[Command("ghv", "~m~Benutzung: ~s~/ghv [Fahrzeug ID]")]
@@ -1171,7 +1171,7 @@ namespace ReallifeGamemode.Server.Commands
}
v.Position = player.Position;
player.Position = player.Position.Add(new Vector3(0, 0, 2));
player.SafeTeleport(player.Position.Add(new Vector3(0, 0, 2)));
}
[Command("factionlist", "~m~Benutzung: ~s~/factionlist")]
@@ -1443,7 +1443,7 @@ namespace ReallifeGamemode.Server.Commands
u.Dead = false;
dbContext.SaveChanges();
}
NAPI.Player.SpawnPlayer(target, target.Position);
target.SafeTeleport(target.Position, 0, true);
target.Health = 100;
Medic.delReviveTask(target);
@@ -2184,7 +2184,7 @@ namespace ReallifeGamemode.Server.Commands
public void sendCPfunc(Player user, int x, int y, int z)
{
Vector3 pos = new Vector3(x, y, z);
user.Position = pos;
user.SafeTeleport(pos);
}
[Command("sethandmoney", "~m~Benutzung: ~s~/sethandmoney [Name/ID] [Menge]")]
@@ -2414,7 +2414,7 @@ namespace ReallifeGamemode.Server.Commands
managedPlayer.SendNotification(toPlayerNotification);
ChatService.SendMessage(managedPlayer, toPlayerChat);
NAPI.Player.SpawnPlayer(managedPlayer, managedPlayer.Position);
managedPlayer.SafeTeleport(managedPlayer.Position, 0, true);
managedPlayer.Health = 100;
Medic.delReviveTask(managedPlayer);
@@ -2671,7 +2671,7 @@ namespace ReallifeGamemode.Server.Commands
Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), business, price);
player.SendNotification("Shopfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
Vector3 oldPos = player.Position;
player.Position = new Vector3(oldPos.X, oldPos.Y, oldPos.Z + 2.5);
player.SafeTeleport(new Vector3(oldPos.X, oldPos.Y, oldPos.Z + 2.5));
}
else ChatService.SendMessage(player, "~m~Du sitzt in keinem Fahrzeug!");
break;

View File

@@ -343,7 +343,7 @@ namespace ReallifeGamemode.Server.Commands
u.Dead = false;
dbContext.SaveChanges();
}
NAPI.Player.SpawnPlayer(deadPlayer, deadPlayer.Position);
deadPlayer.SafeTeleport(deadPlayer.Position, 0, true);
deadPlayer.Health = 50;
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == deadPlayer.Name);

View File

@@ -190,7 +190,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
veh.Position = sVeh.Position;
veh.Rotation = new Vector3(0, 0, sVeh.Heading);
user.Position = new Vector3(-814.39, -1336.76, 5.15);
user.SafeTeleport(new Vector3(-814.39, -1336.76, 5.15));
}
[RemoteEvent("drivingSchoolEvent")]
@@ -304,7 +304,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
veh.Position = sVeh.Position;
veh.Rotation = new Vector3(0, 0, sVeh.Heading);
user.Position = new Vector3(-814.39, -1336.76, 5.15);
user.SafeTeleport(new Vector3(-814.39, -1336.76, 5.15));
}
[RemoteEvent("bikeSchoolEvent")]

View File

@@ -128,7 +128,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
dbContext.SaveChanges();
}
user.ResetData("ActiveSchool");
user.Position = new Vector3(-1083.96, -2476.96, 13.07);
user.SafeTeleport(new Vector3(-1083.96, -2476.96, 13.07));
}
[RemoteEvent("planeSchoolEvent")]

View File

@@ -26,7 +26,7 @@ namespace ReallifeGamemode.Server.Events
player.TriggerEvent("CLIENT:StopSound");
//player.SetSharedData("vehicleAdminSpeed2", 1.0);
player.SetData("isLoggedIn", false);
player.Position = new Vector3(-1883.736, -781.4911, -10);
player.SafeTeleport(new Vector3(-1883.736, -781.4911, -10));
bool registered = false;

View File

@@ -238,7 +238,7 @@ namespace ReallifeGamemode.Server.Events
Player medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName);
Medic.RemoveTaskFromList(task);
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5), -98.36f);
player.SafeTeleport(new Vector3(-495.45, -336.33, 34.5), 0, true);
}
}
}

View File

@@ -51,7 +51,7 @@ namespace ReallifeGamemode.Server.Events
client.WarpOutOfVehicle();
ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(vehicle);
ServerVehicleExtensions.Spawn(sVeh, vehicle);
client.Position = sVeh.Position;
client.SafeTeleport(sVeh.Position);
CheckPointHandle.DeleteCheckpoints(client);
}
}

View File

@@ -113,7 +113,7 @@ namespace ReallifeGamemode.Server.Events
currentPlayerCreatorDimension++;
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
player.Rotation = new Vector3(0, 0, 180);
player.TriggerEvent("toggleCreator");
}
@@ -123,7 +123,7 @@ namespace ReallifeGamemode.Server.Events
UpdateCharacterCloth.LoadCharacterDefaults(player);
if (user.JailTime <= 0)
{
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
player.SafeTeleport(new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0, true);
}
else
{
@@ -151,7 +151,7 @@ namespace ReallifeGamemode.Server.Events
{
player.SetData("isDead", false);
}
}, delayTime: 1000);
}, delayTime: 1000);
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Extensions;
namespace ReallifeGamemode.Server.Events
{
@@ -10,7 +11,7 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("CLIENT:SET_InFrontOfPos")]
public void SetFrontOfPos(Player player, Vector3 pos)
{
player.Position = pos;
player.SafeTeleport(pos);
}
}
}

View File

@@ -3,6 +3,7 @@ using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
/**
* @overview Life of German Reallife - Event Register (Register.cs)
@@ -63,7 +64,7 @@ namespace ReallifeGamemode.Server.Events
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.TriggerEvent("toggleCreator");
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
}
else

View File

@@ -1,4 +1,5 @@
using GTANetworkAPI;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers;
namespace ReallifeGamemode.Server.Events
@@ -11,7 +12,7 @@ namespace ReallifeGamemode.Server.Events
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
if (elevator != null)
{
client.Position = elevator.Position;
client.SafeTeleport(elevator.Position);
}
}
}

View File

@@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Admin;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
@@ -59,6 +60,20 @@ namespace ReallifeGamemode.Server.Extensions
}
}
public static void SafeTeleport(this Player player, Vector3 position, float heading = 0, bool spawn = false)
{
AntiCheat.NoTpAntiCheatForPlayer(player.Name);
if (spawn)
{
NAPI.Player.SpawnPlayer(player, position, heading);
}
else
{
player.Position = position;
player.Heading = heading;
}
}
public static void SetJailTime(this User user, bool killed)
{
if (user == null)

View File

@@ -59,7 +59,7 @@ namespace ReallifeGamemode.Server.Job
if (quit)
{
ChatService.SendMessage(player, $"~y~[Job]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
player.Position = JobManager.playerJobStartPosition[player];
player.SafeTeleport(JobManager.playerJobStartPosition[player]);
}
JobStop?.Invoke(player);

View File

@@ -254,7 +254,7 @@ namespace ReallifeGamemode.Server.Managers
//};
//player.SetHeadOverlay(4, makeupHo);
//player.SetHeadOverlay(5, blushHo);
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
player.SafeTeleport(Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING, true);
player.TriggerEvent("draw", player.Name, player.Handle.Value);
player.Dimension = 0;
}

View File

@@ -258,14 +258,14 @@ namespace ReallifeGamemode.Server.Managers
targetPlayer.SetData("duty", false);
targetPlayer.TriggerEvent("toggleDutyMode", false);
UpdateCharacterCloth.LoadCharacterDefaults(targetPlayer);
ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen.");
targetUser.SetBlipAndNametagColor();
ChatService.SendMessage(targetPlayer, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen.");
}
targetUser.SetBlipAndNametagColor();
Medic.UpdateDutyMedics();
targetUser.FactionRankId = null;
targetUser.FactionId = null;
ChatService.SendMessage(player, "!{02FCFF}Du hast " + targetUser.Name + " aus der Fraktion geworfen.");
ChatService.SendMessage(player, "!{02FCFF}Du hast " + targetUser.Name + " aus der Fraktion geworfen.");
dbContext.SaveChanges();
}
else if (type == "Gruppe")

View File

@@ -203,30 +203,30 @@ namespace ReallifeGamemode.Server.Managers
if (player.GetUser().JobId == 1)//Taxifahrer
{
player.TriggerEvent("CLIENT:stopFare");
player.Position = new Vector3(-628.598388671875, -2107.609130859375, 6.072586536407471);
player.SafeTeleport(new Vector3(-628.598388671875, -2107.609130859375, 6.072586536407471));
player.Heading = (-171.50303649902344f);
}
if (player.GetUser().JobId == 2)//Müllmann
{
player.Position = new Vector3(485.4114685058594, -2173.25, 5.918273448944092);
player.SafeTeleport(new Vector3(485.4114685058594, -2173.25, 5.918273448944092));
player.Heading = (-15.922085762023926f);
}
if (player.GetUser().JobId == 3)//Pilot
{
if (!player.HasData("PilotenBase") || player.GetData<int>("PilotenBase") == 1) //Sandyshores
{
player.Position = new Vector3(1707.2711181640625, 3276.216064453125, 41.155494689941406);
player.SafeTeleport(new Vector3(1707.2711181640625, 3276.216064453125, 41.155494689941406));
player.Heading = (-154.65234375f);
}
if (player.HasData("PilotenBase") && player.GetData<int>("PilotenBase") == 2) //LS Airport
{
player.Position = new Vector3(-1622.48, -3151.58, 13);
player.SafeTeleport(new Vector3(-1622.48, -3151.58, 13));
player.Heading = (48.44f);
}
}
if (player.GetUser().JobId == 4)//Busfahrer
{
player.Position = new Vector3(-535.46, -2144.97, 5.95);
player.SafeTeleport(new Vector3(-535.46, -2144.97, 5.95));
player.Heading = (57.03f);
}
}

View File

@@ -5,6 +5,7 @@ using ReallifeGamemode.Server.Shop.Clothing;
using ReallifeGamemode.Server.Shop.SevenEleven;
using ReallifeGamemode.Server.Shop.Friseur;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Extensions;
namespace ReallifeGamemode.Server.Managers
{
@@ -293,7 +294,7 @@ namespace ReallifeGamemode.Server.Managers
return;
}
player.Position = ElevatorPoints.Where(e => e.Stage == level).First().Position;
player.SafeTeleport(ElevatorPoints.Where(e => e.Stage == level).First().Position);
}
}
}

View File

@@ -33,12 +33,16 @@ namespace ReallifeGamemode.Server.Wanted
player.Armor = 0;
Random rnd = new Random();
int rndInt = rnd.Next(1, 3);
Vector3 position = new Vector3();
if (rndInt == 1)
NAPI.Player.SpawnPlayer(player, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail
position = new Vector3(458.9842, -997.2126, 24.91485); //send client to jail
if (rndInt == 2)
NAPI.Player.SpawnPlayer(player, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail
position = new Vector3(459.696, -994.3766, 24.91486); //send client to jail
if (rndInt == 3)
NAPI.Player.SpawnPlayer(player, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail
position = new Vector3(458.3372, -1001.258, 24.91485); //send client to jail
player.SafeTeleport(position, 0, true);
Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds
int timeMinutes;
@@ -135,7 +139,7 @@ namespace ReallifeGamemode.Server.Wanted
if (user.JailTime <= 0)
{
Jailtime.Remove(user.Id);
player.Position = new Vector3(427.879, -984.65, 30.71);
player.SafeTeleport(new Vector3(427.879, -984.65, 30.71));
player.TriggerEvent("jailTime", 0);
return;
}
@@ -179,7 +183,7 @@ namespace ReallifeGamemode.Server.Wanted
dbContext.SaveChanges();
}
player.Health = 100;
player.Position = new Vector3(427.879, -984.65, 30.71);
player.SafeTeleport(new Vector3(427.879, -984.65, 30.71));
ChatService.HQMessage("!{#8181E9}HQ: Beamter " + cop.Name + " hat " + user.Name + " aus dem Knast entlassen.");
ChatService.SendMessage(player, "!{#8181E9}Der Beamte " + cop.Name + " hat dich aus dem Knast entlassen");
@@ -199,7 +203,7 @@ namespace ReallifeGamemode.Server.Wanted
dbContext.SaveChanges();
target.Health = 100;
target.Position = new Vector3(427.879, -984.65, 30.71);
target.SafeTeleport(new Vector3(427.879, -984.65, 30.71));
ChatService.HQMessage(" Admin " + admin.Name + " hat " + user.Name + " aus dem Knast entlassen.");
ChatService.SendMessage(target, "!{#8181E9}Admin " + admin.Name + " hat dich aus dem Knast entlassen");