From 2c9985cbb454a81ee9fb0ed91a455d6cdb204ee8 Mon Sep 17 00:00:00 2001 From: kookroach Date: Wed, 21 Apr 2021 20:58:06 +0000 Subject: [PATCH 01/36] Fix BusDriver Problem needs testing (cherry picked from commit 8f9710688a18b56fd9ddbfedf8c049ae7236ebba) --- ReallifeGamemode.Server/Job/BusDriverJob.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index 181b2436..b94308d6 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -440,7 +440,6 @@ namespace ReallifeGamemode.Server.Job else if (type == PROFESSIONAL) BusJobEvents.payWage(player, WAGE_PROFESSIOAL); - NAPI.Task.Run(() => { if (type == BEGINNER) @@ -451,6 +450,9 @@ namespace ReallifeGamemode.Server.Job playerRoutePair3.Remove(player.Name); playerRouteCurrent.Remove(player.Name); + if (!GetPlayerInJob().Contains(player)) + return; + BusDriverJob job = JobManager.GetJob(); StartBusRoute(player, type); }, delayTime: 10000); @@ -464,7 +466,6 @@ namespace ReallifeGamemode.Server.Job NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); } - public void BusCheckpoint(Player player) { if (!player.IsInVehicle || player.VehicleSeat != 0) return; From 885e7976752faefe1913d1b6ae0d2303150b0b91 Mon Sep 17 00:00:00 2001 From: hydrant Date: Wed, 21 Apr 2021 22:00:47 +0000 Subject: [PATCH 02/36] fix route 3 bus skill 3 (cherry picked from commit 57e7455abf0ae7a18c6ee90c6f2cbccc39a21043) --- ReallifeGamemode.Server/Job/BusDriverJob.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ReallifeGamemode.Server/Job/BusDriverJob.cs b/ReallifeGamemode.Server/Job/BusDriverJob.cs index b94308d6..5a596644 100644 --- a/ReallifeGamemode.Server/Job/BusDriverJob.cs +++ b/ReallifeGamemode.Server/Job/BusDriverJob.cs @@ -229,15 +229,15 @@ namespace ReallifeGamemode.Server.Job new List() { //new Vector3(-601.733, -2049.285, 6.090), - new Vector3(-566.381, -2209.74, 5.88064), - new Vector3(769.912, -1983.54, 29.2573), - new Vector3(1021.58, -725.525, 57.6664), - new Vector3(244.279, -860.634, 29.5133), - new Vector3(-506.147, -282.95, 35.4909), - new Vector3(-1205.3, -130.106, 40.9405), - new Vector3(-1396.98, -773.447, 20.68), - new Vector3(-666.861, -1241.26, 10.5494), new Vector3(-599.541, -2054.42, 6.0372), + new Vector3(-666.861, -1241.26, 10.5494), + new Vector3(-1396.98, -773.447, 20.68), + new Vector3(-1205.3, -130.106, 40.9405), + new Vector3(-506.147, -282.95, 35.4909), + new Vector3(244.279, -860.634, 29.5133), + new Vector3(1021.58, -725.525, 57.6664), + new Vector3(769.912, -1983.54, 29.2573), + new Vector3(-566.381, -2209.74, 5.88064), } }, }; From 7186f4e25387975465effa16fb60ab27093274fe Mon Sep 17 00:00:00 2001 From: hydrant Date: Tue, 27 Apr 2021 13:52:49 +0200 Subject: [PATCH 03/36] Revert "remove garbage" This reverts commit fa0be13bb23077ac0610b453f81e3656f23bc768 (cherry picked from commit 4e2e1a46ebe3ce8cfb528a0a07458cbf132c583c) --- ReallifeGamemode.Server/Events/Death.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index baeede9d..c41bbb90 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -71,6 +71,11 @@ namespace ReallifeGamemode.Server.Events if (killerUser != null) { NAPI.Util.ConsoleOutput($"OnPlayerDeath - Player {player.Name} died - Killer GetUser is not null"); + killerId = killerUser.Id; + killerPosX = killer.Position.X; + killerPosY = killer.Position.Y; + killerPosZ = killer.Position.Z; + killerHeading = killer.Heading; var playerInGangwar = player.HasData("inGangWar"); var killerInGangwar = killer.HasData("inGangWar"); From f6cfe9390fcadb06e10e05b4893f85a89c58c7cc Mon Sep 17 00:00:00 2001 From: Alex_qp Date: Wed, 28 Apr 2021 21:00:08 +0200 Subject: [PATCH 04/36] catch FormatException in pay (cherry picked from commit 0cc701755549950cb6b9bc939ff4d9b6fe33778f) --- .../Managers/InteractionManager.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 926dd56f..ce438abe 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Newtonsoft.Json; @@ -753,7 +753,16 @@ namespace ReallifeGamemode.Server.Managers public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount) { string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId); - int amount = Int32.Parse(stringAmount); + int amount; + try + { + amount = Int32.Parse(stringAmount); + } + catch + { + player.SendNotification("~r~" + stringAmount + " ist kein gültiger Betrag."); + return; + } Player target = PlayerService.GetPlayerByNameOrId(nameOrId); List nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player); @@ -769,7 +778,7 @@ namespace ReallifeGamemode.Server.Managers } else if (!nearbyPlayers.Contains(target)) { - player.SendNotification("~r~Dieser Spieler befindet sich nicht in deiner nähe!"); + player.SendNotification("~r~Dieser Spieler befindet sich nicht in deiner Nähe!"); } else if (player.GetUser().Handmoney < amount) { From f0328711687aeac0293e68147d3e60d551ac2bdb Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 27 Apr 2021 18:51:53 +0200 Subject: [PATCH 05/36] befehl spawnschutz zapzerap --- .../Commands/AdminCommands.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index d312239c..9216e766 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -545,6 +545,27 @@ namespace ReallifeGamemode.Server.Commands #region Admin + [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]")] + public void CmdAdminRmss(Player player, String targetname) + { + if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) + { + ChatService.NotAuthorized(player); + return; + } + + Player target = PlayerService.GetPlayerByNameOrId(targetname); + + if (target == null || !target.IsLoggedIn()) + { + ChatService.PlayerNotFound(player); + return; + } + + target.TriggerEvent("abortSpawnschutz"); + + } + [Command("countdown", "~m~Benutzung: ~s~/countdown [Zeit] [Text]", GreedyArg = true)] public void CmdAdminCountdown(Player player, string timer_string, string text) { From 5dbbf508f371a535684304625add4f64fd3d0453 Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 27 Apr 2021 18:41:54 +0200 Subject: [PATCH 06/36] test spawnschutz --- ReallifeGamemode.Client/Player/spawnschutz.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ReallifeGamemode.Client/Player/spawnschutz.ts b/ReallifeGamemode.Client/Player/spawnschutz.ts index 848d7c93..320a135a 100644 --- a/ReallifeGamemode.Client/Player/spawnschutz.ts +++ b/ReallifeGamemode.Client/Player/spawnschutz.ts @@ -16,6 +16,7 @@ export default function spawnschutz() { }); mp.events.add("triggerSpawnschutzTimer", () => { + clearInterval(spawnschutzTimer); spawnschutzTimer = setTimeout(() => { mp.events.call("toggleSpawnschutz", false); spawnschutzEnabled = false; From 39f425059560a33613a9f9ea4f4cec30d49f5f23 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 9 May 2021 01:52:05 +0200 Subject: [PATCH 07/36] fix rmss --- .../Commands/AdminCommands.cs | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index bb59b4be..59c1fcb2 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -585,27 +585,6 @@ namespace ReallifeGamemode.Server.Commands } - [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]")] - public void CmdAdminRmss(Player player, String targetname) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Player target = PlayerService.GetPlayerByNameOrId(targetname); - - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.TriggerEvent("abortSpawnschutz"); - - } - [Command("countdown", "~m~Benutzung: ~s~/countdown [Zeit] [Text]", GreedyArg = true)] public void CmdAdminCountdown(Player player, string timer_string, string text) { @@ -3858,9 +3837,12 @@ namespace ReallifeGamemode.Server.Commands string playedHoursString = ""; int jailTime = targetUser.JailTime; - if (user.IsAdmin(AdminLevel.HEADADMIN)) { + if (user.IsAdmin(AdminLevel.HEADADMIN)) + { playedHoursString = playedHours.ToString(); - } else { + } + else + { int newbiePlayedHoursThreshold = GlobalHelper.newbiePlayedMinutesThreshold / 60; playedHoursString = playedHours > newbiePlayedHoursThreshold ? (newbiePlayedHoursThreshold + "+") : playedHours.ToString(); } From 3c2d56f2ad21ac99185f2f2c95ce30b8f1666bec Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 00:58:14 +0200 Subject: [PATCH 08/36] =?UTF-8?q?M-Men=C3=BC=20fix=20wenn=20zivilist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReallifeGamemode.Server/Events/Key.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 6be91059..15af42c2 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -171,7 +171,7 @@ namespace ReallifeGamemode.Server.Events isActive = JobBase.GetPlayerInJob().Contains(player), }; - var memberList = dbContext.Users.Where(f => f.FactionId == u.FactionId && u.FactionId != 0).OrderByDescending(f => f.FactionRank.Order).ThenBy(f => f.Name).Select(m => new + var memberList = dbContext.Users.Where(f => f.FactionId == u.FactionId && u.FactionId != null && u.FactionId != 0).OrderByDescending(f => f.FactionRank.Order).ThenBy(f => f.Name).Select(m => new { username = m.Name, factionRank = m.FactionRank.Order, From a2db770316a6f76a660ba20825773675f3109f81 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 03:14:37 +0200 Subject: [PATCH 09/36] GELD LOGS --- .../Managers/HouseManager.cs | 3 + .../Menus/PoliceDepartment.cs | 9 +- ReallifeGamemode.Server/Bank/bank.cs | 70 ++-- .../Commands/AdminCommands.cs | 4 + .../Commands/FactionCommands.cs | 14 +- .../Commands/UserCommands.cs | 12 +- .../DrivingSchool/DrivingSchool.cs | 81 ++-- .../DrivingSchool/PlaneSchool.cs | 13 +- .../Events/UpdateCharacterCloth.cs | 12 +- ReallifeGamemode.Server/Events/Weapon.cs | 2 +- .../Extensions/ClientExtension.cs | 6 + .../Factions/Medic/Medic.cs | 34 +- ReallifeGamemode.Server/Finance/Economy.cs | 9 +- ReallifeGamemode.Server/Gangwar/Turf.cs | 10 +- ReallifeGamemode.Server/Main.cs | 390 +++++++++--------- .../Managers/ATMManager.cs | 12 +- .../Managers/CharacterCreator.cs | 5 + .../Managers/CityHallManager.cs | 10 +- .../Managers/InteractionManager.cs | 24 +- .../Managers/InventoryManager.cs | 19 +- .../Managers/TuningManager.cs | 7 +- ReallifeGamemode.Server/Util/Rentcar.cs | 8 +- 22 files changed, 448 insertions(+), 306 deletions(-) diff --git a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs index aaf43688..0ccca564 100644 --- a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs +++ b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs @@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Core.Extensions; using System.Linq; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Common; +using Microsoft.Extensions.Logging; namespace ReallifeGamemode.Server.Core.Managers { @@ -451,6 +452,8 @@ namespace ReallifeGamemode.Server.Core.Managers return; } + Log.LogInformation("Player {0} did a withdraw of {1} dollars from house {2}", player.Name, amount, house.Id); + user.BankAccount.Balance += amount; house.BankAccount.Balance -= amount; diff --git a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs index f4e9c3ef..67021b46 100644 --- a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs +++ b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs @@ -6,12 +6,13 @@ using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Core.Extensions; using Microsoft.EntityFrameworkCore; using System.Linq; +using Microsoft.Extensions.Logging; namespace ReallifeGamemode.Server.Core.Menus { internal class PoliceDepartment : Script { - + private const int WEAPONLICENSE_PRICE = 5000; public PoliceDepartment() { @@ -40,13 +41,15 @@ namespace ReallifeGamemode.Server.Core.Menus var account = user.BankAccount; - if (account.Balance < 5000) + if (account.Balance < WEAPONLICENSE_PRICE) { player.SendMessage("Du hast nicht genug Geld auf der Bank (5.000$)!", ChatPrefix.Error); return; } - account.Balance -= 5000; + Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name); + + account.Balance -= WEAPONLICENSE_PRICE; player.SendMessage("Du hast den Waffenschein erfolgreich erworben.", ChatPrefix.Info); diff --git a/ReallifeGamemode.Server/Bank/bank.cs b/ReallifeGamemode.Server/Bank/bank.cs index a17e81c6..b074d0a9 100644 --- a/ReallifeGamemode.Server/Bank/bank.cs +++ b/ReallifeGamemode.Server/Bank/bank.cs @@ -4,18 +4,20 @@ * @copyright (c) 2008 - 2021 Life of German */ using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Finance; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Services; using System; namespace ReallifeGamemode.Server.Bank { - class bank : Script + class Bank : Script { private static TextLabel informationLabel; private static TextLabel factionInformationLabel; @@ -25,6 +27,7 @@ namespace ReallifeGamemode.Server.Bank private static ColShape _factioncolShape; public static Vector3 Position { get; } + private static readonly ILogger logger = LogManager.GetLogger(); public static void Setup() { @@ -58,7 +61,7 @@ namespace ReallifeGamemode.Server.Bank } private static void EntityEnterFactionBankColShape(ColShape colShape, Player client) - { + { if (client.IsInVehicle || !client.IsLoggedIn() || client.GetUser().FactionId is null) return; User user = client.GetUser(); @@ -92,6 +95,7 @@ namespace ReallifeGamemode.Server.Bank } else { + logger.LogInformation("Player {0} did a deposit of {1} dollars at the bank", player.Name, amount); player.SendNotification($"~w~Du hast $~g~{amount} ~w~eingezahlt."); player.GetUser(dbContext).Handmoney -= amount; player.GetUser(dbContext).BankAccount.Balance += amount; @@ -115,6 +119,7 @@ namespace ReallifeGamemode.Server.Bank } else { + logger.LogInformation("Player {0} did a withdraw of {1} dollars at the bank", player.Name, amount); player.SendNotification($"~w~Du hast $~g~{amount} ~w~abgehoben."); player.GetUser(dbContext).Handmoney += amount; player.GetUser(dbContext).BankAccount.Balance -= amount; @@ -130,34 +135,40 @@ namespace ReallifeGamemode.Server.Bank int amount = Int32.Parse(stringAmount); Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (!target.IsLoggedIn()) + { + player.SendNotification($"~r~Dieser Spieler ist nicht Online."); + return; + } + using (var dbContext = new DatabaseContext()) { - if (player.GetUser().PlayedMinutes < 180) + User user = player.GetUser(dbContext); + if (user.PlayedMinutes < 180) { player.SendNotification("~r~Du kannst Geld erst ab 3 Spielstunden vergeben"); return; } - if (player.GetUser(dbContext) == target.GetUser(dbContext)) + + User targetUser = target.GetUser(dbContext); + + if (user == targetUser) { player.SendNotification($"~r~Du kannst dir selber kein Geld überweisen."); return; } - else if (!target.IsLoggedIn()) - { - player.SendNotification($"~r~Dieser Spieler ist nicht Online."); - - } - else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).BankAccount.Balance) + else if (amount <= 0 || (int)(amount * 1.05) > user.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); return; } else { + logger.LogInformation("Player {0} did a transfer of {1} dollars to {2}", user.Name, amount, targetUser.Name); player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen."); target.SendNotification($"~w~{player.Name} hat dir $~g~{amount} ~w~Überwiesen."); - player.GetUser(dbContext).BankAccount.Balance -= (int)(amount * 1.05); - target.GetUser(dbContext).otheramount += amount; + user.BankAccount.Balance -= (int)(amount * 1.05); + targetUser.otheramount += amount; dbContext.SaveChanges(); } } @@ -170,17 +181,23 @@ namespace ReallifeGamemode.Server.Bank using (var dbContext = new DatabaseContext()) { + User user = player.GetUser(dbContext); + if (user.FactionId == null) + { + return; + } - if (amount <= 0 || amount > player.GetUser(dbContext).BankAccount.Balance) + if (amount <= 0 || amount > user.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag ist ungültig."); return; } else { + logger.LogInformation("Player {0} did a faction payin of {1} dollars to faction {2}", user.Name, amount, user.Faction.Id); player.SendNotification($"~w~Du hast $~g~{amount}~w~ in die Fraktionskasse eingezahlt."); - player.GetUser(dbContext).BankAccount.Balance -= amount; - player.GetUser(dbContext).Faction.BankAccount.Balance += amount; + user.BankAccount.Balance -= amount; + user.Faction.BankAccount.Balance += amount; dbContext.SaveChanges(); } } @@ -193,23 +210,28 @@ namespace ReallifeGamemode.Server.Bank int amount = Int32.Parse(stringAmount); Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (!target.IsLoggedIn()) + { + player.SendNotification($"~r~Dieser Spieler ist nicht Online."); + return; + } + using (var dbContext = new DatabaseContext()) { - if (!target.IsLoggedIn()) - { - player.SendNotification($"~r~Dieser Spieler ist nicht Online."); - - } - else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).Faction.BankAccount.Balance) + User user = player.GetUser(dbContext); + User targetUser = target.GetUser(dbContext); + if (amount <= 0 || (int)(amount * 1.05) > user.Faction.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); return; } else { - player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen."); - player.GetUser(dbContext).Faction.BankAccount.Balance -= (int)(amount * 1.05); - target.GetUser(dbContext).otheramount += amount; + logger.LogInformation("Player {0} did a faction transfer of {1} dollars from faction {2} to {3}", user.Name, amount, user.Faction.Id, target); + player.SendNotification($"Du hast ~g~{amount.ToMoneyString()}~s~ an ~y~{targetUser.Name}~s~ überwiesen"); + target.SendNotification($"Dir wurden ~g~{amount.ToMoneyString()}~s~ von ~y~{user.Name}~s~ überwiesen"); + user.Faction.BankAccount.Balance -= (int)(amount * 1.05); + targetUser.otheramount += amount; dbContext.SaveChanges(); } } diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 0c61a0bb..dbf19e4d 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2287,6 +2287,7 @@ namespace ReallifeGamemode.Server.Commands { var user = target.GetUser(context); user.Handmoney = amount; + logger.LogInformation("Admin {0} set the handmoney of player {1} to {2} dollars", admin.Name, target.Name, amount); context.SaveChanges(); //target.TriggerEvent("SERVER:SET_HANDMONEY", amount); } @@ -2313,6 +2314,7 @@ namespace ReallifeGamemode.Server.Commands { var user = target.GetUser(context); user.Handmoney += amount; + logger.LogInformation("Admin {0} added {2} dollarsto the handmoney of player {1}", admin.Name, target.Name, amount); context.SaveChanges(); //target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); } @@ -3356,6 +3358,7 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { + logger.LogInformation("Admin {0} set the bank account of {1} to {2} dollars", player.Name, target.Name, amount); target.GetUser(dbContext).BankAccount.Balance = amount; dbContext.SaveChanges(); } @@ -3381,6 +3384,7 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { + logger.LogInformation("Admin {0} added {2} dollars to the bank account of {1}", player.Name, target.Name, amount); target.GetUser(dbContext).BankAccount.Balance += amount; dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 9d90d3a2..7dd4e5b7 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities.Logs.Chat; using ReallifeGamemode.Database.Models; @@ -15,6 +16,7 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Faction Commands (Faction.cs) @@ -26,6 +28,8 @@ namespace ReallifeGamemode.Server.Commands { internal class FactionCommands : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + #region Chat Commands [Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)] @@ -413,17 +417,19 @@ namespace ReallifeGamemode.Server.Commands return; } - if (deadPlayerUser.Handmoney >= 100) + if (deadPlayerUser.Handmoney >= Medic.ReviveIncome) { - deadPlayerUser.Handmoney -= 100; + deadPlayerUser.Handmoney -= Medic.ReviveIncome; } else { - int bankMoney = 100 - deadPlayerUser.Handmoney; + int bankMoney = Medic.ReviveIncome - deadPlayerUser.Handmoney; deadPlayerUser.Handmoney = 0; deadPlayerUser.BankAccount.Balance -= bankMoney; } + logger.LogInformation("Player {0} has been revived by {1} for {2} dollars", deadPlayer.Name, player.Name, Medic.ReviveIncome); + player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0); deadPlayer.TriggerEvent("onPlayerRevived"); diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 2ed40def..ec9dfcd2 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; @@ -13,11 +14,16 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Commands { internal class UserCommands : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + + private const int SMS_PRICE = 5; + [Command("rent", "~m~rent stop")] public void CmdUserStopRent(Player player, String option = "") { @@ -113,13 +119,15 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { User user = player.GetUser(dbContext); - if (user.BankAccount.Balance < 5) + if (user.BankAccount.Balance < SMS_PRICE) { ChatService.ErrorMessage(player, "Dafür hast du nicht genug Geld auf deinem Bankkonto"); return; } - user.BankAccount.Balance -= 5; + logger.LogInformation("Player {0} sent a sms to {1} for {2} dollars", player.Name, target.Name, SMS_PRICE); + + user.BankAccount.Balance -= SMS_PRICE; dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs index 590bbf7e..3f333409 100644 --- a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs +++ b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs @@ -6,17 +6,24 @@ using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; using System; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.DrivingSchool { internal class DrivingSchool : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + private static TextLabel informationLabel; private static Marker marker; private static ColShape _colShape; public static Vector3 Position { get; } private const int FAILPOINTS = 2; + private const int CAR_LICENSE_PRICE = 2500; + private const int BIKE_LICENSE_PRICE = 3500; + private readonly IReadOnlyCollection BikeRoute = new List { new Vector3(-741.98, -1283.46, 6.17), @@ -122,14 +129,14 @@ namespace ReallifeGamemode.Server.DrivingSchool public void StartDrivingSchool(Player client) { User user = client.GetUser(); - + if (user.DriverLicenseVehicle || client.HasData("ActiveSchool")) { client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Führerschein."); return; } - - if (user.Handmoney < 2500) + + if (user.Handmoney < CAR_LICENSE_PRICE) { client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($2.500)!", true); return; @@ -138,7 +145,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 2500; + payer.Handmoney -= CAR_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the driving school (car) for {1} dollars", client.Name, CAR_LICENSE_PRICE); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } @@ -174,8 +182,8 @@ namespace ReallifeGamemode.Server.DrivingSchool [RemoteEvent("drivingSchoolEventEnd")] public void DrivingSchoolEventEnd(Player user, int checkpoint) { - using (var dbContext = new DatabaseContext()) - { + using (var dbContext = new DatabaseContext()) + { User drivingUser = user.GetUser(dbContext); if (drivingUser.failpoints > FAILPOINTS) @@ -186,13 +194,13 @@ namespace ReallifeGamemode.Server.DrivingSchool else { user.TriggerEvent("renderTextOnScreen", "Du hast den Führerschein bestanden. Glückwunsch!"); - user.ResetData("ActiveSchool"); + user.ResetData("ActiveSchool"); drivingUser.DriverLicenseVehicle = true; drivingUser.failpoints = 0; dbContext.SaveChanges(); } - - } + + } Vehicle veh = user.Vehicle; user.WarpOutOfVehicle(); ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh); @@ -208,31 +216,31 @@ namespace ReallifeGamemode.Server.DrivingSchool [RemoteEvent("drivingSchoolEvent")] public void DrivingSchoolEvent(Player user, int checkpoint) { - /* for (int i = 0; i >= 33; i++) - { - if (checkpoint <= 24) - { - user.TriggerEvent("kmh100"); - } - else if (checkpoint >= 25 && checkpoint <= 26) - { - user.TriggerEvent("kmh150"); - } - else if (checkpoint >= 26 && checkpoint <= 28) - { - user.TriggerEvent("kmh100"); - } - else if (checkpoint >= 29 && checkpoint <= 31) - { - user.TriggerEvent("kmh150"); - } - else if (checkpoint >= 32 && checkpoint <= 33) - { - user.TriggerEvent("kmh100"); - } - } - */ - switch(checkpoint) + /* for (int i = 0; i >= 33; i++) + { + if (checkpoint <= 24) + { + user.TriggerEvent("kmh100"); + } + else if (checkpoint >= 25 && checkpoint <= 26) + { + user.TriggerEvent("kmh150"); + } + else if (checkpoint >= 26 && checkpoint <= 28) + { + user.TriggerEvent("kmh100"); + } + else if (checkpoint >= 29 && checkpoint <= 31) + { + user.TriggerEvent("kmh150"); + } + else if (checkpoint >= 32 && checkpoint <= 33) + { + user.TriggerEvent("kmh100"); + } + } + */ + switch (checkpoint) { case 25: case 26: @@ -275,7 +283,7 @@ namespace ReallifeGamemode.Server.DrivingSchool client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Motorradschein."); return; } - if (user.Handmoney < 3500) + if (user.Handmoney < BIKE_LICENSE_PRICE) { client.SendNotification("~r~[FEHLER]~s~Du hast nicht genug Geld auf der Hand($3.500)!", true); return; @@ -284,7 +292,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 3500; + payer.Handmoney -= BIKE_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the driving school (bike) for {1} dollars", client.Name, BIKE_LICENSE_PRICE); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs b/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs index 310860ec..94873705 100644 --- a/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs +++ b/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; @@ -15,8 +17,12 @@ namespace ReallifeGamemode.Server.DrivingSchool private static ColShape _colShape1; public static Vector3 Position { get; } + private static readonly ILogger logger = LogManager.GetLogger(); + private const int CHECKPOINT_MARKER_ID = 6; + private const int PLANE_LICENSE_PRICE = 5000; + private readonly IReadOnlyCollection planeRoute = new List { new Vector3(-1114.39, -2333.09, 14.87), @@ -74,7 +80,7 @@ namespace ReallifeGamemode.Server.DrivingSchool client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Flugschein."); return; } - if (user.Handmoney < 5000) + if (user.Handmoney < PLANE_LICENSE_PRICE) { client.SendNotification("~r~Du brauchst ~g~$5.000~r~ auf der Hand, um die Prüfung starten zu können.", true); return; @@ -82,7 +88,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 5000; + payer.Handmoney -= PLANE_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the plane school for {1} dollars", client.Name, PLANE_LICENSE_PRICE); //client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } @@ -171,7 +178,7 @@ namespace ReallifeGamemode.Server.DrivingSchool case 14: user.TriggerEvent("renderTextOnScreen", "Setzen Sie zum Landeanflug an. Drücken Sie 'G', um das Fahrwerk auszufahren."); - CheckPointHandle.StartCheckPointRoute(user, planeRouteEnd, 5000, CHECKPOINT_MARKER_ID, 12, 5, true, "planeSchoolEventEnd"); + CheckPointHandle.StartCheckPointRoute(user, planeRouteEnd, PLANE_LICENSE_PRICE, CHECKPOINT_MARKER_ID, 12, 5, true, "planeSchoolEventEnd"); break; } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index ea2d67d6..086ec118 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -6,11 +6,15 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using System; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Events { public class UpdateCharacterCloth : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + [RemoteEvent("updateDutyProp")] public void UpdateDutyProp(Player player, int componentId, int componentVariation) { @@ -280,7 +284,8 @@ namespace ReallifeGamemode.Server.Events } } - if(data[0] == 2){ + if (data[0] == 2) + { User payer = client.GetUser(dbContext); payer.GetCharacter(dbContext); payer.Character.Hair = Convert.ToByte(data[2]); @@ -288,13 +293,14 @@ namespace ReallifeGamemode.Server.Events } client.GetUser(dbContext).Handmoney -= data[6]; + logger.LogInformation("Player {0} bought clothing for {1} dollars: slot = {2}, cloth = {3}, texture = {4}", client.Name, data[6], data[0], data[2], data[1]); dbContext.SaveChanges(); //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); } client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); } } - + [RemoteEvent("SERVER:BuyHairColor")] public void BuyHairColor(Player client, byte HairColor) @@ -332,7 +338,7 @@ namespace ReallifeGamemode.Server.Events User payer = client.GetUser(dbContext); payer.GetCharacter(dbContext); payer.Handmoney -= 50; - payer.Character.HairHighlightColor = HairlightColor; + payer.Character.HairHighlightColor = HairlightColor; // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/Events/Weapon.cs b/ReallifeGamemode.Server/Events/Weapon.cs index c32f22c0..34d7661d 100644 --- a/ReallifeGamemode.Server/Events/Weapon.cs +++ b/ReallifeGamemode.Server/Events/Weapon.cs @@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server.Events player.SendNotification("Du hast nicht genügend Geld bei dir"); return; } - logger.LogInformation("Player {0} bought a {1} in ammunation", user.Name, weaponmodel); + logger.LogInformation("Player {0} bought a weapon {1} in ammunation for {2} dollars", user.Name, weaponmodel, price); user.Handmoney -= price; dbContext.SaveChanges(); player.GiveWeapon(NAPI.Util.WeaponNameToModel(weaponmodel), ammo); diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index dcd4d284..2b57264b 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Admin; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; @@ -22,6 +24,8 @@ namespace ReallifeGamemode.Server.Extensions { public static class PlayerExtension { + private static ILogger Logger => LogManager.GetLogger(typeof(PlayerExtension)); + /// /// Gibt das User-Objekt eines Player's zurück. /// Gibt nichts zurück, wenn der Player nicht eingeloggt ist @@ -108,6 +112,8 @@ namespace ReallifeGamemode.Server.Extensions faction.BankAccount.Balance += factionMoney; } + Logger.LogInformation("Player {0} was sent to jail for {1} seconds, executive factions got {2} dollars each", user.Name, time, factionMoney); + user.Wanteds = 0; user.JailTime = time; } diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 1bc98dcd..58847dcf 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -9,6 +9,8 @@ using ReallifeGamemode.Database.Models; using Microsoft.EntityFrameworkCore; using System; using ReallifeGamemode.Server.Extensions; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Server Factions Medic Medic.cs @@ -20,6 +22,8 @@ namespace ReallifeGamemode.Server.Factions.Medic { public class Medic : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + public static List ReviveTasks = new List(); public static List HealTasks = new List(); public static List FireTasks = new List(); @@ -34,7 +38,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public Player dTarget; public int dPrice; } - + public static void AddTaskToList(MedicTask task) { if (task == null) @@ -84,7 +88,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void UpdateReviveSperre() { var allRevivedPlayers = NAPI.Pools.GetAllPlayers().Where(c => c.HasData("reviveSperre")); - foreach(var player in allRevivedPlayers) + foreach (var player in allRevivedPlayers) { var timeLeft = player.GetData("reviveSperre"); @@ -101,7 +105,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void CheckHealDecisionDistance() { - foreach(var healAuftrag in HealDecisions.ToList()) + foreach (var healAuftrag in HealDecisions.ToList()) { if (healAuftrag.dMedic.Position.DistanceTo(healAuftrag.dTarget.Position) > 5) { @@ -117,9 +121,9 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void MakeHealDecision(Player target, bool decision) { var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target); - if(decision == false) + if (decision == false) { - activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt",false); + activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt", false); activeDecision.dTarget.SendNotification("Du hast den Heal ~r~abgelehnt", false); } else @@ -141,6 +145,8 @@ namespace ReallifeGamemode.Server.Factions.Medic targetUser.BankAccount.Balance -= bankMoney; } + logger.LogInformation("Player {0} accepted a heal for {1} dollars from medic {2}", target.Name, activeDecision.dPrice, activeDecision.dMedic.Name); + dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += activeDecision.dPrice / 2; activeDecision.dMedic.GetUser(dbContext).Wage += activeDecision.dPrice / 2; @@ -149,7 +155,7 @@ namespace ReallifeGamemode.Server.Factions.Medic activeDecision.dTarget.SafeSetHealth(100); activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false); activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false); - delHealTask(activeDecision.dTarget); + delHealTask(activeDecision.dTarget); } HealDecisions.Remove(activeDecision); } @@ -166,7 +172,7 @@ namespace ReallifeGamemode.Server.Factions.Medic var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime)); task.TimeLeft = taskTimeLeft; var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); - if(medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft); + if (medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft); } } } @@ -176,14 +182,14 @@ namespace ReallifeGamemode.Server.Factions.Medic { if (HealTasks.Count != 0) { - foreach(var task in HealTasks) + foreach (var task in HealTasks) { - if(task.MedicName != "none") + if (task.MedicName != "none") { var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); var victim = PlayerService.GetPlayerByNameOrId(task.Victim); - if(medic == null || victim == null) + if (medic == null || victim == null) { continue; } @@ -241,11 +247,11 @@ namespace ReallifeGamemode.Server.Factions.Medic { reviveTask.MedicName = "none"; } - else + else { reviveTask.MedicName = player.Name; } - + ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Reviveauftrag von " + victim + " angenommen.", new List() { 2 }); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ eilt zur Rettung."); break; @@ -261,7 +267,7 @@ namespace ReallifeGamemode.Server.Factions.Medic healTask.MedicName = player.Name; ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Healauftrag von " + victim + " angenommen.", new List() { 2 }); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ hat deinen Auftrag angenommen."); - } + } break; case 2: @@ -275,7 +281,7 @@ namespace ReallifeGamemode.Server.Factions.Medic { MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name); if (task != null) - { + { player.SetData("healauftrag", false); var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName); if (medicPlayer != null) diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index f602fb3a..65fa002f 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -9,9 +9,11 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Wanted; @@ -19,6 +21,8 @@ namespace ReallifeGamemode.Server.Finance { public class Economy { + private static readonly ILogger logger = LogManager.GetLogger(); + public static Dictionary Paychecks { get; set; } = new Dictionary(); public static (int, float, float) GetEconomyClass(Player client, int wage) @@ -162,6 +166,8 @@ namespace ReallifeGamemode.Server.Finance } } + logger.LogInformation("Player {0} has a payday of {1} dollars. old balance: {2}, new balance: {3}", client.Name, paycheck.Amount, u.BankAccount.Balance, u.BankAccount.Balance + paycheck.Amount); + u.BankAccount.Balance += paycheck.Amount; u.Wage = 0; u.otheramount = 0; @@ -173,7 +179,7 @@ namespace ReallifeGamemode.Server.Finance .Where(hR => hR.UserId == u.Id); dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1); - + logger.LogInformation("Medic faction got a health insurance payment of {0} dollars from player {1}", paycheck.HealthInsurance * 0.1, client.Name); if (rentals.Any()) { foreach (var rental in rentals) @@ -181,6 +187,7 @@ namespace ReallifeGamemode.Server.Finance if (rental?.House?.BankAccount != null) { rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); + logger.LogInformation("House {0} got a rentalfee of {1} from paycheck from user {2}", rental.House.Id, rental.House.RentalFee * 0.7, u.Name); } } } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 3cd1d52b..88573919 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -5,16 +5,20 @@ using System.Threading.Tasks; using System.Timers; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +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 Turf { + private static readonly ILogger logger = LogManager.GetLogger(); + public int TurfID { get; set; } public string TurfName { get; set; } public int Color { get; set; } @@ -203,7 +207,7 @@ namespace ReallifeGamemode.Server.Gangwar public void enter(Player client) { User user = client.GetUser(); - if(user == null || user.FactionId == null) + if (user == null || user.FactionId == null) { return; } @@ -276,6 +280,7 @@ namespace ReallifeGamemode.Server.Gangwar a.TriggerEvent("CLIENT:loose"); } ownerFaction.BankAccount.Balance += 15000; + logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getAttacker(), 15000); } else if (getOwner() != FactionName) { @@ -292,6 +297,7 @@ namespace ReallifeGamemode.Server.Gangwar if (a != null) a.TriggerEvent("CLIENT:win"); } + logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getOwner(), 10000); this.Owner = FactionName; attackerFaction.BankAccount.Balance += 10000; Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); @@ -379,7 +385,7 @@ namespace ReallifeGamemode.Server.Gangwar { if (getOwner() == FactionName) { - NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); + NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); Att_Score += 1; } else if (getAttacker() == FactionName) diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index 28e226d3..c50c6ce4 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -29,212 +29,212 @@ using System.IO; namespace ReallifeGamemode.Server { - public class Main : Script - { - public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); - public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; - - public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); - - private Core.Events.EventHandler eventHandler; - - private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); - - public Main() + public class Main : Script { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - } + public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); + public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; - [ServerEvent(Event.ResourceStart)] - public void OnResourceStart() - { - try - { - if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") + public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); + + private Core.Events.EventHandler eventHandler; + + private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); + + public Main() { - using var dbContext = new DatabaseContext(true); - - var pendingMigrations = dbContext.Database.GetPendingMigrations(); - - if (!pendingMigrations.Any()) - { - System.Console.WriteLine("No migrations to apply"); - } - else - { - System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); - foreach (var migration in pendingMigrations) - { - System.Console.WriteLine("\t{0}", migration); - } - - try - { - dbContext.Database.Migrate(); - } - catch (System.Exception e) - { - System.Console.WriteLine("Error while updating database: {0}", e.ToString()); - System.Console.ReadLine(); - System.Environment.Exit(1); - } - - System.Console.WriteLine("Migrations successfull"); - } + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; } - var methods = Assembly.GetExecutingAssembly() - .GetTypes() - .SelectMany(t => t.GetMethods()) - .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) - .ToArray(); - - var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); - - var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); - cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() { - registeredCommands.AddRange(a.Alias.Split(',')); - }); - - IAPI apiInstance = new RageAPI(); - eventHandler = new Core.Events.EventHandler(apiInstance); - - new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); - - NAPI.Server.SetGlobalServerChat(false); - - NAPI.Server.SetCommandErrorMessage(""); - NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); - NAPI.Server.SetAutoSpawnOnConnect(false); - NAPI.Server.SetAutoRespawnAfterDeath(false); - NAPI.Data.SetWorldData("playerCreatorDimension", 0); - - JsonConvert.DefaultSettings = () => - { - return new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }; - }; - - InventoryManager.LoadItems(); - ShopManager.LoadClotheShops(); - ShopManager.LoadItemShops(); - ShopManager.LoadFriseur(); - ShopManager.LoadAmmunations(); - TuningManager.LoadTuningGarages(); - - TimeManager.StartTimeManager(); - VehicleManager.CheckEnabledMods(); - - DatabaseHelper.InitDatabaseFirstTime(); - - FactionHelper.CheckFactionBankAccounts(); - BusinessManager.LoadBusinesses(); - //InteriorManager.LoadInteriors(); - DoorManager.LoadDoors(); - ATMManager.InitATMs(); - CityHallManager.LoadCityHall(); - JobManager.LoadJobs(); - //TaxiDriverJob.StartTaxiTimer(); Obselete - //HouseManager.LoadHouses(); - DrivingSchool.DrivingSchool.Setup(); - PlaneSchool.Setup(); - Gangwar.Gangwar.loadTurfs(); - Bank.bank.Setup(); - Introduction.Setup(); - PositionManager.LoadPositionManager(); - LoadManager.LoadLoadManager(); - Rentcar.Setup(); - - World.WeatherSync.Load(); - - TempBlip tempBlip = new TempBlip() - { - Color = 1, - Name = "", - Transparency = 0, - ShortRange = true, - Sprite = 1, - Scale = 1, - }; - - NAPI.Data.SetWorldData("blipTemplate", tempBlip); - - //WantedEscapeTimer.WantedTimer(); Obselete - //Jail.JailTimer(); Obselete - //Economy.PaydayTimer(); Obselete - // WeaponDealManager.WeaponDealTimer(); Obselete - - ThreadTimers.StartAllTimers(); - - Managers.SVarManager.LoadSVars(); - - UserBankAccount.BalanceChanged += (account) => - { - using (var dbContext = new DatabaseContext()) - { - var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); - if (user == null) + try { - return; + if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") + { + using var dbContext = new DatabaseContext(true); + + var pendingMigrations = dbContext.Database.GetPendingMigrations(); + + if (!pendingMigrations.Any()) + { + System.Console.WriteLine("No migrations to apply"); + } + else + { + System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); + foreach (var migration in pendingMigrations) + { + System.Console.WriteLine("\t{0}", migration); + } + + try + { + dbContext.Database.Migrate(); + } + catch (System.Exception e) + { + System.Console.WriteLine("Error while updating database: {0}", e.ToString()); + System.Console.ReadLine(); + System.Environment.Exit(1); + } + + System.Console.WriteLine("Migrations successfull"); + } + } + + var methods = Assembly.GetExecutingAssembly() + .GetTypes() + .SelectMany(t => t.GetMethods()) + .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) + .ToArray(); + + var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); + + var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); + cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => + { + registeredCommands.AddRange(a.Alias.Split(',')); + }); + + IAPI apiInstance = new RageAPI(); + eventHandler = new Core.Events.EventHandler(apiInstance); + + new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); + + NAPI.Server.SetGlobalServerChat(false); + + NAPI.Server.SetCommandErrorMessage(""); + NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); + NAPI.Server.SetAutoSpawnOnConnect(false); + NAPI.Server.SetAutoRespawnAfterDeath(false); + NAPI.Data.SetWorldData("playerCreatorDimension", 0); + + JsonConvert.DefaultSettings = () => + { + return new JsonSerializerSettings() + { + NullValueHandling = NullValueHandling.Ignore + }; + }; + + InventoryManager.LoadItems(); + ShopManager.LoadClotheShops(); + ShopManager.LoadItemShops(); + ShopManager.LoadFriseur(); + ShopManager.LoadAmmunations(); + TuningManager.LoadTuningGarages(); + + TimeManager.StartTimeManager(); + VehicleManager.CheckEnabledMods(); + + DatabaseHelper.InitDatabaseFirstTime(); + + FactionHelper.CheckFactionBankAccounts(); + BusinessManager.LoadBusinesses(); + //InteriorManager.LoadInteriors(); + DoorManager.LoadDoors(); + ATMManager.InitATMs(); + CityHallManager.LoadCityHall(); + JobManager.LoadJobs(); + //TaxiDriverJob.StartTaxiTimer(); Obselete + //HouseManager.LoadHouses(); + DrivingSchool.DrivingSchool.Setup(); + PlaneSchool.Setup(); + Gangwar.Gangwar.loadTurfs(); + Bank.Bank.Setup(); + Introduction.Setup(); + PositionManager.LoadPositionManager(); + LoadManager.LoadLoadManager(); + Rentcar.Setup(); + + World.WeatherSync.Load(); + + TempBlip tempBlip = new TempBlip() + { + Color = 1, + Name = "", + Transparency = 0, + ShortRange = true, + Sprite = 1, + Scale = 1, + }; + + NAPI.Data.SetWorldData("blipTemplate", tempBlip); + + //WantedEscapeTimer.WantedTimer(); Obselete + //Jail.JailTimer(); Obselete + //Economy.PaydayTimer(); Obselete + // WeaponDealManager.WeaponDealTimer(); Obselete + + ThreadTimers.StartAllTimers(); + + Managers.SVarManager.LoadSVars(); + + UserBankAccount.BalanceChanged += (account) => + { + using (var dbContext = new DatabaseContext()) + { + var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); + if (user == null) + { + return; + } + + Player player = PlayerService.GetPlayerByNameOrId(user); + if (player == null) + { + return; + } + + player.TriggerEvent("updateMoney", account.Balance); + } + }; + + User.HandMoneyChanged += (user) => + { + user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + }; + + //IPLS + NAPI.World.RequestIpl("vw_casino_garage"); + + } + catch (Exception e) + { + Log(e.ToString()); + } + } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Log(e.ExceptionObject.ToString()); + } + + private void Log(string message) + { + string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + string log = Path.Combine(basePath, "log.txt"); + + logMutex.WaitOne(); + + if (!File.Exists(log)) + { + File.Create(log); } - Player player = PlayerService.GetPlayerByNameOrId(user); - if(player == null) - { - return; - } + string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; - player.TriggerEvent("updateMoney", account.Balance); - } - }; + File.AppendAllText(log, msg); - User.HandMoneyChanged += (user) => + logMutex.ReleaseMutex(); + } + + [RemoteEvent("CLIENT:Event")] + public void OnClientEvent(Player player, string dataStr) { - user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); - }; - - //IPLS - NAPI.World.RequestIpl("vw_casino_garage"); - - } - catch (Exception e) - { - Log(e.ToString()); - } + var data = dataStr.DeserializeJson>(); + eventHandler.HandleEvent(new RagePlayer(player), data); + } } - - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - Log(e.ExceptionObject.ToString()); - } - - private void Log(string message) - { - string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - string log = Path.Combine(basePath, "log.txt"); - - logMutex.WaitOne(); - - if (!File.Exists(log)) - { - File.Create(log); - } - - string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; - - File.AppendAllText(log, msg); - - logMutex.ReleaseMutex(); - } - - [RemoteEvent("CLIENT:Event")] - public void OnClientEvent(Player player, string dataStr) - { - var data = dataStr.DeserializeJson>(); - eventHandler.HandleEvent(new RagePlayer(player), data); - } - } } diff --git a/ReallifeGamemode.Server/Managers/ATMManager.cs b/ReallifeGamemode.Server/Managers/ATMManager.cs index 2fab284c..ec10ddae 100644 --- a/ReallifeGamemode.Server/Managers/ATMManager.cs +++ b/ReallifeGamemode.Server/Managers/ATMManager.cs @@ -2,9 +2,11 @@ using System.Linq; using System.Numerics; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers ATMManager (ATMManager.cs) @@ -18,6 +20,8 @@ namespace ReallifeGamemode.Server.Managers { public static List ATMColShapes = new List(); + private static readonly ILogger logger = LogManager.GetLogger(); + public static void InitATMs() { var addedATMs = 0; @@ -112,15 +116,16 @@ namespace ReallifeGamemode.Server.Managers //client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance); client.SendNotification("~r~Nicht genügend Geld auf der Hand!"); } - else if(inputField1 < 0) + else if (inputField1 < 0) { client.SendNotification("~r~Ungültiger Betrag!"); - } - else + } + else { var updateBankMoneyIn = user.BankAccount; var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); user.Handmoney -= inputField1; + logger.LogInformation("Player {0} did a deposit of {1} dollars at atm {2}", client.Name, inputField1, nearATM); updateBankMoneyIn.Balance += inputField1; updateATMBalanceIn.Balance += inputField1; //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); @@ -149,6 +154,7 @@ namespace ReallifeGamemode.Server.Managers var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); updateHandMoneyOut.Handmoney += inputField1; user.BankAccount.Balance -= inputField1; + logger.LogInformation("Player {0} did a withdraw of {1} dollars at atm {2}", client.Name, inputField1, nearATM); updateATMBalanceOut.Balance -= inputField1; //client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney); } diff --git a/ReallifeGamemode.Server/Managers/CharacterCreator.cs b/ReallifeGamemode.Server/Managers/CharacterCreator.cs index f0c2ee73..4815ec7c 100644 --- a/ReallifeGamemode.Server/Managers/CharacterCreator.cs +++ b/ReallifeGamemode.Server/Managers/CharacterCreator.cs @@ -1,11 +1,13 @@ using System.Linq; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Events; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Managers { @@ -14,6 +16,8 @@ namespace ReallifeGamemode.Server.Managers public static Vector3 surgeryPoint = new Vector3(342.30032, -1397.7542, 32.50923); public const int SURGERY_PRICE = 15000; + private static readonly ILogger logger = LogManager.GetLogger(); + public CharacterCreator() { //LoadSurgery(); @@ -273,6 +277,7 @@ namespace ReallifeGamemode.Server.Managers } else { + logger.LogInformation("Player {0} bought a surgery for {1} dollars", player.Name, SURGERY_PRICE); user.BankAccount.Balance -= SURGERY_PRICE; } saveCharacter.Remove(oldChar); diff --git a/ReallifeGamemode.Server/Managers/CityHallManager.cs b/ReallifeGamemode.Server/Managers/CityHallManager.cs index 428c90de..53259373 100644 --- a/ReallifeGamemode.Server/Managers/CityHallManager.cs +++ b/ReallifeGamemode.Server/Managers/CityHallManager.cs @@ -1,9 +1,11 @@ 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; using ReallifeGamemode.Server.Types; @@ -11,8 +13,11 @@ namespace ReallifeGamemode.Server.Managers { internal class CityHallManager : Script { + private const int GROUP_PRICE = 50000; private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9); + private static readonly ILogger logger = LogManager.GetLogger(); + public static void LoadCityHall() { NAPI.Marker.CreateMarker(GTANetworkAPI.MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255)); @@ -57,13 +62,14 @@ namespace ReallifeGamemode.Server.Managers u.Group = group; u.GroupRank = GroupRank.OWNER; - if (player.GetUser(dbContext).BankAccount.Balance < 50000) + if (u.BankAccount.Balance < GROUP_PRICE) { ChatService.ErrorMessage(player, "Du hast nicht genug Geld"); return; } - player.GetUser(dbContext).BankAccount.Balance -= 50000; + logger.LogInformation("Player {0} created a group for {1} dollars", player.Name, GROUP_PRICE); + u.BankAccount.Balance -= GROUP_PRICE; dbContext.SaveChanges(); ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group); diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 536a9fe9..4d799e80 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -16,6 +16,8 @@ using ReallifeGamemode.Server.Events; using System; using ReallifeGamemode.Server.Core.API; using ReallifeGamemode.Server.Factions.Medic; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) @@ -27,6 +29,8 @@ namespace ReallifeGamemode.Server.Managers { public class InteractionManager : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + #region Eigeninteraktionen Taste-M [RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")] @@ -484,8 +488,8 @@ namespace ReallifeGamemode.Server.Managers using var dbContext = new DatabaseContext(); var user = player.GetUser(dbContext); ServerVehicle serverVehicle = dbContext.ServerVehicles.FirstOrDefault(v => v.Id == id); - - if(serverVehicle is UserVehicle) + + if (serverVehicle is UserVehicle) { UserVehicle userVehicle = dbContext.UserVehicles.Where(v => v.Id == id && v.UserId == user.Id).FirstOrDefault(); var vehPrice = userVehicle.Price; @@ -493,25 +497,29 @@ namespace ReallifeGamemode.Server.Managers GTANetworkAPI.Vehicle veh = VehicleManager.GetVehicleFromServerVehicle(userVehicle); user.BankAccount.Balance += backPrice; - ChatService.SendMessage(player, $"~b~[INFO]~s~ Du hast durch den Autoverkauf ~g~{backPrice.ToMoneyString()} ~s~erhalten."); + logger.LogInformation("Player {0} sold his uservehicle {1} for {2} dollars", player.Name, userVehicle.Model.ToString(), backPrice); + + ChatService.SendMessage(player, $"~b~[INFO]~s~ Du hast durch den Autoverkauf ~g~{backPrice.ToMoneyString()}~s~ erhalten."); VehicleManager.DeleteVehicle(veh); dbContext.UserVehicles.Remove(userVehicle); player.SendNotification("~g~Du hast dein Fahrzeug verkauft"); } - else if(serverVehicle is FactionVehicle) + else if (serverVehicle is FactionVehicle) { FactionVehicle factionVehicle = dbContext.FactionVehicles.FirstOrDefault(v => v.Id == id); var backPrice = (int)(factionVehicle.BuyPrice * 1.5 * 0.4); user.Faction.BankAccount.Balance += backPrice; + logger.LogInformation("Player {0} sold thr factionvehicle {1} of faction {2} for {3} dollars", player.Name, factionVehicle.Model.ToString(), user.Faction.Id, backPrice); + ChatService.SendMessage(player, $"~b~[INFO]~s~ Die Fraktionskasse hat ~g~{backPrice.ToMoneyString()}~s~ erhalten."); VehicleManager.DeleteVehicle(VehicleManager.GetVehicleFromServerVehicle(factionVehicle)); dbContext.FactionVehicles.Remove(factionVehicle); player.SendNotification("~g~Du hast dein Fraktionsfahrzeug verkauft"); - } + } dbContext.SaveChanges(); } @@ -564,13 +572,13 @@ namespace ReallifeGamemode.Server.Managers ChatService.ErrorMessage(player, "Das Fahrzeug konnte nicht verkauft werden. Bitte melde dich bei der Leaderverwaltung"); return; } - + var backPrice = (int)(price.Price * 1.5 * 0.4); player.SetData("SellVehicleDecision", true); player.SetData("VehicleToSell", id); - ChatService.SendMessage(player, "~s~Möchtest du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~" + backPrice.ToMoneyString() + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen."); + ChatService.SendMessage(player, "~s~Möchtest du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~" + backPrice.ToMoneyString() + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen."); } } @@ -733,6 +741,7 @@ namespace ReallifeGamemode.Server.Managers fibBankAccount.Balance += (int)(ticket_amount / 100 * 60); lspdBankAccount.Balance += (int)(ticket_amount / 100 * 40); } + logger.LogInformation("Player {0} accepted a ticket of {1} dollars", player.Name, ticket_amount); dbContext.SaveChanges(); } target.ResetData("ticket_boolean"); @@ -798,6 +807,7 @@ namespace ReallifeGamemode.Server.Managers if (amount > 0 && amount <= 5000) { + logger.LogInformation("Player {0} did a local payment of {1} dollars to player {2}", player.Name, amount, target.Name); player.SendNotification($"~w~Du hast ~y~{targetname} ~w~{amount.ToMoneyString()} gegeben."); target.SendNotification($"~w~ Du hast von ~y~{playername} ~w~{amount.ToMoneyString()} erhalten.", true); diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index ffeb557b..e0dc309d 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -14,6 +14,8 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; using ReallifeGamemode.Server.Types; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs) @@ -25,6 +27,9 @@ namespace ReallifeGamemode.Server.Managers { public class InventoryManager : Script { + private const int MAX_USER_INVENTORY = 40000; + private static readonly ILogger logger = LogManager.GetLogger(); + public static List itemList; private static Dictionary TradeItems { get; set; } = new Dictionary(); @@ -224,7 +229,7 @@ namespace ReallifeGamemode.Server.Managers using (var context = new DatabaseContext()) { - List userItems = context.UserItems.ToList().FindAll(i => i.UserId == user.Id); + List userItems = context.UserItems.Where(i => i.UserId == user.Id).ToList(); foreach (var item in userItems) { IItem iItem = GetItemById(item.ItemId); @@ -381,7 +386,7 @@ namespace ReallifeGamemode.Server.Managers int setAmount = 0; for (int i = 1; i <= amount; i++) { - if (GetUserInventoryWeight(player) + (i * GetItemById(itemId).Gewicht) > 40000) + if (GetUserInventoryWeight(player) + (i * GetItemById(itemId).Gewicht) > MAX_USER_INVENTORY) { break; } @@ -589,7 +594,7 @@ namespace ReallifeGamemode.Server.Managers break; } context.SaveChanges(); - + } } @@ -608,6 +613,14 @@ namespace ReallifeGamemode.Server.Managers return; } + logger.LogInformation("Player {0} bought the item {1} for {2} dollars", client.Name, shopItem.Name, shopItem.Price); + + if (GetUserInventoryWeight(client) + shopItem.Gewicht > MAX_USER_INVENTORY) + { + + return; + } + UserItem item = dbContext.UserItems.Where(i => i.ItemId == shopItem.Id && i.UserId == user.Id).FirstOrDefault(); if (item == null) { diff --git a/ReallifeGamemode.Server/Managers/TuningManager.cs b/ReallifeGamemode.Server/Managers/TuningManager.cs index af39a796..c3834da0 100644 --- a/ReallifeGamemode.Server/Managers/TuningManager.cs +++ b/ReallifeGamemode.Server/Managers/TuningManager.cs @@ -2,14 +2,17 @@ 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.Log; namespace ReallifeGamemode.Server.Managers { internal class TuningManager : Script { + private static readonly ILogger logger = LogManager.GetLogger(); private static List tuningGarages = new List(); public static void LoadTuningGarages() @@ -220,6 +223,7 @@ namespace ReallifeGamemode.Server.Managers ServerVehicle sV = player.Vehicle.GetServerVehicle(dbContext); if (sV == null) return; + logger.LogInformation("Player {0} bought a tuning part for server vehicle {1}, slot: {2}, mod: {3} for {4} dollars", player.Name, sV.Id, slot, index, price); VehicleMod vMod = dbContext.VehicleMods.FirstOrDefault(m => m.ServerVehicleId == sV.Id && m.Slot == slot); if (vMod == null && index != -1) @@ -265,7 +269,7 @@ namespace ReallifeGamemode.Server.Managers veh.SecondaryColor = color; } - using var dbContext = new DatabaseContext(true); + using var dbContext = new DatabaseContext(); ServerVehicle serverVeh = VehicleManager.GetServerVehicleFromVehicle(veh, dbContext); if (serverVeh == null) @@ -311,6 +315,7 @@ namespace ReallifeGamemode.Server.Managers if (serverVehicle != null) { + logger.LogInformation("Player {0} bought wheels for server vehicle {1}, type: {2}, wheels: {3} for {4} dollars", player.Name, serverVehicle.Id, wheelType, wheelIndex, price); VehicleMod typeMod = dbContext.VehicleMods.Where(m => m.ServerVehicleId == serverVehicle.Id && m.Slot == -2).FirstOrDefault(); if (typeMod == null) { diff --git a/ReallifeGamemode.Server/Util/Rentcar.cs b/ReallifeGamemode.Server/Util/Rentcar.cs index ff17b584..b5828f64 100644 --- a/ReallifeGamemode.Server/Util/Rentcar.cs +++ b/ReallifeGamemode.Server/Util/Rentcar.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Text; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; @@ -12,6 +14,7 @@ namespace ReallifeGamemode.Server.Util { class Rentcar : Script { + private static readonly ILogger logger = LogManager.GetLogger(); //In Sekunden public static int PAY_TIMER = 180; @@ -69,6 +72,7 @@ namespace ReallifeGamemode.Server.Util { User user = player.GetUser(dbContext); user.BankAccount.Balance -= mapPlayerRentcarBill[player.Name].Item2; + logger.LogInformation("Player {0} cancelled a rent and payed {1} dollars", player.Name, mapPlayerRentcarBill[player.Name].Item2); dbContext.SaveChanges(); } @@ -105,9 +109,9 @@ namespace ReallifeGamemode.Server.Util { return; } - + player.TriggerEvent("BN_Show", "Fahrzeug seit ~b~" + (int)(time / 60) + "~w~ Minuten gemietet (Gesamtkosten: ~g~$~s~" + bill + ")."); - mapPlayerRentcarBill[player.Name] = (mapPlayerRentcarBill[player.Name].Item1, bill); + mapPlayerRentcarBill[player.Name] = (mapPlayerRentcarBill[player.Name].Item1, bill); } [RemoteEvent("SERVER:rentcarBooked")] From 3c63002c030655d956428978a2f3508385092184 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 00:58:14 +0200 Subject: [PATCH 10/36] =?UTF-8?q?M-Men=C3=BC=20fix=20wenn=20zivilist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 3c2d56f2ad21ac99185f2f2c95ce30b8f1666bec) --- ReallifeGamemode.Server/Events/Key.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 45a00fcf..697b904a 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -171,7 +171,7 @@ namespace ReallifeGamemode.Server.Events isActive = JobBase.GetPlayerInJob().Contains(player), }; - var memberList = dbContext.Users.Where(f => f.FactionId == u.FactionId && u.FactionId != 0).OrderByDescending(f => f.FactionRank.Order).ThenBy(f => f.Name).Select(m => new + var memberList = dbContext.Users.Where(f => f.FactionId == u.FactionId && u.FactionId != null && u.FactionId != 0).OrderByDescending(f => f.FactionRank.Order).ThenBy(f => f.Name).Select(m => new { username = m.Name, factionRank = m.FactionRank.Order, From 7411fa02f374349b82ed53ebab624130b133e670 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 03:14:37 +0200 Subject: [PATCH 11/36] GELD LOGS (cherry picked from commit a2db770316a6f76a660ba20825773675f3109f81) --- .../Managers/HouseManager.cs | 3 + .../Menus/PoliceDepartment.cs | 9 +- ReallifeGamemode.Server/Bank/bank.cs | 70 ++-- .../Commands/AdminCommands.cs | 4 + .../Commands/FactionCommands.cs | 14 +- .../Commands/UserCommands.cs | 12 +- .../DrivingSchool/DrivingSchool.cs | 81 ++-- .../DrivingSchool/PlaneSchool.cs | 13 +- .../Events/UpdateCharacterCloth.cs | 12 +- ReallifeGamemode.Server/Events/Weapon.cs | 2 +- .../Extensions/ClientExtension.cs | 6 + .../Factions/Medic/Medic.cs | 34 +- ReallifeGamemode.Server/Finance/Economy.cs | 9 +- ReallifeGamemode.Server/Gangwar/Turf.cs | 10 +- ReallifeGamemode.Server/Main.cs | 390 +++++++++--------- .../Managers/ATMManager.cs | 12 +- .../Managers/CharacterCreator.cs | 5 + .../Managers/CityHallManager.cs | 10 +- .../Managers/InteractionManager.cs | 24 +- .../Managers/InventoryManager.cs | 19 +- .../Managers/TuningManager.cs | 7 +- ReallifeGamemode.Server/Util/Rentcar.cs | 8 +- 22 files changed, 448 insertions(+), 306 deletions(-) diff --git a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs index aaf43688..0ccca564 100644 --- a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs +++ b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs @@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Core.Extensions; using System.Linq; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Common; +using Microsoft.Extensions.Logging; namespace ReallifeGamemode.Server.Core.Managers { @@ -451,6 +452,8 @@ namespace ReallifeGamemode.Server.Core.Managers return; } + Log.LogInformation("Player {0} did a withdraw of {1} dollars from house {2}", player.Name, amount, house.Id); + user.BankAccount.Balance += amount; house.BankAccount.Balance -= amount; diff --git a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs index f4e9c3ef..67021b46 100644 --- a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs +++ b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs @@ -6,12 +6,13 @@ using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Core.Extensions; using Microsoft.EntityFrameworkCore; using System.Linq; +using Microsoft.Extensions.Logging; namespace ReallifeGamemode.Server.Core.Menus { internal class PoliceDepartment : Script { - + private const int WEAPONLICENSE_PRICE = 5000; public PoliceDepartment() { @@ -40,13 +41,15 @@ namespace ReallifeGamemode.Server.Core.Menus var account = user.BankAccount; - if (account.Balance < 5000) + if (account.Balance < WEAPONLICENSE_PRICE) { player.SendMessage("Du hast nicht genug Geld auf der Bank (5.000$)!", ChatPrefix.Error); return; } - account.Balance -= 5000; + Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name); + + account.Balance -= WEAPONLICENSE_PRICE; player.SendMessage("Du hast den Waffenschein erfolgreich erworben.", ChatPrefix.Info); diff --git a/ReallifeGamemode.Server/Bank/bank.cs b/ReallifeGamemode.Server/Bank/bank.cs index a17e81c6..b074d0a9 100644 --- a/ReallifeGamemode.Server/Bank/bank.cs +++ b/ReallifeGamemode.Server/Bank/bank.cs @@ -4,18 +4,20 @@ * @copyright (c) 2008 - 2021 Life of German */ using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Finance; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Services; using System; namespace ReallifeGamemode.Server.Bank { - class bank : Script + class Bank : Script { private static TextLabel informationLabel; private static TextLabel factionInformationLabel; @@ -25,6 +27,7 @@ namespace ReallifeGamemode.Server.Bank private static ColShape _factioncolShape; public static Vector3 Position { get; } + private static readonly ILogger logger = LogManager.GetLogger(); public static void Setup() { @@ -58,7 +61,7 @@ namespace ReallifeGamemode.Server.Bank } private static void EntityEnterFactionBankColShape(ColShape colShape, Player client) - { + { if (client.IsInVehicle || !client.IsLoggedIn() || client.GetUser().FactionId is null) return; User user = client.GetUser(); @@ -92,6 +95,7 @@ namespace ReallifeGamemode.Server.Bank } else { + logger.LogInformation("Player {0} did a deposit of {1} dollars at the bank", player.Name, amount); player.SendNotification($"~w~Du hast $~g~{amount} ~w~eingezahlt."); player.GetUser(dbContext).Handmoney -= amount; player.GetUser(dbContext).BankAccount.Balance += amount; @@ -115,6 +119,7 @@ namespace ReallifeGamemode.Server.Bank } else { + logger.LogInformation("Player {0} did a withdraw of {1} dollars at the bank", player.Name, amount); player.SendNotification($"~w~Du hast $~g~{amount} ~w~abgehoben."); player.GetUser(dbContext).Handmoney += amount; player.GetUser(dbContext).BankAccount.Balance -= amount; @@ -130,34 +135,40 @@ namespace ReallifeGamemode.Server.Bank int amount = Int32.Parse(stringAmount); Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (!target.IsLoggedIn()) + { + player.SendNotification($"~r~Dieser Spieler ist nicht Online."); + return; + } + using (var dbContext = new DatabaseContext()) { - if (player.GetUser().PlayedMinutes < 180) + User user = player.GetUser(dbContext); + if (user.PlayedMinutes < 180) { player.SendNotification("~r~Du kannst Geld erst ab 3 Spielstunden vergeben"); return; } - if (player.GetUser(dbContext) == target.GetUser(dbContext)) + + User targetUser = target.GetUser(dbContext); + + if (user == targetUser) { player.SendNotification($"~r~Du kannst dir selber kein Geld überweisen."); return; } - else if (!target.IsLoggedIn()) - { - player.SendNotification($"~r~Dieser Spieler ist nicht Online."); - - } - else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).BankAccount.Balance) + else if (amount <= 0 || (int)(amount * 1.05) > user.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); return; } else { + logger.LogInformation("Player {0} did a transfer of {1} dollars to {2}", user.Name, amount, targetUser.Name); player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen."); target.SendNotification($"~w~{player.Name} hat dir $~g~{amount} ~w~Überwiesen."); - player.GetUser(dbContext).BankAccount.Balance -= (int)(amount * 1.05); - target.GetUser(dbContext).otheramount += amount; + user.BankAccount.Balance -= (int)(amount * 1.05); + targetUser.otheramount += amount; dbContext.SaveChanges(); } } @@ -170,17 +181,23 @@ namespace ReallifeGamemode.Server.Bank using (var dbContext = new DatabaseContext()) { + User user = player.GetUser(dbContext); + if (user.FactionId == null) + { + return; + } - if (amount <= 0 || amount > player.GetUser(dbContext).BankAccount.Balance) + if (amount <= 0 || amount > user.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag ist ungültig."); return; } else { + logger.LogInformation("Player {0} did a faction payin of {1} dollars to faction {2}", user.Name, amount, user.Faction.Id); player.SendNotification($"~w~Du hast $~g~{amount}~w~ in die Fraktionskasse eingezahlt."); - player.GetUser(dbContext).BankAccount.Balance -= amount; - player.GetUser(dbContext).Faction.BankAccount.Balance += amount; + user.BankAccount.Balance -= amount; + user.Faction.BankAccount.Balance += amount; dbContext.SaveChanges(); } } @@ -193,23 +210,28 @@ namespace ReallifeGamemode.Server.Bank int amount = Int32.Parse(stringAmount); Player target = PlayerService.GetPlayerByNameOrId(nameOrId); + if (!target.IsLoggedIn()) + { + player.SendNotification($"~r~Dieser Spieler ist nicht Online."); + return; + } + using (var dbContext = new DatabaseContext()) { - if (!target.IsLoggedIn()) - { - player.SendNotification($"~r~Dieser Spieler ist nicht Online."); - - } - else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).Faction.BankAccount.Balance) + User user = player.GetUser(dbContext); + User targetUser = target.GetUser(dbContext); + if (amount <= 0 || (int)(amount * 1.05) > user.Faction.BankAccount.Balance) { player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); return; } else { - player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen."); - player.GetUser(dbContext).Faction.BankAccount.Balance -= (int)(amount * 1.05); - target.GetUser(dbContext).otheramount += amount; + logger.LogInformation("Player {0} did a faction transfer of {1} dollars from faction {2} to {3}", user.Name, amount, user.Faction.Id, target); + player.SendNotification($"Du hast ~g~{amount.ToMoneyString()}~s~ an ~y~{targetUser.Name}~s~ überwiesen"); + target.SendNotification($"Dir wurden ~g~{amount.ToMoneyString()}~s~ von ~y~{user.Name}~s~ überwiesen"); + user.Faction.BankAccount.Balance -= (int)(amount * 1.05); + targetUser.otheramount += amount; dbContext.SaveChanges(); } } diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 916f4293..15d1d9d0 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -2287,6 +2287,7 @@ namespace ReallifeGamemode.Server.Commands { var user = target.GetUser(context); user.Handmoney = amount; + logger.LogInformation("Admin {0} set the handmoney of player {1} to {2} dollars", admin.Name, target.Name, amount); context.SaveChanges(); //target.TriggerEvent("SERVER:SET_HANDMONEY", amount); } @@ -2313,6 +2314,7 @@ namespace ReallifeGamemode.Server.Commands { var user = target.GetUser(context); user.Handmoney += amount; + logger.LogInformation("Admin {0} added {2} dollarsto the handmoney of player {1}", admin.Name, target.Name, amount); context.SaveChanges(); //target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); } @@ -3356,6 +3358,7 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { + logger.LogInformation("Admin {0} set the bank account of {1} to {2} dollars", player.Name, target.Name, amount); target.GetUser(dbContext).BankAccount.Balance = amount; dbContext.SaveChanges(); } @@ -3381,6 +3384,7 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { + logger.LogInformation("Admin {0} added {2} dollars to the bank account of {1}", player.Name, target.Name, amount); target.GetUser(dbContext).BankAccount.Balance += amount; dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 9d90d3a2..7dd4e5b7 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities.Logs.Chat; using ReallifeGamemode.Database.Models; @@ -15,6 +16,7 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Faction Commands (Faction.cs) @@ -26,6 +28,8 @@ namespace ReallifeGamemode.Server.Commands { internal class FactionCommands : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + #region Chat Commands [Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)] @@ -413,17 +417,19 @@ namespace ReallifeGamemode.Server.Commands return; } - if (deadPlayerUser.Handmoney >= 100) + if (deadPlayerUser.Handmoney >= Medic.ReviveIncome) { - deadPlayerUser.Handmoney -= 100; + deadPlayerUser.Handmoney -= Medic.ReviveIncome; } else { - int bankMoney = 100 - deadPlayerUser.Handmoney; + int bankMoney = Medic.ReviveIncome - deadPlayerUser.Handmoney; deadPlayerUser.Handmoney = 0; deadPlayerUser.BankAccount.Balance -= bankMoney; } + logger.LogInformation("Player {0} has been revived by {1} for {2} dollars", deadPlayer.Name, player.Name, Medic.ReviveIncome); + player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0); deadPlayer.TriggerEvent("onPlayerRevived"); diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 2ed40def..ec9dfcd2 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; @@ -13,11 +14,16 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Commands { internal class UserCommands : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + + private const int SMS_PRICE = 5; + [Command("rent", "~m~rent stop")] public void CmdUserStopRent(Player player, String option = "") { @@ -113,13 +119,15 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { User user = player.GetUser(dbContext); - if (user.BankAccount.Balance < 5) + if (user.BankAccount.Balance < SMS_PRICE) { ChatService.ErrorMessage(player, "Dafür hast du nicht genug Geld auf deinem Bankkonto"); return; } - user.BankAccount.Balance -= 5; + logger.LogInformation("Player {0} sent a sms to {1} for {2} dollars", player.Name, target.Name, SMS_PRICE); + + user.BankAccount.Balance -= SMS_PRICE; dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs index 590bbf7e..3f333409 100644 --- a/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs +++ b/ReallifeGamemode.Server/DrivingSchool/DrivingSchool.cs @@ -6,17 +6,24 @@ using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; using System; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.DrivingSchool { internal class DrivingSchool : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + private static TextLabel informationLabel; private static Marker marker; private static ColShape _colShape; public static Vector3 Position { get; } private const int FAILPOINTS = 2; + private const int CAR_LICENSE_PRICE = 2500; + private const int BIKE_LICENSE_PRICE = 3500; + private readonly IReadOnlyCollection BikeRoute = new List { new Vector3(-741.98, -1283.46, 6.17), @@ -122,14 +129,14 @@ namespace ReallifeGamemode.Server.DrivingSchool public void StartDrivingSchool(Player client) { User user = client.GetUser(); - + if (user.DriverLicenseVehicle || client.HasData("ActiveSchool")) { client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Führerschein."); return; } - - if (user.Handmoney < 2500) + + if (user.Handmoney < CAR_LICENSE_PRICE) { client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($2.500)!", true); return; @@ -138,7 +145,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 2500; + payer.Handmoney -= CAR_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the driving school (car) for {1} dollars", client.Name, CAR_LICENSE_PRICE); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } @@ -174,8 +182,8 @@ namespace ReallifeGamemode.Server.DrivingSchool [RemoteEvent("drivingSchoolEventEnd")] public void DrivingSchoolEventEnd(Player user, int checkpoint) { - using (var dbContext = new DatabaseContext()) - { + using (var dbContext = new DatabaseContext()) + { User drivingUser = user.GetUser(dbContext); if (drivingUser.failpoints > FAILPOINTS) @@ -186,13 +194,13 @@ namespace ReallifeGamemode.Server.DrivingSchool else { user.TriggerEvent("renderTextOnScreen", "Du hast den Führerschein bestanden. Glückwunsch!"); - user.ResetData("ActiveSchool"); + user.ResetData("ActiveSchool"); drivingUser.DriverLicenseVehicle = true; drivingUser.failpoints = 0; dbContext.SaveChanges(); } - - } + + } Vehicle veh = user.Vehicle; user.WarpOutOfVehicle(); ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh); @@ -208,31 +216,31 @@ namespace ReallifeGamemode.Server.DrivingSchool [RemoteEvent("drivingSchoolEvent")] public void DrivingSchoolEvent(Player user, int checkpoint) { - /* for (int i = 0; i >= 33; i++) - { - if (checkpoint <= 24) - { - user.TriggerEvent("kmh100"); - } - else if (checkpoint >= 25 && checkpoint <= 26) - { - user.TriggerEvent("kmh150"); - } - else if (checkpoint >= 26 && checkpoint <= 28) - { - user.TriggerEvent("kmh100"); - } - else if (checkpoint >= 29 && checkpoint <= 31) - { - user.TriggerEvent("kmh150"); - } - else if (checkpoint >= 32 && checkpoint <= 33) - { - user.TriggerEvent("kmh100"); - } - } - */ - switch(checkpoint) + /* for (int i = 0; i >= 33; i++) + { + if (checkpoint <= 24) + { + user.TriggerEvent("kmh100"); + } + else if (checkpoint >= 25 && checkpoint <= 26) + { + user.TriggerEvent("kmh150"); + } + else if (checkpoint >= 26 && checkpoint <= 28) + { + user.TriggerEvent("kmh100"); + } + else if (checkpoint >= 29 && checkpoint <= 31) + { + user.TriggerEvent("kmh150"); + } + else if (checkpoint >= 32 && checkpoint <= 33) + { + user.TriggerEvent("kmh100"); + } + } + */ + switch (checkpoint) { case 25: case 26: @@ -275,7 +283,7 @@ namespace ReallifeGamemode.Server.DrivingSchool client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Motorradschein."); return; } - if (user.Handmoney < 3500) + if (user.Handmoney < BIKE_LICENSE_PRICE) { client.SendNotification("~r~[FEHLER]~s~Du hast nicht genug Geld auf der Hand($3.500)!", true); return; @@ -284,7 +292,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 3500; + payer.Handmoney -= BIKE_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the driving school (bike) for {1} dollars", client.Name, BIKE_LICENSE_PRICE); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs b/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs index 310860ec..94873705 100644 --- a/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs +++ b/ReallifeGamemode.Server/DrivingSchool/PlaneSchool.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; @@ -15,8 +17,12 @@ namespace ReallifeGamemode.Server.DrivingSchool private static ColShape _colShape1; public static Vector3 Position { get; } + private static readonly ILogger logger = LogManager.GetLogger(); + private const int CHECKPOINT_MARKER_ID = 6; + private const int PLANE_LICENSE_PRICE = 5000; + private readonly IReadOnlyCollection planeRoute = new List { new Vector3(-1114.39, -2333.09, 14.87), @@ -74,7 +80,7 @@ namespace ReallifeGamemode.Server.DrivingSchool client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Flugschein."); return; } - if (user.Handmoney < 5000) + if (user.Handmoney < PLANE_LICENSE_PRICE) { client.SendNotification("~r~Du brauchst ~g~$5.000~r~ auf der Hand, um die Prüfung starten zu können.", true); return; @@ -82,7 +88,8 @@ namespace ReallifeGamemode.Server.DrivingSchool using (var dbContext = new DatabaseContext()) { User payer = client.GetUser(dbContext); - payer.Handmoney -= 5000; + payer.Handmoney -= PLANE_LICENSE_PRICE; + logger.LogInformation("Player {0} bought the plane school for {1} dollars", client.Name, PLANE_LICENSE_PRICE); //client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } @@ -171,7 +178,7 @@ namespace ReallifeGamemode.Server.DrivingSchool case 14: user.TriggerEvent("renderTextOnScreen", "Setzen Sie zum Landeanflug an. Drücken Sie 'G', um das Fahrwerk auszufahren."); - CheckPointHandle.StartCheckPointRoute(user, planeRouteEnd, 5000, CHECKPOINT_MARKER_ID, 12, 5, true, "planeSchoolEventEnd"); + CheckPointHandle.StartCheckPointRoute(user, planeRouteEnd, PLANE_LICENSE_PRICE, CHECKPOINT_MARKER_ID, 12, 5, true, "planeSchoolEventEnd"); break; } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index ea2d67d6..086ec118 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -6,11 +6,15 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using System; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Events { public class UpdateCharacterCloth : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + [RemoteEvent("updateDutyProp")] public void UpdateDutyProp(Player player, int componentId, int componentVariation) { @@ -280,7 +284,8 @@ namespace ReallifeGamemode.Server.Events } } - if(data[0] == 2){ + if (data[0] == 2) + { User payer = client.GetUser(dbContext); payer.GetCharacter(dbContext); payer.Character.Hair = Convert.ToByte(data[2]); @@ -288,13 +293,14 @@ namespace ReallifeGamemode.Server.Events } client.GetUser(dbContext).Handmoney -= data[6]; + logger.LogInformation("Player {0} bought clothing for {1} dollars: slot = {2}, cloth = {3}, texture = {4}", client.Name, data[6], data[0], data[2], data[1]); dbContext.SaveChanges(); //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); } client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); } } - + [RemoteEvent("SERVER:BuyHairColor")] public void BuyHairColor(Player client, byte HairColor) @@ -332,7 +338,7 @@ namespace ReallifeGamemode.Server.Events User payer = client.GetUser(dbContext); payer.GetCharacter(dbContext); payer.Handmoney -= 50; - payer.Character.HairHighlightColor = HairlightColor; + payer.Character.HairHighlightColor = HairlightColor; // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); dbContext.SaveChanges(); } diff --git a/ReallifeGamemode.Server/Events/Weapon.cs b/ReallifeGamemode.Server/Events/Weapon.cs index c32f22c0..34d7661d 100644 --- a/ReallifeGamemode.Server/Events/Weapon.cs +++ b/ReallifeGamemode.Server/Events/Weapon.cs @@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server.Events player.SendNotification("Du hast nicht genügend Geld bei dir"); return; } - logger.LogInformation("Player {0} bought a {1} in ammunation", user.Name, weaponmodel); + logger.LogInformation("Player {0} bought a weapon {1} in ammunation for {2} dollars", user.Name, weaponmodel, price); user.Handmoney -= price; dbContext.SaveChanges(); player.GiveWeapon(NAPI.Util.WeaponNameToModel(weaponmodel), ammo); diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index dcd4d284..2b57264b 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Admin; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; @@ -22,6 +24,8 @@ namespace ReallifeGamemode.Server.Extensions { public static class PlayerExtension { + private static ILogger Logger => LogManager.GetLogger(typeof(PlayerExtension)); + /// /// Gibt das User-Objekt eines Player's zurück. /// Gibt nichts zurück, wenn der Player nicht eingeloggt ist @@ -108,6 +112,8 @@ namespace ReallifeGamemode.Server.Extensions faction.BankAccount.Balance += factionMoney; } + Logger.LogInformation("Player {0} was sent to jail for {1} seconds, executive factions got {2} dollars each", user.Name, time, factionMoney); + user.Wanteds = 0; user.JailTime = time; } diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 1bc98dcd..58847dcf 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -9,6 +9,8 @@ using ReallifeGamemode.Database.Models; using Microsoft.EntityFrameworkCore; using System; using ReallifeGamemode.Server.Extensions; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Server Factions Medic Medic.cs @@ -20,6 +22,8 @@ namespace ReallifeGamemode.Server.Factions.Medic { public class Medic : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + public static List ReviveTasks = new List(); public static List HealTasks = new List(); public static List FireTasks = new List(); @@ -34,7 +38,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public Player dTarget; public int dPrice; } - + public static void AddTaskToList(MedicTask task) { if (task == null) @@ -84,7 +88,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void UpdateReviveSperre() { var allRevivedPlayers = NAPI.Pools.GetAllPlayers().Where(c => c.HasData("reviveSperre")); - foreach(var player in allRevivedPlayers) + foreach (var player in allRevivedPlayers) { var timeLeft = player.GetData("reviveSperre"); @@ -101,7 +105,7 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void CheckHealDecisionDistance() { - foreach(var healAuftrag in HealDecisions.ToList()) + foreach (var healAuftrag in HealDecisions.ToList()) { if (healAuftrag.dMedic.Position.DistanceTo(healAuftrag.dTarget.Position) > 5) { @@ -117,9 +121,9 @@ namespace ReallifeGamemode.Server.Factions.Medic public static void MakeHealDecision(Player target, bool decision) { var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target); - if(decision == false) + if (decision == false) { - activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt",false); + activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt", false); activeDecision.dTarget.SendNotification("Du hast den Heal ~r~abgelehnt", false); } else @@ -141,6 +145,8 @@ namespace ReallifeGamemode.Server.Factions.Medic targetUser.BankAccount.Balance -= bankMoney; } + logger.LogInformation("Player {0} accepted a heal for {1} dollars from medic {2}", target.Name, activeDecision.dPrice, activeDecision.dMedic.Name); + dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += activeDecision.dPrice / 2; activeDecision.dMedic.GetUser(dbContext).Wage += activeDecision.dPrice / 2; @@ -149,7 +155,7 @@ namespace ReallifeGamemode.Server.Factions.Medic activeDecision.dTarget.SafeSetHealth(100); activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false); activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false); - delHealTask(activeDecision.dTarget); + delHealTask(activeDecision.dTarget); } HealDecisions.Remove(activeDecision); } @@ -166,7 +172,7 @@ namespace ReallifeGamemode.Server.Factions.Medic var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime)); task.TimeLeft = taskTimeLeft; var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); - if(medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft); + if (medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft); } } } @@ -176,14 +182,14 @@ namespace ReallifeGamemode.Server.Factions.Medic { if (HealTasks.Count != 0) { - foreach(var task in HealTasks) + foreach (var task in HealTasks) { - if(task.MedicName != "none") + if (task.MedicName != "none") { var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); var victim = PlayerService.GetPlayerByNameOrId(task.Victim); - if(medic == null || victim == null) + if (medic == null || victim == null) { continue; } @@ -241,11 +247,11 @@ namespace ReallifeGamemode.Server.Factions.Medic { reviveTask.MedicName = "none"; } - else + else { reviveTask.MedicName = player.Name; } - + ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Reviveauftrag von " + victim + " angenommen.", new List() { 2 }); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ eilt zur Rettung."); break; @@ -261,7 +267,7 @@ namespace ReallifeGamemode.Server.Factions.Medic healTask.MedicName = player.Name; ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Healauftrag von " + victim + " angenommen.", new List() { 2 }); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ hat deinen Auftrag angenommen."); - } + } break; case 2: @@ -275,7 +281,7 @@ namespace ReallifeGamemode.Server.Factions.Medic { MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name); if (task != null) - { + { player.SetData("healauftrag", false); var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName); if (medicPlayer != null) diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index f602fb3a..65fa002f 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -9,9 +9,11 @@ using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Wanted; @@ -19,6 +21,8 @@ namespace ReallifeGamemode.Server.Finance { public class Economy { + private static readonly ILogger logger = LogManager.GetLogger(); + public static Dictionary Paychecks { get; set; } = new Dictionary(); public static (int, float, float) GetEconomyClass(Player client, int wage) @@ -162,6 +166,8 @@ namespace ReallifeGamemode.Server.Finance } } + logger.LogInformation("Player {0} has a payday of {1} dollars. old balance: {2}, new balance: {3}", client.Name, paycheck.Amount, u.BankAccount.Balance, u.BankAccount.Balance + paycheck.Amount); + u.BankAccount.Balance += paycheck.Amount; u.Wage = 0; u.otheramount = 0; @@ -173,7 +179,7 @@ namespace ReallifeGamemode.Server.Finance .Where(hR => hR.UserId == u.Id); dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1); - + logger.LogInformation("Medic faction got a health insurance payment of {0} dollars from player {1}", paycheck.HealthInsurance * 0.1, client.Name); if (rentals.Any()) { foreach (var rental in rentals) @@ -181,6 +187,7 @@ namespace ReallifeGamemode.Server.Finance if (rental?.House?.BankAccount != null) { rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); + logger.LogInformation("House {0} got a rentalfee of {1} from paycheck from user {2}", rental.House.Id, rental.House.RentalFee * 0.7, u.Name); } } } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 3cd1d52b..88573919 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -5,16 +5,20 @@ using System.Threading.Tasks; using System.Timers; using GTANetworkAPI; using Microsoft.EntityFrameworkCore; +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 Turf { + private static readonly ILogger logger = LogManager.GetLogger(); + public int TurfID { get; set; } public string TurfName { get; set; } public int Color { get; set; } @@ -203,7 +207,7 @@ namespace ReallifeGamemode.Server.Gangwar public void enter(Player client) { User user = client.GetUser(); - if(user == null || user.FactionId == null) + if (user == null || user.FactionId == null) { return; } @@ -276,6 +280,7 @@ namespace ReallifeGamemode.Server.Gangwar a.TriggerEvent("CLIENT:loose"); } ownerFaction.BankAccount.Balance += 15000; + logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getAttacker(), 15000); } else if (getOwner() != FactionName) { @@ -292,6 +297,7 @@ namespace ReallifeGamemode.Server.Gangwar if (a != null) a.TriggerEvent("CLIENT:win"); } + logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getOwner(), 10000); this.Owner = FactionName; attackerFaction.BankAccount.Balance += 10000; Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); @@ -379,7 +385,7 @@ namespace ReallifeGamemode.Server.Gangwar { if (getOwner() == FactionName) { - NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); + NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); Att_Score += 1; } else if (getAttacker() == FactionName) diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index 28e226d3..c50c6ce4 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -29,212 +29,212 @@ using System.IO; namespace ReallifeGamemode.Server { - public class Main : Script - { - public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); - public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; - - public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); - - private Core.Events.EventHandler eventHandler; - - private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); - - public Main() + public class Main : Script { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - } + public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); + public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; - [ServerEvent(Event.ResourceStart)] - public void OnResourceStart() - { - try - { - if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") + public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); + + private Core.Events.EventHandler eventHandler; + + private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); + + public Main() { - using var dbContext = new DatabaseContext(true); - - var pendingMigrations = dbContext.Database.GetPendingMigrations(); - - if (!pendingMigrations.Any()) - { - System.Console.WriteLine("No migrations to apply"); - } - else - { - System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); - foreach (var migration in pendingMigrations) - { - System.Console.WriteLine("\t{0}", migration); - } - - try - { - dbContext.Database.Migrate(); - } - catch (System.Exception e) - { - System.Console.WriteLine("Error while updating database: {0}", e.ToString()); - System.Console.ReadLine(); - System.Environment.Exit(1); - } - - System.Console.WriteLine("Migrations successfull"); - } + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; } - var methods = Assembly.GetExecutingAssembly() - .GetTypes() - .SelectMany(t => t.GetMethods()) - .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) - .ToArray(); - - var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); - - var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); - cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() { - registeredCommands.AddRange(a.Alias.Split(',')); - }); - - IAPI apiInstance = new RageAPI(); - eventHandler = new Core.Events.EventHandler(apiInstance); - - new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); - - NAPI.Server.SetGlobalServerChat(false); - - NAPI.Server.SetCommandErrorMessage(""); - NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); - NAPI.Server.SetAutoSpawnOnConnect(false); - NAPI.Server.SetAutoRespawnAfterDeath(false); - NAPI.Data.SetWorldData("playerCreatorDimension", 0); - - JsonConvert.DefaultSettings = () => - { - return new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }; - }; - - InventoryManager.LoadItems(); - ShopManager.LoadClotheShops(); - ShopManager.LoadItemShops(); - ShopManager.LoadFriseur(); - ShopManager.LoadAmmunations(); - TuningManager.LoadTuningGarages(); - - TimeManager.StartTimeManager(); - VehicleManager.CheckEnabledMods(); - - DatabaseHelper.InitDatabaseFirstTime(); - - FactionHelper.CheckFactionBankAccounts(); - BusinessManager.LoadBusinesses(); - //InteriorManager.LoadInteriors(); - DoorManager.LoadDoors(); - ATMManager.InitATMs(); - CityHallManager.LoadCityHall(); - JobManager.LoadJobs(); - //TaxiDriverJob.StartTaxiTimer(); Obselete - //HouseManager.LoadHouses(); - DrivingSchool.DrivingSchool.Setup(); - PlaneSchool.Setup(); - Gangwar.Gangwar.loadTurfs(); - Bank.bank.Setup(); - Introduction.Setup(); - PositionManager.LoadPositionManager(); - LoadManager.LoadLoadManager(); - Rentcar.Setup(); - - World.WeatherSync.Load(); - - TempBlip tempBlip = new TempBlip() - { - Color = 1, - Name = "", - Transparency = 0, - ShortRange = true, - Sprite = 1, - Scale = 1, - }; - - NAPI.Data.SetWorldData("blipTemplate", tempBlip); - - //WantedEscapeTimer.WantedTimer(); Obselete - //Jail.JailTimer(); Obselete - //Economy.PaydayTimer(); Obselete - // WeaponDealManager.WeaponDealTimer(); Obselete - - ThreadTimers.StartAllTimers(); - - Managers.SVarManager.LoadSVars(); - - UserBankAccount.BalanceChanged += (account) => - { - using (var dbContext = new DatabaseContext()) - { - var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); - if (user == null) + try { - return; + if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") + { + using var dbContext = new DatabaseContext(true); + + var pendingMigrations = dbContext.Database.GetPendingMigrations(); + + if (!pendingMigrations.Any()) + { + System.Console.WriteLine("No migrations to apply"); + } + else + { + System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); + foreach (var migration in pendingMigrations) + { + System.Console.WriteLine("\t{0}", migration); + } + + try + { + dbContext.Database.Migrate(); + } + catch (System.Exception e) + { + System.Console.WriteLine("Error while updating database: {0}", e.ToString()); + System.Console.ReadLine(); + System.Environment.Exit(1); + } + + System.Console.WriteLine("Migrations successfull"); + } + } + + var methods = Assembly.GetExecutingAssembly() + .GetTypes() + .SelectMany(t => t.GetMethods()) + .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) + .ToArray(); + + var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); + + var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); + cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => + { + registeredCommands.AddRange(a.Alias.Split(',')); + }); + + IAPI apiInstance = new RageAPI(); + eventHandler = new Core.Events.EventHandler(apiInstance); + + new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); + + NAPI.Server.SetGlobalServerChat(false); + + NAPI.Server.SetCommandErrorMessage(""); + NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); + NAPI.Server.SetAutoSpawnOnConnect(false); + NAPI.Server.SetAutoRespawnAfterDeath(false); + NAPI.Data.SetWorldData("playerCreatorDimension", 0); + + JsonConvert.DefaultSettings = () => + { + return new JsonSerializerSettings() + { + NullValueHandling = NullValueHandling.Ignore + }; + }; + + InventoryManager.LoadItems(); + ShopManager.LoadClotheShops(); + ShopManager.LoadItemShops(); + ShopManager.LoadFriseur(); + ShopManager.LoadAmmunations(); + TuningManager.LoadTuningGarages(); + + TimeManager.StartTimeManager(); + VehicleManager.CheckEnabledMods(); + + DatabaseHelper.InitDatabaseFirstTime(); + + FactionHelper.CheckFactionBankAccounts(); + BusinessManager.LoadBusinesses(); + //InteriorManager.LoadInteriors(); + DoorManager.LoadDoors(); + ATMManager.InitATMs(); + CityHallManager.LoadCityHall(); + JobManager.LoadJobs(); + //TaxiDriverJob.StartTaxiTimer(); Obselete + //HouseManager.LoadHouses(); + DrivingSchool.DrivingSchool.Setup(); + PlaneSchool.Setup(); + Gangwar.Gangwar.loadTurfs(); + Bank.Bank.Setup(); + Introduction.Setup(); + PositionManager.LoadPositionManager(); + LoadManager.LoadLoadManager(); + Rentcar.Setup(); + + World.WeatherSync.Load(); + + TempBlip tempBlip = new TempBlip() + { + Color = 1, + Name = "", + Transparency = 0, + ShortRange = true, + Sprite = 1, + Scale = 1, + }; + + NAPI.Data.SetWorldData("blipTemplate", tempBlip); + + //WantedEscapeTimer.WantedTimer(); Obselete + //Jail.JailTimer(); Obselete + //Economy.PaydayTimer(); Obselete + // WeaponDealManager.WeaponDealTimer(); Obselete + + ThreadTimers.StartAllTimers(); + + Managers.SVarManager.LoadSVars(); + + UserBankAccount.BalanceChanged += (account) => + { + using (var dbContext = new DatabaseContext()) + { + var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); + if (user == null) + { + return; + } + + Player player = PlayerService.GetPlayerByNameOrId(user); + if (player == null) + { + return; + } + + player.TriggerEvent("updateMoney", account.Balance); + } + }; + + User.HandMoneyChanged += (user) => + { + user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + }; + + //IPLS + NAPI.World.RequestIpl("vw_casino_garage"); + + } + catch (Exception e) + { + Log(e.ToString()); + } + } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Log(e.ExceptionObject.ToString()); + } + + private void Log(string message) + { + string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + string log = Path.Combine(basePath, "log.txt"); + + logMutex.WaitOne(); + + if (!File.Exists(log)) + { + File.Create(log); } - Player player = PlayerService.GetPlayerByNameOrId(user); - if(player == null) - { - return; - } + string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; - player.TriggerEvent("updateMoney", account.Balance); - } - }; + File.AppendAllText(log, msg); - User.HandMoneyChanged += (user) => + logMutex.ReleaseMutex(); + } + + [RemoteEvent("CLIENT:Event")] + public void OnClientEvent(Player player, string dataStr) { - user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); - }; - - //IPLS - NAPI.World.RequestIpl("vw_casino_garage"); - - } - catch (Exception e) - { - Log(e.ToString()); - } + var data = dataStr.DeserializeJson>(); + eventHandler.HandleEvent(new RagePlayer(player), data); + } } - - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - Log(e.ExceptionObject.ToString()); - } - - private void Log(string message) - { - string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - string log = Path.Combine(basePath, "log.txt"); - - logMutex.WaitOne(); - - if (!File.Exists(log)) - { - File.Create(log); - } - - string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; - - File.AppendAllText(log, msg); - - logMutex.ReleaseMutex(); - } - - [RemoteEvent("CLIENT:Event")] - public void OnClientEvent(Player player, string dataStr) - { - var data = dataStr.DeserializeJson>(); - eventHandler.HandleEvent(new RagePlayer(player), data); - } - } } diff --git a/ReallifeGamemode.Server/Managers/ATMManager.cs b/ReallifeGamemode.Server/Managers/ATMManager.cs index 2fab284c..ec10ddae 100644 --- a/ReallifeGamemode.Server/Managers/ATMManager.cs +++ b/ReallifeGamemode.Server/Managers/ATMManager.cs @@ -2,9 +2,11 @@ using System.Linq; using System.Numerics; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers ATMManager (ATMManager.cs) @@ -18,6 +20,8 @@ namespace ReallifeGamemode.Server.Managers { public static List ATMColShapes = new List(); + private static readonly ILogger logger = LogManager.GetLogger(); + public static void InitATMs() { var addedATMs = 0; @@ -112,15 +116,16 @@ namespace ReallifeGamemode.Server.Managers //client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance); client.SendNotification("~r~Nicht genügend Geld auf der Hand!"); } - else if(inputField1 < 0) + else if (inputField1 < 0) { client.SendNotification("~r~Ungültiger Betrag!"); - } - else + } + else { var updateBankMoneyIn = user.BankAccount; var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); user.Handmoney -= inputField1; + logger.LogInformation("Player {0} did a deposit of {1} dollars at atm {2}", client.Name, inputField1, nearATM); updateBankMoneyIn.Balance += inputField1; updateATMBalanceIn.Balance += inputField1; //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); @@ -149,6 +154,7 @@ namespace ReallifeGamemode.Server.Managers var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); updateHandMoneyOut.Handmoney += inputField1; user.BankAccount.Balance -= inputField1; + logger.LogInformation("Player {0} did a withdraw of {1} dollars at atm {2}", client.Name, inputField1, nearATM); updateATMBalanceOut.Balance -= inputField1; //client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney); } diff --git a/ReallifeGamemode.Server/Managers/CharacterCreator.cs b/ReallifeGamemode.Server/Managers/CharacterCreator.cs index f0c2ee73..4815ec7c 100644 --- a/ReallifeGamemode.Server/Managers/CharacterCreator.cs +++ b/ReallifeGamemode.Server/Managers/CharacterCreator.cs @@ -1,11 +1,13 @@ using System.Linq; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Events; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; namespace ReallifeGamemode.Server.Managers { @@ -14,6 +16,8 @@ namespace ReallifeGamemode.Server.Managers public static Vector3 surgeryPoint = new Vector3(342.30032, -1397.7542, 32.50923); public const int SURGERY_PRICE = 15000; + private static readonly ILogger logger = LogManager.GetLogger(); + public CharacterCreator() { //LoadSurgery(); @@ -273,6 +277,7 @@ namespace ReallifeGamemode.Server.Managers } else { + logger.LogInformation("Player {0} bought a surgery for {1} dollars", player.Name, SURGERY_PRICE); user.BankAccount.Balance -= SURGERY_PRICE; } saveCharacter.Remove(oldChar); diff --git a/ReallifeGamemode.Server/Managers/CityHallManager.cs b/ReallifeGamemode.Server/Managers/CityHallManager.cs index 428c90de..53259373 100644 --- a/ReallifeGamemode.Server/Managers/CityHallManager.cs +++ b/ReallifeGamemode.Server/Managers/CityHallManager.cs @@ -1,9 +1,11 @@ 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; using ReallifeGamemode.Server.Types; @@ -11,8 +13,11 @@ namespace ReallifeGamemode.Server.Managers { internal class CityHallManager : Script { + private const int GROUP_PRICE = 50000; private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9); + private static readonly ILogger logger = LogManager.GetLogger(); + public static void LoadCityHall() { NAPI.Marker.CreateMarker(GTANetworkAPI.MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255)); @@ -57,13 +62,14 @@ namespace ReallifeGamemode.Server.Managers u.Group = group; u.GroupRank = GroupRank.OWNER; - if (player.GetUser(dbContext).BankAccount.Balance < 50000) + if (u.BankAccount.Balance < GROUP_PRICE) { ChatService.ErrorMessage(player, "Du hast nicht genug Geld"); return; } - player.GetUser(dbContext).BankAccount.Balance -= 50000; + logger.LogInformation("Player {0} created a group for {1} dollars", player.Name, GROUP_PRICE); + u.BankAccount.Balance -= GROUP_PRICE; dbContext.SaveChanges(); ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group); diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 536a9fe9..4d799e80 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -16,6 +16,8 @@ using ReallifeGamemode.Server.Events; using System; using ReallifeGamemode.Server.Core.API; using ReallifeGamemode.Server.Factions.Medic; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) @@ -27,6 +29,8 @@ namespace ReallifeGamemode.Server.Managers { public class InteractionManager : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + #region Eigeninteraktionen Taste-M [RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")] @@ -484,8 +488,8 @@ namespace ReallifeGamemode.Server.Managers using var dbContext = new DatabaseContext(); var user = player.GetUser(dbContext); ServerVehicle serverVehicle = dbContext.ServerVehicles.FirstOrDefault(v => v.Id == id); - - if(serverVehicle is UserVehicle) + + if (serverVehicle is UserVehicle) { UserVehicle userVehicle = dbContext.UserVehicles.Where(v => v.Id == id && v.UserId == user.Id).FirstOrDefault(); var vehPrice = userVehicle.Price; @@ -493,25 +497,29 @@ namespace ReallifeGamemode.Server.Managers GTANetworkAPI.Vehicle veh = VehicleManager.GetVehicleFromServerVehicle(userVehicle); user.BankAccount.Balance += backPrice; - ChatService.SendMessage(player, $"~b~[INFO]~s~ Du hast durch den Autoverkauf ~g~{backPrice.ToMoneyString()} ~s~erhalten."); + logger.LogInformation("Player {0} sold his uservehicle {1} for {2} dollars", player.Name, userVehicle.Model.ToString(), backPrice); + + ChatService.SendMessage(player, $"~b~[INFO]~s~ Du hast durch den Autoverkauf ~g~{backPrice.ToMoneyString()}~s~ erhalten."); VehicleManager.DeleteVehicle(veh); dbContext.UserVehicles.Remove(userVehicle); player.SendNotification("~g~Du hast dein Fahrzeug verkauft"); } - else if(serverVehicle is FactionVehicle) + else if (serverVehicle is FactionVehicle) { FactionVehicle factionVehicle = dbContext.FactionVehicles.FirstOrDefault(v => v.Id == id); var backPrice = (int)(factionVehicle.BuyPrice * 1.5 * 0.4); user.Faction.BankAccount.Balance += backPrice; + logger.LogInformation("Player {0} sold thr factionvehicle {1} of faction {2} for {3} dollars", player.Name, factionVehicle.Model.ToString(), user.Faction.Id, backPrice); + ChatService.SendMessage(player, $"~b~[INFO]~s~ Die Fraktionskasse hat ~g~{backPrice.ToMoneyString()}~s~ erhalten."); VehicleManager.DeleteVehicle(VehicleManager.GetVehicleFromServerVehicle(factionVehicle)); dbContext.FactionVehicles.Remove(factionVehicle); player.SendNotification("~g~Du hast dein Fraktionsfahrzeug verkauft"); - } + } dbContext.SaveChanges(); } @@ -564,13 +572,13 @@ namespace ReallifeGamemode.Server.Managers ChatService.ErrorMessage(player, "Das Fahrzeug konnte nicht verkauft werden. Bitte melde dich bei der Leaderverwaltung"); return; } - + var backPrice = (int)(price.Price * 1.5 * 0.4); player.SetData("SellVehicleDecision", true); player.SetData("VehicleToSell", id); - ChatService.SendMessage(player, "~s~Möchtest du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~" + backPrice.ToMoneyString() + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen."); + ChatService.SendMessage(player, "~s~Möchtest du das Fahrzeug ~y~" + veh.DisplayName + " ~s~wirklich für ~g~" + backPrice.ToMoneyString() + " ~s~verkaufen? Drücke ~g~J~s~ zum Bestätigen oder ~r~N ~s~zum Abbrechen."); } } @@ -733,6 +741,7 @@ namespace ReallifeGamemode.Server.Managers fibBankAccount.Balance += (int)(ticket_amount / 100 * 60); lspdBankAccount.Balance += (int)(ticket_amount / 100 * 40); } + logger.LogInformation("Player {0} accepted a ticket of {1} dollars", player.Name, ticket_amount); dbContext.SaveChanges(); } target.ResetData("ticket_boolean"); @@ -798,6 +807,7 @@ namespace ReallifeGamemode.Server.Managers if (amount > 0 && amount <= 5000) { + logger.LogInformation("Player {0} did a local payment of {1} dollars to player {2}", player.Name, amount, target.Name); player.SendNotification($"~w~Du hast ~y~{targetname} ~w~{amount.ToMoneyString()} gegeben."); target.SendNotification($"~w~ Du hast von ~y~{playername} ~w~{amount.ToMoneyString()} erhalten.", true); diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index ffeb557b..e0dc309d 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -14,6 +14,8 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Services; using ReallifeGamemode.Server.Types; +using Microsoft.Extensions.Logging; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs) @@ -25,6 +27,9 @@ namespace ReallifeGamemode.Server.Managers { public class InventoryManager : Script { + private const int MAX_USER_INVENTORY = 40000; + private static readonly ILogger logger = LogManager.GetLogger(); + public static List itemList; private static Dictionary TradeItems { get; set; } = new Dictionary(); @@ -224,7 +229,7 @@ namespace ReallifeGamemode.Server.Managers using (var context = new DatabaseContext()) { - List userItems = context.UserItems.ToList().FindAll(i => i.UserId == user.Id); + List userItems = context.UserItems.Where(i => i.UserId == user.Id).ToList(); foreach (var item in userItems) { IItem iItem = GetItemById(item.ItemId); @@ -381,7 +386,7 @@ namespace ReallifeGamemode.Server.Managers int setAmount = 0; for (int i = 1; i <= amount; i++) { - if (GetUserInventoryWeight(player) + (i * GetItemById(itemId).Gewicht) > 40000) + if (GetUserInventoryWeight(player) + (i * GetItemById(itemId).Gewicht) > MAX_USER_INVENTORY) { break; } @@ -589,7 +594,7 @@ namespace ReallifeGamemode.Server.Managers break; } context.SaveChanges(); - + } } @@ -608,6 +613,14 @@ namespace ReallifeGamemode.Server.Managers return; } + logger.LogInformation("Player {0} bought the item {1} for {2} dollars", client.Name, shopItem.Name, shopItem.Price); + + if (GetUserInventoryWeight(client) + shopItem.Gewicht > MAX_USER_INVENTORY) + { + + return; + } + UserItem item = dbContext.UserItems.Where(i => i.ItemId == shopItem.Id && i.UserId == user.Id).FirstOrDefault(); if (item == null) { diff --git a/ReallifeGamemode.Server/Managers/TuningManager.cs b/ReallifeGamemode.Server/Managers/TuningManager.cs index af39a796..c3834da0 100644 --- a/ReallifeGamemode.Server/Managers/TuningManager.cs +++ b/ReallifeGamemode.Server/Managers/TuningManager.cs @@ -2,14 +2,17 @@ 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.Log; namespace ReallifeGamemode.Server.Managers { internal class TuningManager : Script { + private static readonly ILogger logger = LogManager.GetLogger(); private static List tuningGarages = new List(); public static void LoadTuningGarages() @@ -220,6 +223,7 @@ namespace ReallifeGamemode.Server.Managers ServerVehicle sV = player.Vehicle.GetServerVehicle(dbContext); if (sV == null) return; + logger.LogInformation("Player {0} bought a tuning part for server vehicle {1}, slot: {2}, mod: {3} for {4} dollars", player.Name, sV.Id, slot, index, price); VehicleMod vMod = dbContext.VehicleMods.FirstOrDefault(m => m.ServerVehicleId == sV.Id && m.Slot == slot); if (vMod == null && index != -1) @@ -265,7 +269,7 @@ namespace ReallifeGamemode.Server.Managers veh.SecondaryColor = color; } - using var dbContext = new DatabaseContext(true); + using var dbContext = new DatabaseContext(); ServerVehicle serverVeh = VehicleManager.GetServerVehicleFromVehicle(veh, dbContext); if (serverVeh == null) @@ -311,6 +315,7 @@ namespace ReallifeGamemode.Server.Managers if (serverVehicle != null) { + logger.LogInformation("Player {0} bought wheels for server vehicle {1}, type: {2}, wheels: {3} for {4} dollars", player.Name, serverVehicle.Id, wheelType, wheelIndex, price); VehicleMod typeMod = dbContext.VehicleMods.Where(m => m.ServerVehicleId == serverVehicle.Id && m.Slot == -2).FirstOrDefault(); if (typeMod == null) { diff --git a/ReallifeGamemode.Server/Util/Rentcar.cs b/ReallifeGamemode.Server/Util/Rentcar.cs index ff17b584..b5828f64 100644 --- a/ReallifeGamemode.Server/Util/Rentcar.cs +++ b/ReallifeGamemode.Server/Util/Rentcar.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Text; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Log; using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Services; @@ -12,6 +14,7 @@ namespace ReallifeGamemode.Server.Util { class Rentcar : Script { + private static readonly ILogger logger = LogManager.GetLogger(); //In Sekunden public static int PAY_TIMER = 180; @@ -69,6 +72,7 @@ namespace ReallifeGamemode.Server.Util { User user = player.GetUser(dbContext); user.BankAccount.Balance -= mapPlayerRentcarBill[player.Name].Item2; + logger.LogInformation("Player {0} cancelled a rent and payed {1} dollars", player.Name, mapPlayerRentcarBill[player.Name].Item2); dbContext.SaveChanges(); } @@ -105,9 +109,9 @@ namespace ReallifeGamemode.Server.Util { return; } - + player.TriggerEvent("BN_Show", "Fahrzeug seit ~b~" + (int)(time / 60) + "~w~ Minuten gemietet (Gesamtkosten: ~g~$~s~" + bill + ")."); - mapPlayerRentcarBill[player.Name] = (mapPlayerRentcarBill[player.Name].Item1, bill); + mapPlayerRentcarBill[player.Name] = (mapPlayerRentcarBill[player.Name].Item1, bill); } [RemoteEvent("SERVER:rentcarBooked")] From 7ad941cd91b0933b1e7eeb5246883c0af4133459 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 10:18:38 +0200 Subject: [PATCH 12/36] remove db logs --- ReallifeGamemode.Server/Main.cs | 370 +++++++++--------- .../Managers/InteractionManager.cs | 2 +- .../WeaponDeal/WeaponDealManager.cs | 4 +- 3 files changed, 188 insertions(+), 188 deletions(-) diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index c50c6ce4..439d20df 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -29,212 +29,212 @@ using System.IO; namespace ReallifeGamemode.Server { - public class Main : Script + public class Main : Script + { + public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); + public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; + + public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); + + private Core.Events.EventHandler eventHandler; + + private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); + + public Main() { - public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-1033.93603515625, -2731.572998046875, 13.756634712219238); - public static readonly float DEFAULT_SPAWN_HEADING = -32.23991012573242f; + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + } - public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); - - private Core.Events.EventHandler eventHandler; - - private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX"); - - public Main() + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() + { + try + { + if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - } + using var dbContext = new DatabaseContext(true); + + var pendingMigrations = dbContext.Database.GetPendingMigrations(); + + if (!pendingMigrations.Any()) + { + System.Console.WriteLine("No migrations to apply"); + } + else + { + System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); + foreach (var migration in pendingMigrations) + { + System.Console.WriteLine("\t{0}", migration); + } - [ServerEvent(Event.ResourceStart)] - public void OnResourceStart() - { try { - if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true") - { - using var dbContext = new DatabaseContext(true); - - var pendingMigrations = dbContext.Database.GetPendingMigrations(); - - if (!pendingMigrations.Any()) - { - System.Console.WriteLine("No migrations to apply"); - } - else - { - System.Console.WriteLine("Applying {0} migrations", pendingMigrations.Count()); - foreach (var migration in pendingMigrations) - { - System.Console.WriteLine("\t{0}", migration); - } - - try - { - dbContext.Database.Migrate(); - } - catch (System.Exception e) - { - System.Console.WriteLine("Error while updating database: {0}", e.ToString()); - System.Console.ReadLine(); - System.Environment.Exit(1); - } - - System.Console.WriteLine("Migrations successfull"); - } - } - - var methods = Assembly.GetExecutingAssembly() - .GetTypes() - .SelectMany(t => t.GetMethods()) - .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) - .ToArray(); - - var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); - - var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); - cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => - { - registeredCommands.AddRange(a.Alias.Split(',')); - }); - - IAPI apiInstance = new RageAPI(); - eventHandler = new Core.Events.EventHandler(apiInstance); - - new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); - - NAPI.Server.SetGlobalServerChat(false); - - NAPI.Server.SetCommandErrorMessage(""); - NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); - NAPI.Server.SetAutoSpawnOnConnect(false); - NAPI.Server.SetAutoRespawnAfterDeath(false); - NAPI.Data.SetWorldData("playerCreatorDimension", 0); - - JsonConvert.DefaultSettings = () => - { - return new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }; - }; - - InventoryManager.LoadItems(); - ShopManager.LoadClotheShops(); - ShopManager.LoadItemShops(); - ShopManager.LoadFriseur(); - ShopManager.LoadAmmunations(); - TuningManager.LoadTuningGarages(); - - TimeManager.StartTimeManager(); - VehicleManager.CheckEnabledMods(); - - DatabaseHelper.InitDatabaseFirstTime(); - - FactionHelper.CheckFactionBankAccounts(); - BusinessManager.LoadBusinesses(); - //InteriorManager.LoadInteriors(); - DoorManager.LoadDoors(); - ATMManager.InitATMs(); - CityHallManager.LoadCityHall(); - JobManager.LoadJobs(); - //TaxiDriverJob.StartTaxiTimer(); Obselete - //HouseManager.LoadHouses(); - DrivingSchool.DrivingSchool.Setup(); - PlaneSchool.Setup(); - Gangwar.Gangwar.loadTurfs(); - Bank.Bank.Setup(); - Introduction.Setup(); - PositionManager.LoadPositionManager(); - LoadManager.LoadLoadManager(); - Rentcar.Setup(); - - World.WeatherSync.Load(); - - TempBlip tempBlip = new TempBlip() - { - Color = 1, - Name = "", - Transparency = 0, - ShortRange = true, - Sprite = 1, - Scale = 1, - }; - - NAPI.Data.SetWorldData("blipTemplate", tempBlip); - - //WantedEscapeTimer.WantedTimer(); Obselete - //Jail.JailTimer(); Obselete - //Economy.PaydayTimer(); Obselete - // WeaponDealManager.WeaponDealTimer(); Obselete - - ThreadTimers.StartAllTimers(); - - Managers.SVarManager.LoadSVars(); - - UserBankAccount.BalanceChanged += (account) => - { - using (var dbContext = new DatabaseContext()) - { - var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); - if (user == null) - { - return; - } - - Player player = PlayerService.GetPlayerByNameOrId(user); - if (player == null) - { - return; - } - - player.TriggerEvent("updateMoney", account.Balance); - } - }; - - User.HandMoneyChanged += (user) => - { - user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); - }; - - //IPLS - NAPI.World.RequestIpl("vw_casino_garage"); - + dbContext.Database.Migrate(); } - catch (Exception e) + catch (System.Exception e) { - Log(e.ToString()); + System.Console.WriteLine("Error while updating database: {0}", e.ToString()); + System.Console.ReadLine(); + System.Environment.Exit(1); } + + System.Console.WriteLine("Migrations successfull"); + } } - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + var methods = Assembly.GetExecutingAssembly() + .GetTypes() + .SelectMany(t => t.GetMethods()) + .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) + .ToArray(); + + var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); + + var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); + cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => { - Log(e.ExceptionObject.ToString()); - } + registeredCommands.AddRange(a.Alias.Split(',')); + }); - private void Log(string message) + IAPI apiInstance = new RageAPI(); + eventHandler = new Core.Events.EventHandler(apiInstance); + + new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); + + NAPI.Server.SetGlobalServerChat(false); + + NAPI.Server.SetCommandErrorMessage(""); + NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); + NAPI.Server.SetAutoSpawnOnConnect(false); + NAPI.Server.SetAutoRespawnAfterDeath(false); + NAPI.Data.SetWorldData("playerCreatorDimension", 0); + + JsonConvert.DefaultSettings = () => { - string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - string log = Path.Combine(basePath, "log.txt"); + return new JsonSerializerSettings() + { + NullValueHandling = NullValueHandling.Ignore + }; + }; - logMutex.WaitOne(); + InventoryManager.LoadItems(); + ShopManager.LoadClotheShops(); + ShopManager.LoadItemShops(); + ShopManager.LoadFriseur(); + ShopManager.LoadAmmunations(); + TuningManager.LoadTuningGarages(); - if (!File.Exists(log)) + TimeManager.StartTimeManager(); + VehicleManager.CheckEnabledMods(); + + DatabaseHelper.InitDatabaseFirstTime(); + + FactionHelper.CheckFactionBankAccounts(); + BusinessManager.LoadBusinesses(); + //InteriorManager.LoadInteriors(); + DoorManager.LoadDoors(); + ATMManager.InitATMs(); + CityHallManager.LoadCityHall(); + JobManager.LoadJobs(); + //TaxiDriverJob.StartTaxiTimer(); Obselete + //HouseManager.LoadHouses(); + DrivingSchool.DrivingSchool.Setup(); + PlaneSchool.Setup(); + Gangwar.Gangwar.loadTurfs(); + Bank.Bank.Setup(); + Introduction.Setup(); + PositionManager.LoadPositionManager(); + LoadManager.LoadLoadManager(); + Rentcar.Setup(); + + World.WeatherSync.Load(); + + TempBlip tempBlip = new TempBlip() + { + Color = 1, + Name = "", + Transparency = 0, + ShortRange = true, + Sprite = 1, + Scale = 1, + }; + + NAPI.Data.SetWorldData("blipTemplate", tempBlip); + + //WantedEscapeTimer.WantedTimer(); Obselete + //Jail.JailTimer(); Obselete + //Economy.PaydayTimer(); Obselete + // WeaponDealManager.WeaponDealTimer(); Obselete + + ThreadTimers.StartAllTimers(); + + Managers.SVarManager.LoadSVars(); + + UserBankAccount.BalanceChanged += (account) => + { + using (var dbContext = new DatabaseContext()) + { + var user = dbContext.Users.Where(u => u.BankAccountId == account.Id).Select(u => u.Name).FirstOrDefault(); + if (user == null) { - File.Create(log); + return; } - string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; + Player player = PlayerService.GetPlayerByNameOrId(user); + if (player == null) + { + return; + } - File.AppendAllText(log, msg); + player.TriggerEvent("updateMoney", account.Balance); + } + }; - logMutex.ReleaseMutex(); - } - - [RemoteEvent("CLIENT:Event")] - public void OnClientEvent(Player player, string dataStr) + User.HandMoneyChanged += (user) => { - var data = dataStr.DeserializeJson>(); - eventHandler.HandleEvent(new RagePlayer(player), data); - } + user.Player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + }; + + //IPLS + NAPI.World.RequestIpl("vw_casino_garage"); + + } + catch (Exception e) + { + Log(e.ToString()); + } } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Log(e.ExceptionObject.ToString()); + } + + private void Log(string message) + { + string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + string log = Path.Combine(basePath, "log.txt"); + + logMutex.WaitOne(); + + if (!File.Exists(log)) + { + File.Create(log); + } + + string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}"; + + File.AppendAllText(log, msg); + + logMutex.ReleaseMutex(); + } + + [RemoteEvent("CLIENT:Event")] + public void OnClientEvent(Player player, string dataStr) + { + var data = dataStr.DeserializeJson>(); + eventHandler.HandleEvent(new RagePlayer(player), data); + } + } } diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 4d799e80..d6d6e0ed 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -55,7 +55,7 @@ namespace ReallifeGamemode.Server.Managers return; } - using (var dbContext = new DatabaseContext(true)) + using (var dbContext = new DatabaseContext()) { User u = leader.GetUser(dbContext); User own = player.GetUser(dbContext); diff --git a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs index 2d430b6a..0f26f7cf 100644 --- a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs +++ b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs @@ -43,7 +43,7 @@ namespace ReallifeGamemode.Server.WeaponDeal return; } - using (var context = new DatabaseContext(true)) + using (var context = new DatabaseContext()) { FactionVehicle factionVehicle = context.FactionVehicles.Where(f => f.Model == WEAPON_DEAL_GANG_VEHICLE_HASH || f.Model == WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH) .ToList() @@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server.WeaponDeal Faction fac = context.Factions.Where(f => f.Id == user.FactionId).FirstOrDefault(); fac.WeaponDealTime = (fac.Id == 1 | fac.Id == 3) ? 180 : 60; - context.SaveChanges(); + context.SaveChanges(); } } From 2c09e6961f439b1be95edf8daa7b0b3ee18f5b88 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 10:22:15 +0200 Subject: [PATCH 13/36] =?UTF-8?q?fix=20error=20bei=20auto=20auf/abschlie?= =?UTF-8?q?=C3=9Fen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReallifeGamemode.Server/Events/Key.cs | 2 +- ReallifeGamemode.Server/Events/Vehicle.cs | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 15af42c2..22b9e783 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -963,7 +963,7 @@ namespace ReallifeGamemode.Server.Events } [RemoteEvent("keyPress:Z")] - public void KeyPressX(Player player) + public void KeyPressZ(Player player) { if (!player.IsLoggedIn() || player.GetData("isDead")) return; diff --git a/ReallifeGamemode.Server/Events/Vehicle.cs b/ReallifeGamemode.Server/Events/Vehicle.cs index b35b9dd3..ff21e6d8 100644 --- a/ReallifeGamemode.Server/Events/Vehicle.cs +++ b/ReallifeGamemode.Server/Events/Vehicle.cs @@ -140,14 +140,9 @@ namespace ReallifeGamemode.Server.Events { ServerVehicle carlocked = v.GetServerVehicle(dbContext); - if (state == true) + if (carlocked != null) { - carlocked.Locked = true; - dbContext.SaveChanges(); - } - else - { - carlocked.Locked = false; + carlocked.Locked = state; dbContext.SaveChanges(); } } @@ -208,14 +203,9 @@ namespace ReallifeGamemode.Server.Events { ServerVehicle carlocked = vehicle.GetServerVehicle(dbContext); - if (state == true) + if (carlocked != null) { - carlocked.Locked = true; - dbContext.SaveChanges(); - } - else - { - carlocked.Locked = false; + carlocked.Locked = state; dbContext.SaveChanges(); } } From e4e3bd0fbf0fa109c180f6bafaacee7c26970703 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 10:22:27 +0200 Subject: [PATCH 14/36] fix error bei waffenschein kaufen --- ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs index 67021b46..9bff07a7 100644 --- a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs +++ b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs @@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Core.Menus return; } - Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name); + Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name, WEAPONLICENSE_PRICE); account.Balance -= WEAPONLICENSE_PRICE; From 104615774746f95d7dca5cf8c19ec6c908fa6fb5 Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 8 May 2021 02:16:16 +0200 Subject: [PATCH 15/36] Lol --- .../Jobs/FarmerFieldSelect.ts | 134 +++++++++++++ ReallifeGamemode.Client/Player/polygons.ts | 1 - ReallifeGamemode.Client/index.ts | 3 + ReallifeGamemode.Server/Events/Key.cs | 37 ++++ ReallifeGamemode.Server/Job/FarmerJob.cs | 176 ++++++++++++++++++ .../Managers/PositionManager.cs | 13 ++ 6 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 ReallifeGamemode.Client/Jobs/FarmerFieldSelect.ts create mode 100644 ReallifeGamemode.Server/Job/FarmerJob.cs diff --git a/ReallifeGamemode.Client/Jobs/FarmerFieldSelect.ts b/ReallifeGamemode.Client/Jobs/FarmerFieldSelect.ts new file mode 100644 index 00000000..d89c7f32 --- /dev/null +++ b/ReallifeGamemode.Client/Jobs/FarmerFieldSelect.ts @@ -0,0 +1,134 @@ +import * as NativeUI from '../libs/NativeUI'; + +var fieldSelectColShape = mp.colshapes.newCircle(2415.229, 4993.037, 46.230038); +const Menu = NativeUI.Menu; +var fieldMenu: NativeUI.Menu; +const Point = NativeUI.Point; +const UIMenuListItem = NativeUI.UIMenuListItem; +const ItemsCollection = NativeUI.ItemsCollection; +const UIMenuItem = NativeUI.UIMenuItem; +const Color = NativeUI.Color; + +let sendItem = new UIMenuItem("Starten", "Route starten"); +sendItem.BackColor = new Color(13, 71, 161); +sendItem.HighlightedBackColor = new Color(25, 118, 210); + +let cancelItem = new UIMenuItem("Abbrechen", ""); +cancelItem.BackColor = new Color(213, 0, 0); +cancelItem.HighlightedBackColor = new Color(229, 57, 53); + +let screenRes = mp.game.graphics.getScreenResolution(0, 0); +var checkpoint = new mp.Vector3(2416.3723, 4993.94, 45); + +export default function farmerFieldList(globalData: IGlobalData) { + var skillSelect; + var skill = 60; + var fieldSelected = false; + var fieldSelect; + + mp.events.add(RageEnums.EventKey.PLAYER_EXIT_COLSHAPE, (colshape) => { + if (colshape == fieldSelectColShape) { + if (fieldMenu && fieldMenu.Visible) { + fieldMenu.Close(); + } + } + }); + + mp.events.add('SERVER:selectField', () => { + + skill = 100; + + if (!globalData.InMenu) { + globalData.InMenu = true; + + skillSelect = ["Knecht (1)", "Hilfsarbeiter (2)", "Ackersmann (3)", "Landwirt (4)", "Ökonom (5)"]; + + fieldMenu = new Menu("Bus Job", "", new Point(0, screenRes.y / 3), null, null); + fieldMenu.AddItem(new UIMenuListItem("Stufe wählen", "", new ItemsCollection(skillSelect))); + fieldSelect = "Anfänger"; + fieldMenu.AddItem(sendItem); + fieldMenu.AddItem(cancelItem); + fieldMenu.Visible = true; + + fieldMenu.ListChange.on((item, index) => { + switch (item.Text) { + case "Stufe wählen": + fieldSelect = String(item.SelectedItem.DisplayText); + break; + } + }); + + fieldMenu.ItemSelect.on((item) => { + if (item.Text === "Starten") { + + if (fieldSelect == skillSelect[1] && skill < 5) { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + } + else if (fieldSelect == skillSelect[2] && skill < 10) { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + } + else if (fieldSelect == skillSelect[3] && skill < 25) { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + } + else if (fieldSelect == skillSelect[4] && skill < 50) { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + } + else { + mp.events.callRemote("CLIENT:StartFieldSelected", fieldSelect); + fieldSelected = true; + fieldMenu.Close(); + globalData.InMenu = false; + } + + + } else if (item.Text === "Abbrechen") { + fieldMenu.Close(); + } + }); + + fieldMenu.MenuClose.on(() => { + if (!fieldSelected) { + //mp.events.callRemote("CLIENT:Job_StopJob"); + } + fieldSelected = false; + globalData.InMenu = false; + }); + } + }); + + var activeCheckpoint; + var activeBlip = null; + var myVar; + var activeCheckpointId; + + mp.events.add('farmerSetCheckpoint', (position, markerId, markerSize, cpId) => { + activeCheckpointId = cpId; + + activeCheckpoint = mp.markers.new(markerId, position, markerSize, { + color: [255, 0, 0, 150], + visible: true, + dimension: 0 + }); + + activeBlip = mp.blips.new(1, position, + { + color: 33, + alpha: 255, + shortRange: false, + }); + activeBlip.setRoute(true); + activeBlip.setRouteColour(33); + + clearInterval(myVar); + myVar = setInterval(checkpointTimer, 50); + }); + + function checkpointTimer() { + let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, checkpoint.x, checkpoint.y, 0, false); + + if (dist <= 2) { + clearInterval(myVar); + activeCheckpoint.destroy(); + } + } +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/Player/polygons.ts b/ReallifeGamemode.Client/Player/polygons.ts index 6c755cbf..75cd2f87 100644 --- a/ReallifeGamemode.Client/Player/polygons.ts +++ b/ReallifeGamemode.Client/Player/polygons.ts @@ -57,7 +57,6 @@ const muellbaseVector2 = new mp.Vector3(454.88348, -2158.1938, 5.9788494); const muellbaseVector3 = new mp.Vector3(529.06635, -2088.4097, 8.303088); const krankenhausVector1 = new mp.Vector3(-508.50705, -351.24368, 34); -//const krankenhausVector2 = new mp.Vector3(-437.00146, -357.10526, 32.735916 const krankenhausVector2 = new mp.Vector3(-442.62323, -356.99185, 33); const krankenhausVector3 = new mp.Vector3(-448.9346, -297.23972, 33.68); const krankenhausVector4 = new mp.Vector3(-504.952, -315.21698, 35.04881); diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index e1b91d2d..e3ed1f78 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -268,6 +268,9 @@ antiAfk(globalData); import ammunation from './Interaction/ammunation/ammunation'; ammunation(globalData); +import farmerFieldList from './Jobs/FarmerFieldSelect'; +farmerFieldList(globalData); + import handsup from './Player/handsup'; handsup(); diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 22b9e783..07a412e6 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -585,6 +585,43 @@ namespace ReallifeGamemode.Server.Events } } + if (player.Position.DistanceTo(FarmerJob.POSITION_SCHEUNE) <= 1.5) + { + if (JobManager.GetJob().GetUsersInJob().Contains(player)) + { + player.TriggerEvent("SERVER:selectField"); + return; + } + } + + if (player.Position.DistanceTo(FarmerJob.POSITION_FAHRZEUGHALLE) <= 1.5) + { + if (FarmerJob.playersWaitingForVehicle.Contains(player) || true) + { + FarmerJob.spawnVehicle(player); + return; + } + } + + if (CharacterCreator.surgeryPoint.DistanceTo(player.Position) <= 1.5) + { + if (user.GetData("duty")) + { + player.SendNotification("~r~Im Dienst kannst du nicht operiert werden", false); + return; + } + if (JobBase.GetPlayerInJob().Contains(player)) + { + player.SendNotification("~r~Im aktiven Job kannst du nicht operiert werden", false); + return; + } + if (user.Wanteds > 0) + { + player.SendNotification("~r~Wenn du gesucht wirst kannst du nicht operiert werden", false); + return; + } + } + //if (CharacterCreator.surgeryPoint.DistanceTo(player.Position) <= 1.5) //{ // if (user.GetData("duty")) diff --git a/ReallifeGamemode.Server/Job/FarmerJob.cs b/ReallifeGamemode.Server/Job/FarmerJob.cs new file mode 100644 index 00000000..f6504b76 --- /dev/null +++ b/ReallifeGamemode.Server/Job/FarmerJob.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Database.Entities; +using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Extensions; + +namespace ReallifeGamemode.Server.Job +{ + public class FarmerJob : JobBase + { + public override int Id => 5; + + public override string Name => "Farmer"; + + public override bool NeedVehicleToStart => false; + + public override bool Deactivated => false; + + private static FarmerJob _Instance; + + public static Vector3 POSITION_JOB_START = new Vector3(2434.2983, 4976.952, 46.571423); + public static Vector3 POSITION_SCHEUNE = new Vector3(2416.3723, 4993.94, 45); + public static Vector3 POSITION_SCHEUNE_LABEL = new Vector3(2416.3723, 4993.94, 46); + public static Vector3 POSITION_FAHRZEUGHALLE = new Vector3(2494.346, 4964.773, 43.5833); + public static Vector3 POSITION_FAHRZEUGHALLE_LABEL = new Vector3(2494.346, 4964.773, 44.5833); + + private static TextLabel labelScheune = null; + private static TextLabel labelFahrzeughalle = null; + + public static List playersWaitingForVehicle = new List(); + public static Dictionary playerHasField = new Dictionary(); + + private static readonly Dictionary VEHICLE_SPAWNS = new Dictionary + { + { new Vector3(2500.026, 4982.7485, 44.50283), (float)-148.8139 }, + { new Vector3(2511.2246, 4981.6924, 44.722702), (float)139.25208 }, + { new Vector3(2518.3486, 4977.3125, 44.716434), (float)131.3338 }, + { new Vector3(2522.8215, 4966.823, 44.53701), (float)118.17867 } + }; + + private static int spawnIndex = 0; + + public static readonly List CHECKPOINTS_FIELD1 = new List() + { + new Vector3(2335.83984375, 5114.8525390625, 47.83000183105469), + new Vector3(2295.81201171875, 5153.26123046875, 54.64070129394531), + new Vector3(2277.558837890625, 5139.4453125, 53.3763542175293), + new Vector3(2318.217041015625, 5099.271484375, 46.98373031616211), + new Vector3(2283.467041015625, 5066.1025390625, 45.97780227661133), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3() + }; + + public FarmerJob() + { + JobStart += FarmerDriverJobJobStart; + JobStop += FarmerDriverJobJobStop; + } + + public static FarmerJob GetInstance() + { + if (_Instance == null) + _Instance = new FarmerJob(); + return _Instance; + } + private void FarmerDriverJobJobStart(Player player) + { + labelScheune = NAPI.TextLabel.CreateTextLabel("Scheune - Drücke ~y~E ~w~um ein Feld auszuwählen", POSITION_SCHEUNE_LABEL, 15, 1, 0, new Color(255, 255, 255), false, 0); + + player.SendChatMessage("~y~[JOB]~w~ Begebe dich zur Scheune um Felder zu pachten"); + player.TriggerEvent("farmerSetCheckpoint", POSITION_SCHEUNE, 1, 1, "scheune"); + } + private void FarmerDriverJobJobStop(Player player) + { + player.SendChatMessage("Job stop"); + } + + [RemoteEvent("CLIENT:StartFieldSelected")] + public void startFieldSelected(Player player, String field) + { + labelScheune.Delete(); + labelFahrzeughalle = NAPI.TextLabel.CreateTextLabel("Fahrzeughalle - Drücke ~y~E ~w~um dir ein Fahrzeug zu holen", POSITION_FAHRZEUGHALLE_LABEL, 15, 1, 0, new Color(255, 255, 255), false, 0); + player.SendChatMessage("~y~[JOB]~w~ Begebe dich zur nun zur Fahrzeughalle um dein Fahrzeug abzuholen"); + player.TriggerEvent("farmerSetCheckpoint", POSITION_FAHRZEUGHALLE, 1, 1, "fahrzeughalle"); + playersWaitingForVehicle.Add(player); + playerHasField.Add(player, field); + } + + public static void spawnVehicle(Player player) + { + if (!playerHasField.ContainsKey(player)) + playerHasField.Add(player, "Landwirt (4)"); + + player.SendChatMessage("player " + player.Name + " with field " + playerHasField[player]); + + //NEXT: verschiedene spawnpositionen für fahrzeuge in VEHICLE_SPAWNS + + //Vector3 spawnPoint = VEHICLE_SPAWNS[spawnIndex++ % VEHICLE_SPAWNS.Count]; + Random rnd = new Random(); + spawnIndex = rnd.Next(VEHICLE_SPAWNS.Count); + + Vector3 spawnPoint = VEHICLE_SPAWNS.ElementAt(spawnIndex).Key; + float vehicleHeading = VEHICLE_SPAWNS[spawnPoint]; + Vehicle vehicle = null; + + if (playerHasField[player] == "Knecht (1)") + { + vehicle = NAPI.Vehicle.CreateVehicle(0x61D6BA8C, spawnPoint, vehicleHeading, 111, 111, "JOB"); + } else if (playerHasField[player] == "Hilfsarbeiter (2)") + { + vehicle = NAPI.Vehicle.CreateVehicle(0x61D6BA8C, spawnPoint, vehicleHeading, 111, 111, "JOB"); + } + else if (playerHasField[player] == "Ackersmann (3)") + { + vehicle = NAPI.Vehicle.CreateVehicle(0x843B73DE, spawnPoint, vehicleHeading, 111, 111, "JOB"); + } + else if (playerHasField[player] == "Landwirt (4)") + { + vehicle = NAPI.Vehicle.CreateVehicle(0x843B73DE, spawnPoint, vehicleHeading, 111, 111, "JOB"); + } + else if (playerHasField[player] == "Ökonom(5)") + { + vehicle = NAPI.Vehicle.CreateVehicle(0x843B73DE, spawnPoint, vehicleHeading, 111, 111, "JOB"); + } + + vehicle.NumberPlate = "JOB-" + vehicle.Id; + + _CHANGING_VEHICLE.Add(player); + if (playerVehiclePair.ContainsKey(player)) + { + Vehicle previousVehicle = null; + if (playerVehiclePair[player] != null) + previousVehicle = playerVehiclePair[player]; + playerVehiclePair.Remove(player); + + previousVehicle?.Delete(); + } + playerVehiclePair.Add(player, vehicle); + + player.SetIntoVehicle(vehicle.Handle, 0); + + } + + public override void LastCheckpoint(Player player) + { + //nothing + } + + public override void StartJobEndTimer(Player player) + { + //nothing + } + + public override bool CheckVehicle(Player player, Vehicle vehicle) + { + //nothig, kack jobsystem + return false; + } + } +} diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index d07d9e46..76e9ad3f 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -9,6 +9,7 @@ using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Shop.Ammunation; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Job; namespace ReallifeGamemode.Server.Managers @@ -207,11 +208,18 @@ namespace ReallifeGamemode.Server.Managers jobId = 4, Skill = 0 }; + JobPoint jobPointFarmer = new JobPoint() + { + Position = FarmerJob.POSITION_JOB_START, + jobId = 5, + Skill = 0 + }; JobPoints.Add(jobPointRefuseCollector); JobPoints.Add(jobPointPilot); JobPoints.Add(jobPointPilot2); JobPoints.Add(jobPointBusDriver); + JobPoints.Add(jobPointFarmer); foreach (JobPoint p in JobPoints) { @@ -240,6 +248,11 @@ namespace ReallifeGamemode.Server.Managers NAPI.TextLabel.CreateTextLabel("Busfahrer - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0); NAPI.Blip.CreateBlip(513, p.Position, 1f, 16, "Busfahrer", 255, 0, true); } + if (p.jobId == 5) + { + NAPI.TextLabel.CreateTextLabel("Farmer - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0); + NAPI.Blip.CreateBlip(369, p.Position, 1f, 16, "Farmer", 255, 0, true); + } } #endregion JobPoints From 5a6ccf4991c5c5fa6fa2324ef664e268254139ba Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 15 May 2021 14:25:42 +0200 Subject: [PATCH 16/36] 50 wanteds bugg --- ReallifeGamemode.Server/Extensions/ClientExtension.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 2b57264b..c7af71aa 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -222,12 +222,13 @@ namespace ReallifeGamemode.Server.Extensions internal static void GiveWanteds(this User user, Player cop, int amount, string reason) { - if (user.Wanteds + amount > 50) + int newWanteds = user.Wanteds + amount; + if (newWanteds > 50) { ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten"); - return; + newWanteds = 50; } - int newWanteds = user.Wanteds + amount; + using (var dbContext = new DatabaseContext()) { User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault(); From 28dfca0034bc14fad25e9af8286f23fb3abd9a3e Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 16 May 2021 14:47:33 +0200 Subject: [PATCH 17/36] fix gangwar server crash --- ReallifeGamemode.Server/Gangwar/Turf.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 88573919..58f29fb1 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -280,7 +280,7 @@ namespace ReallifeGamemode.Server.Gangwar a.TriggerEvent("CLIENT:loose"); } ownerFaction.BankAccount.Balance += 15000; - logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getAttacker(), 15000); + logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getName(), getAttacker(), 15000); } else if (getOwner() != FactionName) { @@ -297,7 +297,7 @@ namespace ReallifeGamemode.Server.Gangwar if (a != null) a.TriggerEvent("CLIENT:win"); } - logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getOwner(), 10000); + logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getName(), getOwner(), 10000); this.Owner = FactionName; attackerFaction.BankAccount.Balance += 10000; Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); From 613d61bf82e58ea3dcfd721d1bdd323990401660 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 16 May 2021 14:47:33 +0200 Subject: [PATCH 18/36] fix gangwar server crash (cherry picked from commit 28dfca0034bc14fad25e9af8286f23fb3abd9a3e) --- ReallifeGamemode.Server/Gangwar/Turf.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 88573919..58f29fb1 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -280,7 +280,7 @@ namespace ReallifeGamemode.Server.Gangwar a.TriggerEvent("CLIENT:loose"); } ownerFaction.BankAccount.Balance += 15000; - logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getAttacker(), 15000); + logger.LogInformation("Gang {0} successfully defended the turf {1} against gang {2} and gained {3} dollars", getOwner(), getName(), getAttacker(), 15000); } else if (getOwner() != FactionName) { @@ -297,7 +297,7 @@ namespace ReallifeGamemode.Server.Gangwar if (a != null) a.TriggerEvent("CLIENT:win"); } - logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getOwner(), 10000); + logger.LogInformation("Gang {0} successfully took over the turf {1} from gang {2} and gained {3} dollars", getAttacker(), getName(), getOwner(), 10000); this.Owner = FactionName; attackerFaction.BankAccount.Balance += 10000; Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); From 1475a92359a6f5cd6ecaa81d5693b77f8f2ba6d3 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 15 May 2021 10:22:27 +0200 Subject: [PATCH 19/36] fix error bei waffenschein kaufen (cherry picked from commit e4e3bd0fbf0fa109c180f6bafaacee7c26970703) --- ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs index 67021b46..9bff07a7 100644 --- a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs +++ b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs @@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Core.Menus return; } - Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name); + Log.LogInformation("Player {0} bought a weapon license for {1} dollars", player.Name, WEAPONLICENSE_PRICE); account.Balance -= WEAPONLICENSE_PRICE; From 223fc1da4f87d902a8f6306384b13fdf71a06d8b Mon Sep 17 00:00:00 2001 From: Fabian Date: Sun, 16 May 2021 19:27:33 +0200 Subject: [PATCH 20/36] FARMER DEAKTIVIERT DA NICHT FERTIG @HYDRANT XDD --- ReallifeGamemode.Server/Job/FarmerJob.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Job/FarmerJob.cs b/ReallifeGamemode.Server/Job/FarmerJob.cs index f6504b76..731c0fe8 100644 --- a/ReallifeGamemode.Server/Job/FarmerJob.cs +++ b/ReallifeGamemode.Server/Job/FarmerJob.cs @@ -17,7 +17,7 @@ namespace ReallifeGamemode.Server.Job public override bool NeedVehicleToStart => false; - public override bool Deactivated => false; + public override bool Deactivated => true; private static FarmerJob _Instance; From 70d40df7ca2d119a22c3cd8b79aaccee8a2d567f Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 16 May 2021 20:46:14 +0200 Subject: [PATCH 21/36] /aunshow und NoClip auf Admin 1 --- ReallifeGamemode.Server/Commands/AdminCommands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index dbf19e4d..c7343e19 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -1766,7 +1766,7 @@ namespace ReallifeGamemode.Server.Commands public void CmdAdminUnshow(Player player) { User user = player.GetUser(); - if (!user.IsAdmin(AdminLevel.HEADADMIN)) + if (!user.IsAdmin(AdminLevel.ADMIN)) { ChatService.NotAuthorized(player); return; @@ -4077,7 +4077,7 @@ namespace ReallifeGamemode.Server.Commands [RemoteEvent("Noclip")] public void Noclip(Player player) { - if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN)) + if (!player.GetUser().IsAdmin(AdminLevel.ADMIN)) { return; } From eebf0469a5573af95c13f37763585d1be7dbc523 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 16 May 2021 22:59:40 +0200 Subject: [PATCH 22/36] Pilot Job Verdienst angepasst --- ReallifeGamemode.Server/Job/PilotJob.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs index fb3d80dc..cab36fea 100644 --- a/ReallifeGamemode.Server/Job/PilotJob.cs +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -24,8 +24,8 @@ namespace ReallifeGamemode.Server.Job public const string INTERMEDIATE = "Fortgeschrittener"; public const string PROFESSIONAL = "Profi"; - public const int WAGE_BEGINNER = 350; - public const int WAGE_INTERMEDIATE = 950; + public const int WAGE_BEGINNER = 600; + public const int WAGE_INTERMEDIATE = 1300; public const uint VEHICLE_BEGINNER = (uint)VehicleHash.Cuban800; public const uint VEHICLE_INTERMEDIATE = (uint)VehicleHash.Velum2; From 0644017701e24eeb43cc5efd0ae6533a20b20d0d Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 00:15:27 +0200 Subject: [PATCH 23/36] Einkommenssteuer gesenkt --- ReallifeGamemode.Server/Finance/Economy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index 65fa002f..90d204bc 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -29,7 +29,7 @@ namespace ReallifeGamemode.Server.Finance { int bankAccount = client.GetUser().BankAccount.Balance; float financialHelp = -(float)Math.Pow(1.0001, -(bankAccount + client.GetUser().Handmoney)) * -1000; - float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1; + float financialInterest = 1 - (float)Math.Pow(1.000041, -wage) * 1; if (financialInterest >= 0.7) financialInterest = 0.7f; From d79abd919ef01578f2902dab65265bd360cd346d Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 00:43:01 +0200 Subject: [PATCH 24/36] fix givemoney log --- ReallifeGamemode.Server/Commands/AdminCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 15d1d9d0..9f4a938a 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -3384,7 +3384,7 @@ namespace ReallifeGamemode.Server.Commands using (var dbContext = new DatabaseContext()) { - logger.LogInformation("Admin {0} added {2} dollars to the bank account of {1}", player.Name, target.Name, amount); + logger.LogInformation("Admin {0} added {1} dollars to the bank account of {2}", player.Name, amount, target.Name); target.GetUser(dbContext).BankAccount.Balance += amount; dbContext.SaveChanges(); } From b8b103389d276e557c881ce78d51df174e245651 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 00:43:11 +0200 Subject: [PATCH 25/36] adjust tuning price --- ReallifeGamemode.Client/Tuning/main.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Client/Tuning/main.ts b/ReallifeGamemode.Client/Tuning/main.ts index 15b408a5..589834f0 100644 --- a/ReallifeGamemode.Client/Tuning/main.ts +++ b/ReallifeGamemode.Client/Tuning/main.ts @@ -36,12 +36,12 @@ export default function tuning(globalData: IGlobalData) { { Slot: 8, Name: "Extra 1", Price: 2000 }, { Slot: 9, Name: "Extra 2", Price: 2000 }, { Slot: 10, Name: "Dach", Price: 1500 }, - { Slot: 11, Name: "Motor", BasePercentage: 20, PriceIncreasePerLevel: 7.5 }, - { Slot: 12, Name: "Bremsen", BasePercentage: 5, PriceIncreasePerLevel: 2.5 }, - { Slot: 13, Name: "Getriebe", BasePercentage: 10, PriceIncreasePerLevel: 2.5 }, + { Slot: 11, Name: "Motor", BasePercentage: 6.25, PriceIncreasePerLevel: 6.25 }, + { Slot: 12, Name: "Bremsen", BasePercentage: 2.5, PriceIncreasePerLevel: 2.5 }, + { Slot: 13, Name: "Getriebe", BasePercentage: 3.75, PriceIncreasePerLevel: 3.75 }, { Slot: 14, Name: "Hupe", Price: 500 }, { Slot: 15, Name: "Federung", Price: 2000 }, - { Slot: 18, Name: "Turbo", BasePercentage: 45, PriceIncreasePerLevel: 0 }, + { Slot: 18, Name: "Turbo", BasePercentage: 25, PriceIncreasePerLevel: 0 }, { Slot: 22, Name: "Licht", Price: 500 }, { Slot: -2, Name: "Reifen", Price: 2500 }, { Slot: -1, Name: "Lackierung", Price: 1000 }, From e916e85314a1cdd4f755182a06d36acab5ddda23 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 00:58:41 +0200 Subject: [PATCH 26/36] improve wt check --- ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs index fe7af038..35249da1 100644 --- a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs +++ b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs @@ -129,7 +129,7 @@ namespace ReallifeGamemode.Server.WeaponDeal InventoryManager.RemoveAllItemsfromVehicleInventory(fVeh); Faction fac = context.Factions.Where(f => f.Id == user.FactionId).FirstOrDefault(); - if (fac.Id == 1 | fac.Id == 3) + if (WEAPON_DEAL_STAATSFRAK_IDS.Contains(fac.Id)) { fac.WeaponDealTime = 180; context.SaveChanges(); From fac349900e416024dc35a4d33b91cb4d21dca192 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 01:17:07 +0200 Subject: [PATCH 27/36] adjust wt amount --- .../WeaponDeal/WeaponDealManager.cs | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs index 35249da1..8cfaae03 100644 --- a/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs +++ b/ReallifeGamemode.Server/WeaponDeal/WeaponDealManager.cs @@ -20,9 +20,15 @@ namespace ReallifeGamemode.Server.WeaponDeal public static readonly VehicleHash WEAPON_DEAL_GANG_VEHICLE_HASH = VehicleHash.Gburrito2; public static readonly VehicleHash WEAPON_DEAL_STAATSFRAK_VEHICLE_HASH = VehicleHash.Policet; - private const int WEAPON_AMOUNT_GANG = 2; - private const int WEAPON_AMOUNT_COP = 4; - private const int WEAPON_AMOUNT_COP_STUNGUN = 4; + private const int WEAPON_AMOUNT_GANG = 1; + private const int WEAPON_AMOUNT_GANG_PISTOL50 = 3; + private const int WEAPON_AMOUNT_GANG_ARMOR = 2; + + private const int WEAPON_AMOUNT_COP = 3; + private const int WEAPON_AMOUNT_COP_ARMOR = 4; + private const int WEAPON_AMOUNT_COP_PISTOLS = 5; + private const int WEAPON_AMOUNT_COP_SNIPER = 1; + public static bool checkWeaponDbyVehicle(Vehicle vehicle) { if ((vehicle.HasData("WeaponDealLoad") && vehicle.GetData("WeaponDealLoad") == true) || @@ -132,13 +138,12 @@ namespace ReallifeGamemode.Server.WeaponDeal if (WEAPON_DEAL_STAATSFRAK_IDS.Contains(fac.Id)) { fac.WeaponDealTime = 180; - context.SaveChanges(); } else { fac.WeaponDealTime = 60; - context.SaveChanges(); } + context.SaveChanges(); } } @@ -208,11 +213,11 @@ namespace ReallifeGamemode.Server.WeaponDeal if (owners.Any(o => WEAPON_DEAL_GANG_IDS.Contains(o))) // Gang WT { - VehicleItem item = new VehicleItem() { ItemId = 2, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG * oMembers }; //pistol50 + VehicleItem item = new VehicleItem() { ItemId = 2, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG_PISTOL50 * oMembers }; //pistol50 InventoryManager.AddItemToVehicleInventory(fVeh, item.ItemId, item.Amount); VehicleItem item3 = new VehicleItem() { ItemId = 9, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG * oMembers }; //PumpShotgun InventoryManager.AddItemToVehicleInventory(fVeh, item3.ItemId, item3.Amount); - VehicleItem item2 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG * oMembers }; //Schutzweste + VehicleItem item2 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG_ARMOR * oMembers }; //Schutzweste InventoryManager.AddItemToVehicleInventory(fVeh, item2.ItemId, item2.Amount); VehicleItem item4 = new VehicleItem() { ItemId = 7, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_GANG * oMembers }; //CompactRifle InventoryManager.AddItemToVehicleInventory(fVeh, item4.ItemId, item4.Amount); @@ -221,34 +226,34 @@ namespace ReallifeGamemode.Server.WeaponDeal } else if (owners.Contains(1)) // LSPD { - VehicleItem item = new VehicleItem() { ItemId = 1, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //pistol + VehicleItem item = new VehicleItem() { ItemId = 1, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_PISTOLS * oMembers }; //pistol InventoryManager.AddItemToVehicleInventory(fVeh, item.ItemId, item.Amount); - VehicleItem item2 = new VehicleItem() { ItemId = 2, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Pistol50 + VehicleItem item2 = new VehicleItem() { ItemId = 2, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_PISTOLS * oMembers }; //Pistol50 InventoryManager.AddItemToVehicleInventory(fVeh, item2.ItemId, item2.Amount); VehicleItem item3 = new VehicleItem() { ItemId = 5, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //SMG InventoryManager.AddItemToVehicleInventory(fVeh, item3.ItemId, item3.Amount); VehicleItem item4 = new VehicleItem() { ItemId = 9, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //PumpShotgun InventoryManager.AddItemToVehicleInventory(fVeh, item4.ItemId, item4.Amount); - VehicleItem item5 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Schutzweste + VehicleItem item5 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_ARMOR * oMembers }; //Schutzweste InventoryManager.AddItemToVehicleInventory(fVeh, item5.ItemId, item5.Amount); - VehicleItem item6 = new VehicleItem() { ItemId = 11, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_STUNGUN * oMembers }; //Stungun + VehicleItem item6 = new VehicleItem() { ItemId = 11, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Stungun InventoryManager.AddItemToVehicleInventory(fVeh, item6.ItemId, item6.Amount); - VehicleItem item7 = new VehicleItem() { ItemId = 14, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_STUNGUN * oMembers }; // AssaultSmg + VehicleItem item7 = new VehicleItem() { ItemId = 14, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; // AssaultSmg InventoryManager.AddItemToVehicleInventory(fVeh, item7.ItemId, item7.Amount); } else if (owners.Contains(3)) // FIB { - VehicleItem item = new VehicleItem() { ItemId = 3, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //pistol_mk2 + VehicleItem item = new VehicleItem() { ItemId = 3, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_PISTOLS * oMembers }; //pistol_mk2 InventoryManager.AddItemToVehicleInventory(fVeh, item.ItemId, item.Amount); - VehicleItem item2 = new VehicleItem() { ItemId = 4, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Combatpistol + VehicleItem item2 = new VehicleItem() { ItemId = 4, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_PISTOLS * oMembers }; //Combatpistol InventoryManager.AddItemToVehicleInventory(fVeh, item2.ItemId, item2.Amount); VehicleItem item3 = new VehicleItem() { ItemId = 6, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Carbinrifle InventoryManager.AddItemToVehicleInventory(fVeh, item3.ItemId, item3.Amount); - VehicleItem item4 = new VehicleItem() { ItemId = 8, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Sniperrifle + VehicleItem item4 = new VehicleItem() { ItemId = 8, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_SNIPER * oMembers }; //Sniperrifle InventoryManager.AddItemToVehicleInventory(fVeh, item4.ItemId, item4.Amount); - VehicleItem item5 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Schutzweste + VehicleItem item5 = new VehicleItem() { ItemId = 10, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_ARMOR * oMembers }; //Schutzweste InventoryManager.AddItemToVehicleInventory(fVeh, item5.ItemId, item5.Amount); - VehicleItem item6 = new VehicleItem() { ItemId = 11, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP_STUNGUN * oMembers }; //Stungun + VehicleItem item6 = new VehicleItem() { ItemId = 11, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //Stungun InventoryManager.AddItemToVehicleInventory(fVeh, item6.ItemId, item6.Amount); VehicleItem item7 = new VehicleItem() { ItemId = 12, VehicleId = factionVehicle.Id, Amount = WEAPON_AMOUNT_COP * oMembers }; //CombatPDW InventoryManager.AddItemToVehicleInventory(fVeh, item7.ItemId, item7.Amount); From a53b8fc57cb88d6619eb5f0f11695520d90f5174 Mon Sep 17 00:00:00 2001 From: Fabian Date: Sat, 15 May 2021 14:25:42 +0200 Subject: [PATCH 28/36] 50 wanteds bugg --- ReallifeGamemode.Server/Extensions/ClientExtension.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 2b57264b..c7af71aa 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -222,12 +222,13 @@ namespace ReallifeGamemode.Server.Extensions internal static void GiveWanteds(this User user, Player cop, int amount, string reason) { - if (user.Wanteds + amount > 50) + int newWanteds = user.Wanteds + amount; + if (newWanteds > 50) { ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten"); - return; + newWanteds = 50; } - int newWanteds = user.Wanteds + amount; + using (var dbContext = new DatabaseContext()) { User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault(); From 3b63ff9f325fef52d659adc4f7c52f21904d3d75 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 01:42:45 +0200 Subject: [PATCH 29/36] improve paycheck and weapondeal logs --- ReallifeGamemode.Server/Events/Key.cs | 8 ++++++++ ReallifeGamemode.Server/Finance/Economy.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 697b904a..bc347c28 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using GTANetworkAPI; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; @@ -19,6 +20,7 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.WeaponDeal; +using ReallifeGamemode.Server.Log; /** * @overview Life of German Reallife - Event Key (Key.cs) @@ -30,6 +32,8 @@ namespace ReallifeGamemode.Server.Events { public class Key : Script { + private static readonly ILogger logger = LogManager.GetLogger(); + #region User Key [RemoteEvent("keyPress:NUM2")] @@ -293,6 +297,8 @@ 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); + InventoryManager.AddItemToInventory(player, v.ItemId, itemToAdd); nearestBehindVehiclePoint.usePoint(player); dbContext.SaveChanges(); @@ -392,6 +398,8 @@ namespace ReallifeGamemode.Server.Events continue; } + logger.LogInformation("Player {0} put the weapon deal item \"{1}\" (amount: {2}) in weapon rack of faction {3}", player.Name, weapon.WeaponModel, item.Amount, user.FactionId); + weapon.Ammount += item.Amount; ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefügt."); unloadedWeaponPackage = true; diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index 90d204bc..860f3c05 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -166,7 +166,14 @@ namespace ReallifeGamemode.Server.Finance } } - logger.LogInformation("Player {0} has a payday of {1} dollars. old balance: {2}, new balance: {3}", client.Name, paycheck.Amount, u.BankAccount.Balance, u.BankAccount.Balance + paycheck.Amount); + logger.LogInformation("Player {0} has a payday of {1} dollars. old balance: {2}, new balance: {3}, wage: {4}, interest: {5}, other: {6}", + client.Name, + paycheck.Amount, + u.BankAccount.Balance, + u.BankAccount.Balance + paycheck.Amount, + paycheck.Wage, + paycheck.FinancialInterest, + paycheck.otheramount); u.BankAccount.Balance += paycheck.Amount; u.Wage = 0; From aa47430397f24dc182d45de0ecde65137055405b Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 01:55:53 +0200 Subject: [PATCH 30/36] Pilot: Fix Fahrzeug immer anmachen nach Ende --- ReallifeGamemode.Client/vehiclesync/vehiclesync.ts | 6 +++++- ReallifeGamemode.Server/Job/PilotJob.cs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts index 461ea0fd..2e349360 100644 --- a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts +++ b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts @@ -10,13 +10,17 @@ game.events.add('SERVER:Vehicle:UpdateData', (vehId, dataStr) => { setVehicleData(vehicle, data); }); +game.events.add("SERVER:Vehicle:SetDefaultEngineBehavior", () => { + mp.game.vehicle.defaultEngineBehaviour = false; +}); + game.events.onPlayerEnterVehicle((vehicle, seat) => { while (!game.players.local.inVehicle) { game.wait(0); } if (vehicle) { - var data: VehicleData = vehicle.getSharedData("VehicleData"); + var data: VehicleData = vehicle.getSharedData("VehicleData"); setVehicleData(vehicle, data); if (vehicle.class == 16) mp.game.vehicle.defaultEngineBehaviour = true; } diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs index cab36fea..03344205 100644 --- a/ReallifeGamemode.Server/Job/PilotJob.cs +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -152,6 +152,8 @@ namespace ReallifeGamemode.Server.Job private void _JobStop(Player player) { + player.TriggerEvent("SERVER:Vehicle:SetDefaultEngineBehavior"); + if (!playerVehiclePair.ContainsKey(player)) return; From c475a08d67709aca4efabadd800ff2e33ae5b47e Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 17 May 2021 23:07:09 +0200 Subject: [PATCH 31/36] rent stop not case sensitive --- ReallifeGamemode.Server/Commands/UserCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index ec9dfcd2..828ab72c 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -29,7 +29,7 @@ namespace ReallifeGamemode.Server.Commands { if (!player.IsLoggedIn()) return; - if (option != "stop") + if (option.ToLower() != "stop") { player.SendChatMessage("Mit \"/rent stop\" kannst du die Miete kündigen"); return; From a03a9749953241b3066a9671915cc9417abe59da Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 19:23:21 +0200 Subject: [PATCH 32/36] improve /giverank command --- .../Commands/FactionCommands.cs | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/FactionCommands.cs b/ReallifeGamemode.Server/Commands/FactionCommands.cs index 7dd4e5b7..5c3d8aff 100644 --- a/ReallifeGamemode.Server/Commands/FactionCommands.cs +++ b/ReallifeGamemode.Server/Commands/FactionCommands.cs @@ -237,7 +237,20 @@ namespace ReallifeGamemode.Server.Commands [Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)] public void CmdFactionGiverank(Player player, string name, string rank) { - if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false) + if (!player.IsLoggedIn()) + { + return; + } + + using var dbContext = new DatabaseContext(); + User user = player.GetUser(dbContext); + + if (user == null) + { + return; + } + + if (user.FactionId == null || !user.FactionLeader) { ChatService.NotAuthorized(player); return; @@ -250,28 +263,32 @@ namespace ReallifeGamemode.Server.Commands return; } - if (target.GetUser()?.FactionId != player.GetUser()?.FactionId) + User targetUser = target.GetUser(dbContext); + if (targetUser == null) + { + ChatService.PlayerNotFound(player); + return; + } + + if (targetUser.FactionId != user.FactionId) { ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion"); return; } - using (var dbContext = new DatabaseContext()) + FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.Order == int.Parse(rank) && r.FactionId == user.FactionId); + if (fr == null) { - FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.Order == int.Parse(rank) && r.FactionId == player.GetUser(dbContext).FactionId); - if (fr == null) - { - ChatService.ErrorMessage(player, "Dieser Rang existiert nicht"); - return; - } - - target.GetUser(dbContext).FactionRankId = fr.Id; - - ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " den Rang '" + fr.RankName + "' (" + fr.Order + ") gegeben."); - ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " den Rang '" + fr.RankName + "' (" + fr.Order + ")' erhalten."); - - dbContext.SaveChanges(); + ChatService.ErrorMessage(player, "Dieser Rang existiert nicht"); + return; } + + targetUser.FactionRankId = fr.Id; + + ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " den Rang '" + fr.RankName + "' (" + fr.Order + ") gegeben."); + ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " den Rang '" + fr.RankName + "' (" + fr.Order + ")' erhalten."); + + dbContext.SaveChanges(); } [Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)] From 5169aedcd6d1239f21c2061e6c8dc38b02382990 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 19:23:38 +0200 Subject: [PATCH 33/36] maybe fix aspeed second parameter --- ReallifeGamemode.Client/admin/aspeed.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/admin/aspeed.ts b/ReallifeGamemode.Client/admin/aspeed.ts index 4d0c919f..4871915c 100644 --- a/ReallifeGamemode.Client/admin/aspeed.ts +++ b/ReallifeGamemode.Client/admin/aspeed.ts @@ -10,9 +10,7 @@ export default function () { }); mp.events.addDataHandler("vehicleAdminSpeed2", (entity, newValue2) => { if (!entity.isAVehicle()) return; - //entity.setEngineTorqueMultiplier(newValue2); - TorqueEntity = entity; - TorqueValue = newValue2; + entity.setEngineTorqueMultiplier(newValue2); }); /*mp.events.add('render', () => { let vehicle = mp.players.local.vehicle; From baf977158cd1c486a389beba9e0349593b33af52 Mon Sep 17 00:00:00 2001 From: hydrant Date: Mon, 17 May 2021 23:14:51 +0200 Subject: [PATCH 34/36] adjust admincommands (method names, removed useless) --- .../Commands/AdminCommands.cs | 175 +++--------------- 1 file changed, 27 insertions(+), 148 deletions(-) diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index bdb0aa73..6ba6f34b 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -532,25 +532,6 @@ namespace ReallifeGamemode.Server.Commands } } - [Command("bitcoin", "~m~/bitcoin [ID]")] - public void CmdAdminBitcoin(Player player, string name) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - - Player target = PlayerService.GetPlayerByNameOrId(name); - if (target == null || !target.IsLoggedIn()) - { - ChatService.PlayerNotFound(player); - return; - } - - target.TriggerEvent("CLIENT:PlaySound", "fun/bitcoinnect", "mp3", 50); - } - #endregion Support #region Admin @@ -567,7 +548,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("remspawnschutz", "~m~Benutzung: ~s~/rmss [Target]", Alias = "rmss")] - public void CmdAdminRmss(Player player, String targetname) + public void CmdAdminRemSpawnSchutz(Player player, String targetname) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -620,7 +601,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("ac", "~m~Benutzung: ~s~/ac [Nachricht]", GreedyArg = true)] - public void CmdAdminA(Player player, string message) + public void CmdAdminChat(Player player, string message) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1062,110 +1043,8 @@ namespace ReallifeGamemode.Server.Commands } } - [Command("destroyped", "~m~Benutzung: ~s~/destroyped [PedNr]")] - public void CmdAdminAddPPed(Player player, int PedNr) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:DestroyPed", PedNr); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addpped", "~m~Benutzung: ~s~/addpped [PedNr] [model] [dimension] [Dynamic] [Freezed] [Collision(0-3)] [Weapon] [AttackProof] [Fire/Explosion-Proof] [DrownProof]")] - public void CmdAdminAddPPed(Player player, Array PedNr, string model, uint dimension = 0, bool dynamic = false, bool freeze = false, int collision = 0, string weapon = "none", bool attackproof = false, bool fireexplosionproof = false, bool drownproof = false) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:AddPed", PedNr, model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension, dynamic, freeze, collision, weapon, attackproof, fireexplosionproof, drownproof); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addmped", "~m~Benutzung: ~s~/addmped [model] [dimension]")] - public void CmdAdminAddMPed(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - player.TriggerEvent("CLIENT:AddPedModel", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - //NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - } - - [Command("addgped", "~m~Benutzung: ~s~/addgped")] - public void CmdAdminAddGPed(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - Ped Peter = NAPI.Ped.CreatePed(PedHash.Bankman, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), player.Heading, dimension); - - //Peter.freezePosition(true); - } - - [Command("addgpedmore", "~m~Benutzung: ~s~/addgpedMore")] - public void CmdAdminAddGPedMore(Player player, int model, uint dimension = 0) - { - if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) - { - ChatService.NotAuthorized(player); - return; - } - //player.TriggerEvent("CLIENT:AddPed", model, player.Position.X, player.Position.Y, player.Position.Z, player.Heading, dimension); - Ped Peter = NAPI.Ped.CreatePed(PedHash.ChickenHawk, new Vector3(player.Position.X + 1, player.Position.Y, player.Position.Z + 2), player.Heading, dimension); - Ped Peter2 = NAPI.Ped.CreatePed(PedHash.MovAlien01, new Vector3(player.Position.X + 2, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter3 = NAPI.Ped.CreatePed(PedHash.Chimp, new Vector3(player.Position.X + 3, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter4 = NAPI.Ped.CreatePed(PedHash.Boar, new Vector3(player.Position.X + 4, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter5 = NAPI.Ped.CreatePed(PedHash.BradCadaverCutscene, new Vector3(player.Position.X + 5, player.Position.Y, player.Position.Z + 2), player.Heading, dimension); - Ped Peter6 = NAPI.Ped.CreatePed(PedHash.Cat, new Vector3(player.Position.X - 1, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter7 = NAPI.Ped.CreatePed(PedHash.Chop, new Vector3(player.Position.X - 2, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter8 = NAPI.Ped.CreatePed(PedHash.Cormorant, new Vector3(player.Position.X - 3, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter9 = NAPI.Ped.CreatePed(PedHash.Cow, new Vector3(player.Position.X - 4, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter10 = NAPI.Ped.CreatePed(PedHash.Deer, new Vector3(player.Position.X - 5, player.Position.Y, player.Position.Z), player.Heading, dimension); - Ped Peter11 = NAPI.Ped.CreatePed(PedHash.Coyote, new Vector3(player.Position.X, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter12 = NAPI.Ped.CreatePed(PedHash.Crow, new Vector3(player.Position.X, player.Position.Y + 2, player.Position.Z + 2), player.Heading, dimension); - Ped Peter13 = NAPI.Ped.CreatePed(PedHash.Humpback, new Vector3(player.Position.X, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter14 = NAPI.Ped.CreatePed(PedHash.Husky, new Vector3(player.Position.X, player.Position.Y + 4, player.Position.Z), player.Heading, dimension); - Ped Peter15 = NAPI.Ped.CreatePed(PedHash.JohnnyKlebitz, new Vector3(player.Position.X, player.Position.Y + 5, player.Position.Z - 1), player.Heading, dimension); - Ped Peter16 = NAPI.Ped.CreatePed(PedHash.Pig, new Vector3(player.Position.X, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter17 = NAPI.Ped.CreatePed(PedHash.Pigeon, new Vector3(player.Position.X, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter18 = NAPI.Ped.CreatePed(PedHash.Poodle, new Vector3(player.Position.X, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter19 = NAPI.Ped.CreatePed(PedHash.Pug, new Vector3(player.Position.X, player.Position.Y - 4, player.Position.Z), player.Heading, dimension); - Ped Peter20 = NAPI.Ped.CreatePed(PedHash.Rabbit, new Vector3(player.Position.X, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter21 = NAPI.Ped.CreatePed(PedHash.Rat, new Vector3(player.Position.X + 1, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter22 = NAPI.Ped.CreatePed(PedHash.Retriever, new Vector3(player.Position.X + 2, player.Position.Y + 2, player.Position.Z), player.Heading, dimension); - Ped Peter23 = NAPI.Ped.CreatePed(PedHash.Rhesus, new Vector3(player.Position.X + 3, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter24 = NAPI.Ped.CreatePed(PedHash.Rottweiler, new Vector3(player.Position.X + 4, player.Position.Y + 4, player.Position.Z), player.Heading, dimension); - Ped Peter25 = NAPI.Ped.CreatePed(PedHash.Seagull, new Vector3(player.Position.X + 5, player.Position.Y + 5, player.Position.Z + 2), player.Heading, dimension); - Ped Peter26 = NAPI.Ped.CreatePed(PedHash.Shepherd, new Vector3(player.Position.X - 1, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter27 = NAPI.Ped.CreatePed(PedHash.Stingray, new Vector3(player.Position.X - 2, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter28 = NAPI.Ped.CreatePed(PedHash.Westy, new Vector3(player.Position.X - 3, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter29 = NAPI.Ped.CreatePed(PedHash.MountainLion, new Vector3(player.Position.X - 4, player.Position.Y - 4, player.Position.Z), player.Heading, dimension); - Ped Peter30 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 5, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter31 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 1, player.Position.Y - 3, player.Position.Z), player.Heading, dimension); - Ped Peter32 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X + 3, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - Ped Peter33 = NAPI.Ped.CreatePed(PedHash.FatCult01AFM, new Vector3(player.Position.X - 1, player.Position.Y + 3, player.Position.Z), player.Heading, dimension); - Ped Peter34 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X - 3, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter35 = NAPI.Ped.CreatePed(PedHash.Acult01AMM, new Vector3(player.Position.X + 5, player.Position.Y + 1, player.Position.Z), player.Heading, dimension); - Ped Peter36 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 1, player.Position.Y - 5, player.Position.Z), player.Heading, dimension); - Ped Peter37 = NAPI.Ped.CreatePed(PedHash.Acult01AMO, new Vector3(player.Position.X + 4, player.Position.Y - 2, player.Position.Z), player.Heading, dimension); - Ped Peter38 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 5, player.Position.Y + 2, player.Position.Z), player.Heading, dimension); - Ped Peter39 = NAPI.Ped.CreatePed(PedHash.Acult01AMY, new Vector3(player.Position.X - 4, player.Position.Y - 1, player.Position.Z), player.Heading, dimension); - - //Peter.freezePosition(true); - } - [Command("gotox", "~m~Benutzung: ~s~/gotox [X] [Y] [Z]")] - public void CmdAdminGotoxyz(Player player, float x, float y, float z) + public void CmdAdminGotox(Player player, float x, float y, float z) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1515,7 +1394,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("aclear", "~m~Benutzung: ~s~/aclear [Spieler] [Grund]", GreedyArg = true)] - public void CmdFactionClear(Player player, string nameOrId, string reason) + public void CmdAdminClear(Player player, string nameOrId, string reason) { User user = player.GetUser(); if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) @@ -1650,7 +1529,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("vcolor", "~m~Benutzung: ~s~/vcolor [Farb-ID1] [Farb-ID2]")] - public void CmdAdminColor(Player player, int color1, int color2) + public void CmdAdminVColor(Player player, int color1, int color2) { if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true) { @@ -1834,7 +1713,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setsvar", "~m~Benutzung:~s~ /setsvar [ID] [WERT]")] - public void CmdAdmSetSvar(Player player, int varId, int varValue) + public void CmdAdminSetSvar(Player player, int varId, int varValue) { if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true) { @@ -1845,7 +1724,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")] - public void CmdAdmCreateTurf(Player player, float option) + public void CmdAdminCreateTurf(Player player, float option) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1867,7 +1746,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")] - public void CmdAdmCancleTurf(Player player) + public void CmdAdminCancleTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1878,7 +1757,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")] - public void CmdAdmReloadTurf(Player player) + public void CmdAdminReloadTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1890,7 +1769,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")] - public void CmdAdmDeleteTurf(Player player) + public void CmdAdminDeleteTurf(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1901,7 +1780,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")] - public void CmdAdmSetTurfPoint(Player player) + public void CmdAdminSetTurfPoint(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -1943,7 +1822,7 @@ namespace ReallifeGamemode.Server.Commands } ChatService.SendMessage(target, "~r~WARNINFO: ~w~Dir wurde von " + adminPlayername + " ein Warn entfernt: " + reason); - ChatService.Broadcast("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " ein Warn entfernt: " + reason); + ChatService.BroadcastAdmin("~y~INFO: ~w~" + targetPlayername + " wurde von " + player.GetUser().AdminLevel.GetName() + " " + adminPlayername + " ein Warn entfernt: " + reason, AdminLevel.ADMIN); } [Command("setskill", "~m~Benutzung: ~s~/setskill [Playerid] [Bus/Pilot] [Menge]")] @@ -2124,7 +2003,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setweather", "~m~Benutzung: ~s~/setweather [Wetter]")] - public void CmdAdminSetweather(Player player, string weather) + public void CmdAdminSetWeather(Player player, string weather) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2174,7 +2053,7 @@ namespace ReallifeGamemode.Server.Commands [Command("showtuningmenu", "~m~Benutzung: ~s~/showtuningmenu", Alias = "stm")] - public void CmdAdminShowtuningmenu(Player player) + public void CmdAdminShowTuningMenu(Player player) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2244,14 +2123,14 @@ namespace ReallifeGamemode.Server.Commands [Command("wepmod", "~m~Benutzung: ~s~/wepmod [Variable]")] public void CmdWeaponModifier(Player player, float modifier) { - player.SendChatMessage("Modifier steht auf" + modifier); + player.SendChatMessage("Modifier steht auf " + modifier); player.TriggerEvent("SERVER:WeaponModifier2", player, modifier, 1); } [Command("wepmmod", "~m~Benutzung: ~s~/wepmmod [Variable]")] public void CmdWeaponMeeleModifier(Player player, float modifier) { - player.SendChatMessage("MeeleModifier steht auf" + modifier); + player.SendChatMessage("MeeleModifier steht auf " + modifier); player.TriggerEvent("SERVER:WeaponModifier2", player, 1, modifier); } @@ -2269,7 +2148,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("sethandmoney", "~m~Benutzung: ~s~/sethandmoney [Name/ID] [Menge]")] - public void CmdAdminSetUserHandMoney(Player admin, string targetname, int amount) + public void CmdAdminSetHandMoney(Player admin, string targetname, int amount) { if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2296,7 +2175,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("givehandmoney", "~m~Benutzung: ~s~/givehandmoney [Name/ID] [Menge]")] - public void CmdAdminGiveUserHandMoney(Player admin, string targetname, int amount) + public void CmdAdminGiveHandMoney(Player admin, string targetname, int amount) { if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2323,7 +2202,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]: ~g~blip, ~g~atm")] - public void CmdAdminSetQuickSaveMode(Player player, string mode) + public void CmdAdminQuickSaveMode(Player player, string mode) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2373,7 +2252,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setshopitem", "~m~Benutzung: ~s~/setshopitem [Item ID]")] - public void CmdAdminSetItemInShop(Player player, int itemId) + public void CmdAdminSetShopItem(Player player, int itemId) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -2419,7 +2298,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("rmshopitem", "~m~Benutzung: ~s~/rmshopitem [Item ID]")] - public void CmdAdminRemoveItemInShop(Player player, int itemId) + public void CmdAdminRmShopItem(Player player, int itemId) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3228,7 +3107,7 @@ namespace ReallifeGamemode.Server.Commands // [Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]", Alias = "mfr")] - public void CmdFactionManageFactionRanks(Player player, int factionID) + public void CmdAdminManageFactionRanks(Player player, int factionID) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3342,7 +3221,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setmoney", "~m~Benutzung: ~s~/setmoney [Name] [Menge]")] - public void SetPlayerMoney(Player player, string receiver, int amount) + public void CmdAdminSetMoney(Player player, string receiver, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3367,7 +3246,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("givemoney", "~m~Benutzung: ~s~/givemoney [Name] [Menge]")] - public void GivePlayerMoney(Player player, string receiver, int amount) + public void GiveAdminGiveMoney(Player player, string receiver, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3393,7 +3272,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setbusinessowner", "~m~Benutzung: ~s~/setbusinessowner [Name] [Business ID]")] - public void CmdAdminSetbusinessowner(Player player, string name, int businessid) + public void CmdAdminSetBusinessOwner(Player player, string name, int businessid) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -3474,7 +3353,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("setbusinessbankbalance", "~m~Benutzung: ~s~/setbusinessbankbalance [Business ID] [Menge]")] - public void CmdAdminGivebusinessbankbalance(Player player, int businessid, int amount) + public void CmdAdminSetBusinessBankBalance(Player player, int businessid, int amount) { if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true) { @@ -4006,7 +3885,7 @@ namespace ReallifeGamemode.Server.Commands } [Command("blind", "~m~Benutzung: ~s~/blind [Spieler] [Mode]")] - public void CmdBlind(Player player, string name, int mode) + public void CmdAdminBlind(Player player, string name, int mode) { if (!player.IsLoggedIn()) return; From bbab2f71fcd5584999a33c06cbfb630cfb43186b Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 17 May 2021 23:19:01 +0200 Subject: [PATCH 35/36] neues rentcar drinne --- ReallifeGamemode.Server/Util/Rentcar.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReallifeGamemode.Server/Util/Rentcar.cs b/ReallifeGamemode.Server/Util/Rentcar.cs index b5828f64..a286f44b 100644 --- a/ReallifeGamemode.Server/Util/Rentcar.cs +++ b/ReallifeGamemode.Server/Util/Rentcar.cs @@ -52,18 +52,23 @@ namespace ReallifeGamemode.Server.Util { noobspawnVehicleProperties.Add(new RentcarProperty("bmx", 10)); noobspawnVehicleProperties.Add(new RentcarProperty("faggio3", 50)); + noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); stadthalleVehicleProperties.Add(new RentcarProperty("bmx", 10)); stadthalleVehicleProperties.Add(new RentcarProperty("faggio3", 50)); + noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); knastVehicleProperties.Add(new RentcarProperty("bmx", 10)); knastVehicleProperties.Add(new RentcarProperty("faggio3", 50)); + noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); paletoVehicleProperties.Add(new RentcarProperty("bmx", 10)); paletoVehicleProperties.Add(new RentcarProperty("faggio3", 50)); + noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); lamesaVehicleProperties.Add(new RentcarProperty("bmx", 10)); lamesaVehicleProperties.Add(new RentcarProperty("faggio3", 50)); + noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); } public static void cancelRent(Player player) From 6a63653889dba21fed84d75dad94c17694ccee4d Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 17 May 2021 23:20:45 +0200 Subject: [PATCH 36/36] shame on me --- ReallifeGamemode.Server/Util/Rentcar.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReallifeGamemode.Server/Util/Rentcar.cs b/ReallifeGamemode.Server/Util/Rentcar.cs index a286f44b..d98c201d 100644 --- a/ReallifeGamemode.Server/Util/Rentcar.cs +++ b/ReallifeGamemode.Server/Util/Rentcar.cs @@ -56,19 +56,19 @@ namespace ReallifeGamemode.Server.Util stadthalleVehicleProperties.Add(new RentcarProperty("bmx", 10)); stadthalleVehicleProperties.Add(new RentcarProperty("faggio3", 50)); - noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); + stadthalleVehicleProperties.Add(new RentcarProperty("panto", 200)); knastVehicleProperties.Add(new RentcarProperty("bmx", 10)); knastVehicleProperties.Add(new RentcarProperty("faggio3", 50)); - noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); + knastVehicleProperties.Add(new RentcarProperty("panto", 200)); paletoVehicleProperties.Add(new RentcarProperty("bmx", 10)); paletoVehicleProperties.Add(new RentcarProperty("faggio3", 50)); - noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); + paletoVehicleProperties.Add(new RentcarProperty("panto", 200)); lamesaVehicleProperties.Add(new RentcarProperty("bmx", 10)); lamesaVehicleProperties.Add(new RentcarProperty("faggio3", 50)); - noobspawnVehicleProperties.Add(new RentcarProperty("panto", 200)); + lamesaVehicleProperties.Add(new RentcarProperty("panto", 200)); } public static void cancelRent(Player player)