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

This commit is contained in:
michael.reiswich
2021-05-26 00:16:53 +02:00
8 changed files with 41 additions and 33 deletions

View File

@@ -26,12 +26,7 @@ export default function deathScreen() {
mp.events.add("startDeathTimer", (isAdmin) => {
if (isDeath === false) {
isDeath = true;
if (isAdmin) {
mp.gui.chat.activate(true);
}
else {
mp.gui.chat.activate(false);
}
mp.gui.chat.activate(true);
mp.game.audio.playSoundFrontend(-1, "Bed", "WastedSounds", true);
deathDate = new Date();
respawnTime = Math.floor(deathDate.getTime() / 1000 + maxDeathTime);

View File

@@ -1937,6 +1937,7 @@ namespace ReallifeGamemode.Server.Commands
{
if (!managedPlayer.IsLoggedIn()) return;
managedPlayer.GiveWeapon(weaponHash, munition);
logger.LogInformation("Admin {0} gave the weapon {1} (ammo: {2}) to player {3}", player.Name, weapon, munition, managedPlayer.Name);
ChatService.SendMessage(managedPlayer, "~b~Admin " + player.Name + " hat im Radius von " + radius + " eine/n " + weapon + " mit " + munition + " Munition vergeben.");
}
ChatService.SendMessage(player, "~b~Du hast " + peopleInRange.Count + " Spielern eine " + weapon + " mit " + munition + " Munition gegeben");
@@ -3828,6 +3829,8 @@ namespace ReallifeGamemode.Server.Commands
return;
}
logger.LogInformation("Admin {0} gave the weapon {1} (ammo: {2}) to player {3}", player.Name, hash, ammo, target.Name);
target.GiveWeapon((WeaponHash)uHash, ammo);
ChatService.SendMessage(target, "~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
ChatService.SendMessage(player, "~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");

View File

@@ -45,19 +45,24 @@ namespace ReallifeGamemode.Server.Commands
}
[Command("eventport", "~m~eventport")]
public void CmdUserEventport(Player player, String option = "")
public void CmdUserEventport(Player player, string option = "")
{
if (!player.IsLoggedIn()) return;
option = option.ToLower();
if (option == "on")
{
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
{
return;
}
PositionManager.eventportPosition = player.Position;
Vector3 position = player.Position;
PositionManager.eventportPosition = position;
PositionManager.eventportActive = true;
player.SendChatMessage("~y~Du hast hier erfolgreich einen Eventport gesetzt.");
ChatService.BroadcastAdmin($"~b~[ADMIN]~s~ ~y~{player.Name}~s~ hat einen Eventport erstellt.", AdminLevel.ADMIN);
logger.LogInformation("Admin {0} created the eventport at x: {1}, y: {2}, z: {3}", player.Name, position.X, position.Y, position.Z);
return;
}
@@ -69,6 +74,8 @@ namespace ReallifeGamemode.Server.Commands
}
PositionManager.eventportActive = false;
player.SendChatMessage("~y~Du hast den Eventport deaktiviert.");
ChatService.BroadcastAdmin($"~b~[ADMIN]~s~ ~y~{player.Name}~s~ hat einen Eventport deaktiviert.", AdminLevel.ADMIN);
logger.LogInformation("Admin {0} removed the eventport", player.Name);
return;
}
@@ -92,7 +99,10 @@ namespace ReallifeGamemode.Server.Commands
int randomX = rnd.Next(-3, 3);
int randomY = rnd.Next(-3, 3);
Vector3 teleportPosition = new Vector3(PositionManager.eventportPosition.X + randomX, PositionManager.eventportPosition.Y + randomY, PositionManager.eventportPosition.Z);
Vector3 currentEventport = PositionManager.eventportPosition;
Vector3 teleportPosition = new Vector3(currentEventport.X + randomX, currentEventport.Y + randomY, currentEventport.Z);
logger.LogInformation("Player {0} used the eventport to x: {1}, y: {2}, z: {3}", player.Name, currentEventport.X, currentEventport.Y, currentEventport.Z);
player.SafeTeleport(teleportPosition);
player.SendNotification("Du hast dich zum Event teleportiert");

View File

@@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Inventory;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
@@ -25,6 +27,8 @@ namespace ReallifeGamemode.Server.Events
{
public class Death : Script
{
private static readonly ILogger logger = LogManager.GetLogger<Death>();
private readonly Dictionary<Player, DateTime> lastPlayerDeathTime = new Dictionary<Player, DateTime>();
[ServerEvent(Event.PlayerDeath)]
@@ -61,16 +65,16 @@ namespace ReallifeGamemode.Server.Events
float killerPosZ = -1;
float killerHeading = -1;
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer = {(killer != null ? killer.Name : "no killer found")}");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer = {(killer != null ? killer.Name : "no killer found")}");
if (killer.IsLoggedIn())
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer is logged in");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer is logged in");
var killerUser = killer.GetUser(dbContext);
if (killerUser != null)
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer GetUser is not null");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Killer GetUser is not null");
killerId = killerUser.Id;
killerPosX = killer.Position.X;
killerPosY = killer.Position.Y;
@@ -80,10 +84,10 @@ namespace ReallifeGamemode.Server.Events
var playerInGangwar = player.HasData("inGangWar");
var killerInGangwar = killer.HasData("inGangWar");
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - PlayerInGangwar = {playerInGangwar}, KillerInGangwar = {killerInGangwar}");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - PlayerInGangwar = {playerInGangwar}, KillerInGangwar = {killerInGangwar}");
if (playerInGangwar && killerInGangwar)
{
NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Both players in gangwar, setting kill");
logger.LogDebug($"OnPlayerDeath - Player {player.Name} died - Both players in gangwar, setting kill");
Gangwar.Gangwar.GangwarKill(killer, player);
}
@@ -228,6 +232,7 @@ namespace ReallifeGamemode.Server.Events
[RemoteEvent("RespawnPlayerAtHospital")]
public void RespawnPlayerAtHospital(Player player)
{
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
player.SetData("isDead", false);
using (var dbContext = new DatabaseContext())
{

View File

@@ -299,7 +299,7 @@ namespace ReallifeGamemode.Server.Events
dbContext.VehicleItems.Remove(v);
}
logger.LogInformation("Player {0} took the weapon deal item {1} (amount: {2}) out of weapon vehicle {3}", player.Name, v.VehicleId, itemToAdd, v.VehicleId);
logger.LogInformation("Player {0} took the weapon deal item {1} (amount: {2}) out of weapon vehicle {3}", player.Name, v.ItemId, itemToAdd, v.VehicleId);
InventoryManager.AddItemToInventory(player, v.ItemId, itemToAdd);
nearestBehindVehiclePoint.usePoint(player);
@@ -975,7 +975,7 @@ namespace ReallifeGamemode.Server.Events
return;
}
if(player.Dead == true)
if (player.Dead == true)
{
return;
}

View File

@@ -1,16 +1,20 @@
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Services;
namespace ReallifeGamemode.Server.Gangwar
{
public class Gangwar : Script
{
private static ILogger logger = LogManager.GetLogger<Gangwar>();
public static Turf[] _loadedTurfs;
private static List<Turfs> turfs;
public const int GANGWAR_TOTAL_TIME = 900;
@@ -53,19 +57,19 @@ namespace ReallifeGamemode.Server.Gangwar
var killerInsideTurf = killer.HasData("GotInsideOfTurf");
var victimInsideTurf = victim.HasData("GotInsideOfTurf");
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - KillerInsideTurf = {killerInsideTurf}, VictimInsideTurf = {victimInsideTurf}");
logger.LogDebug($"GangwarKill - Victim {victim.Name} - KillerInsideTurf = {killerInsideTurf}, VictimInsideTurf = {victimInsideTurf}");
if (killerInsideTurf && victimInsideTurf)
{
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Killer and Victim are in Turf area");
logger.LogDebug($"GangwarKill - Victim {victim.Name} - Killer and Victim are in Turf area");
killer.TriggerEvent("gangWarKillNotification", victim.Name);
foreach (var turf in getTurfs())
{
if (turf.getId() == victim.GetData<int>("inGangWar"))
{
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Killed in turf id {turf.getId()}");
logger.LogDebug($"GangwarKill - Victim {victim.Name} - Killed in turf id {turf.getId()}");
var victimFactionName = victim.GetUser().Faction.Name;
NAPI.Util.ConsoleOutput($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}");
logger.LogDebug($"GangwarKill - Victim {victim.Name} - Faction Name = {victimFactionName}");
turf.setKill(victimFactionName);
return;
}
@@ -96,7 +100,7 @@ namespace ReallifeGamemode.Server.Gangwar
[RemoteEvent("Gangarea:Leave")]
public void RmtEvent_TurfLeave(Player client, string jsonId)
{
if(string.IsNullOrEmpty(jsonId))
if (string.IsNullOrEmpty(jsonId))
{
return;
}
@@ -189,7 +193,7 @@ namespace ReallifeGamemode.Server.Gangwar
public void RmtEvent_StartGangwar(Player client)
{
User user = client.GetUser();
if(user == null || user.Faction == null)
if (user == null || user.Faction == null)
{
return;
}

View File

@@ -385,12 +385,12 @@ namespace ReallifeGamemode.Server.Gangwar
{
if (getOwner() == FactionName)
{
NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}");
logger.LogDebug($"GangwarKill - Adding Point for Faction {getAttacker()}");
Att_Score += 1;
}
else if (getAttacker() == FactionName)
{
NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getOwner()}");
logger.LogDebug($"GangwarKill - Adding Point for Faction {getOwner()}");
Def_Score += 1;
}
}

View File

@@ -147,15 +147,6 @@ namespace ReallifeGamemode.Server.WeaponDeal
}
}
/*
public static void WeaponDealTimer()
{
System.Timers.Timer timer = new System.Timers.Timer(60000);
timer.Start();
timer.Elapsed += Timer_Elapsed;
}
*/
public static void Timer_Elapsed()
{
using (var context = new DatabaseContext())