GELD LOGS

(cherry picked from commit a2db770316)
This commit is contained in:
hydrant
2021-05-15 03:14:37 +02:00
parent 3c63002c03
commit 7411fa02f3
22 changed files with 448 additions and 306 deletions

View File

@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Core.Extensions;
using System.Linq; using System.Linq;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Common; using ReallifeGamemode.Server.Common;
using Microsoft.Extensions.Logging;
namespace ReallifeGamemode.Server.Core.Managers namespace ReallifeGamemode.Server.Core.Managers
{ {
@@ -451,6 +452,8 @@ namespace ReallifeGamemode.Server.Core.Managers
return; return;
} }
Log.LogInformation("Player {0} did a withdraw of {1} dollars from house {2}", player.Name, amount, house.Id);
user.BankAccount.Balance += amount; user.BankAccount.Balance += amount;
house.BankAccount.Balance -= amount; house.BankAccount.Balance -= amount;

View File

@@ -6,12 +6,13 @@ using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Core.Extensions; using ReallifeGamemode.Server.Core.Extensions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Linq; using System.Linq;
using Microsoft.Extensions.Logging;
namespace ReallifeGamemode.Server.Core.Menus namespace ReallifeGamemode.Server.Core.Menus
{ {
internal class PoliceDepartment : Script internal class PoliceDepartment : Script
{ {
private const int WEAPONLICENSE_PRICE = 5000;
public PoliceDepartment() public PoliceDepartment()
{ {
@@ -40,13 +41,15 @@ namespace ReallifeGamemode.Server.Core.Menus
var account = user.BankAccount; 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); player.SendMessage("Du hast nicht genug Geld auf der Bank (5.000$)!", ChatPrefix.Error);
return; 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); player.SendMessage("Du hast den Waffenschein erfolgreich erworben.", ChatPrefix.Info);

View File

@@ -4,18 +4,20 @@
* @copyright (c) 2008 - 2021 Life of German * @copyright (c) 2008 - 2021 Life of German
*/ */
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using System; using System;
namespace ReallifeGamemode.Server.Bank namespace ReallifeGamemode.Server.Bank
{ {
class bank : Script class Bank : Script
{ {
private static TextLabel informationLabel; private static TextLabel informationLabel;
private static TextLabel factionInformationLabel; private static TextLabel factionInformationLabel;
@@ -25,6 +27,7 @@ namespace ReallifeGamemode.Server.Bank
private static ColShape _factioncolShape; private static ColShape _factioncolShape;
public static Vector3 Position { get; } public static Vector3 Position { get; }
private static readonly ILogger logger = LogManager.GetLogger<Bank>();
public static void Setup() public static void Setup()
{ {
@@ -58,7 +61,7 @@ namespace ReallifeGamemode.Server.Bank
} }
private static void EntityEnterFactionBankColShape(ColShape colShape, Player client) private static void EntityEnterFactionBankColShape(ColShape colShape, Player client)
{ {
if (client.IsInVehicle || !client.IsLoggedIn() || client.GetUser().FactionId is null) return; if (client.IsInVehicle || !client.IsLoggedIn() || client.GetUser().FactionId is null) return;
User user = client.GetUser(); User user = client.GetUser();
@@ -92,6 +95,7 @@ namespace ReallifeGamemode.Server.Bank
} }
else 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.SendNotification($"~w~Du hast $~g~{amount} ~w~eingezahlt.");
player.GetUser(dbContext).Handmoney -= amount; player.GetUser(dbContext).Handmoney -= amount;
player.GetUser(dbContext).BankAccount.Balance += amount; player.GetUser(dbContext).BankAccount.Balance += amount;
@@ -115,6 +119,7 @@ namespace ReallifeGamemode.Server.Bank
} }
else 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.SendNotification($"~w~Du hast $~g~{amount} ~w~abgehoben.");
player.GetUser(dbContext).Handmoney += amount; player.GetUser(dbContext).Handmoney += amount;
player.GetUser(dbContext).BankAccount.Balance -= amount; player.GetUser(dbContext).BankAccount.Balance -= amount;
@@ -130,34 +135,40 @@ namespace ReallifeGamemode.Server.Bank
int amount = Int32.Parse(stringAmount); int amount = Int32.Parse(stringAmount);
Player target = PlayerService.GetPlayerByNameOrId(nameOrId); Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
if (!target.IsLoggedIn())
{
player.SendNotification($"~r~Dieser Spieler ist nicht Online.");
return;
}
using (var dbContext = new DatabaseContext()) 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"); player.SendNotification("~r~Du kannst Geld erst ab 3 Spielstunden vergeben");
return; 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."); player.SendNotification($"~r~Du kannst dir selber kein Geld überweisen.");
return; return;
} }
else if (!target.IsLoggedIn()) else if (amount <= 0 || (int)(amount * 1.05) > user.BankAccount.Balance)
{
player.SendNotification($"~r~Dieser Spieler ist nicht Online.");
}
else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).BankAccount.Balance)
{ {
player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden.");
return; return;
} }
else 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."); player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen.");
target.SendNotification($"~w~{player.Name} hat dir $~g~{amount} ~w~Überwiesen."); target.SendNotification($"~w~{player.Name} hat dir $~g~{amount} ~w~Überwiesen.");
player.GetUser(dbContext).BankAccount.Balance -= (int)(amount * 1.05); user.BankAccount.Balance -= (int)(amount * 1.05);
target.GetUser(dbContext).otheramount += amount; targetUser.otheramount += amount;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
} }
@@ -170,17 +181,23 @@ namespace ReallifeGamemode.Server.Bank
using (var dbContext = new DatabaseContext()) 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."); player.SendNotification($"~r~Dieser Betrag ist ungültig.");
return; return;
} }
else 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.SendNotification($"~w~Du hast $~g~{amount}~w~ in die Fraktionskasse eingezahlt.");
player.GetUser(dbContext).BankAccount.Balance -= amount; user.BankAccount.Balance -= amount;
player.GetUser(dbContext).Faction.BankAccount.Balance += amount; user.Faction.BankAccount.Balance += amount;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
} }
@@ -193,23 +210,28 @@ namespace ReallifeGamemode.Server.Bank
int amount = Int32.Parse(stringAmount); int amount = Int32.Parse(stringAmount);
Player target = PlayerService.GetPlayerByNameOrId(nameOrId); Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
if (!target.IsLoggedIn())
{
player.SendNotification($"~r~Dieser Spieler ist nicht Online.");
return;
}
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
if (!target.IsLoggedIn()) User user = player.GetUser(dbContext);
{ User targetUser = target.GetUser(dbContext);
player.SendNotification($"~r~Dieser Spieler ist nicht Online."); if (amount <= 0 || (int)(amount * 1.05) > user.Faction.BankAccount.Balance)
}
else if (amount <= 0 || (int)(amount * 1.05) > player.GetUser(dbContext).Faction.BankAccount.Balance)
{ {
player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden."); player.SendNotification($"~r~Dieser Betrag kann nicht überwiesen werden.");
return; return;
} }
else else
{ {
player.SendNotification($"~w~Du hast {target.Name} $~g~{amount} ~w~Überwiesen."); logger.LogInformation("Player {0} did a faction transfer of {1} dollars from faction {2} to {3}", user.Name, amount, user.Faction.Id, target);
player.GetUser(dbContext).Faction.BankAccount.Balance -= (int)(amount * 1.05); player.SendNotification($"Du hast ~g~{amount.ToMoneyString()}~s~ an ~y~{targetUser.Name}~s~ überwiesen");
target.GetUser(dbContext).otheramount += amount; 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(); dbContext.SaveChanges();
} }
} }

View File

@@ -2287,6 +2287,7 @@ namespace ReallifeGamemode.Server.Commands
{ {
var user = target.GetUser(context); var user = target.GetUser(context);
user.Handmoney = amount; user.Handmoney = amount;
logger.LogInformation("Admin {0} set the handmoney of player {1} to {2} dollars", admin.Name, target.Name, amount);
context.SaveChanges(); context.SaveChanges();
//target.TriggerEvent("SERVER:SET_HANDMONEY", amount); //target.TriggerEvent("SERVER:SET_HANDMONEY", amount);
} }
@@ -2313,6 +2314,7 @@ namespace ReallifeGamemode.Server.Commands
{ {
var user = target.GetUser(context); var user = target.GetUser(context);
user.Handmoney += amount; user.Handmoney += amount;
logger.LogInformation("Admin {0} added {2} dollarsto the handmoney of player {1}", admin.Name, target.Name, amount);
context.SaveChanges(); context.SaveChanges();
//target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); //target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
} }
@@ -3356,6 +3358,7 @@ namespace ReallifeGamemode.Server.Commands
using (var dbContext = new DatabaseContext()) 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; target.GetUser(dbContext).BankAccount.Balance = amount;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
@@ -3381,6 +3384,7 @@ namespace ReallifeGamemode.Server.Commands
using (var dbContext = new DatabaseContext()) 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; target.GetUser(dbContext).BankAccount.Balance += amount;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }

View File

@@ -1,9 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Entities.Logs.Chat; using ReallifeGamemode.Database.Entities.Logs.Chat;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
@@ -15,6 +16,7 @@ using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Log;
/** /**
* @overview Life of German Reallife - Faction Commands (Faction.cs) * @overview Life of German Reallife - Faction Commands (Faction.cs)
@@ -26,6 +28,8 @@ namespace ReallifeGamemode.Server.Commands
{ {
internal class FactionCommands : Script internal class FactionCommands : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<FactionCommands>();
#region Chat Commands #region Chat Commands
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)] [Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
@@ -413,17 +417,19 @@ namespace ReallifeGamemode.Server.Commands
return; return;
} }
if (deadPlayerUser.Handmoney >= 100) if (deadPlayerUser.Handmoney >= Medic.ReviveIncome)
{ {
deadPlayerUser.Handmoney -= 100; deadPlayerUser.Handmoney -= Medic.ReviveIncome;
} }
else else
{ {
int bankMoney = 100 - deadPlayerUser.Handmoney; int bankMoney = Medic.ReviveIncome - deadPlayerUser.Handmoney;
deadPlayerUser.Handmoney = 0; deadPlayerUser.Handmoney = 0;
deadPlayerUser.BankAccount.Balance -= bankMoney; 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); player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
deadPlayer.TriggerEvent("onPlayerRevived"); deadPlayer.TriggerEvent("onPlayerRevived");

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
@@ -13,11 +14,16 @@ using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.Commands namespace ReallifeGamemode.Server.Commands
{ {
internal class UserCommands : Script internal class UserCommands : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<UserCommands>();
private const int SMS_PRICE = 5;
[Command("rent", "~m~rent stop")] [Command("rent", "~m~rent stop")]
public void CmdUserStopRent(Player player, String option = "") public void CmdUserStopRent(Player player, String option = "")
{ {
@@ -113,13 +119,15 @@ namespace ReallifeGamemode.Server.Commands
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User user = player.GetUser(dbContext); 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"); ChatService.ErrorMessage(player, "Dafür hast du nicht genug Geld auf deinem Bankkonto");
return; 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(); dbContext.SaveChanges();
} }

View File

@@ -6,17 +6,24 @@ using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using System; using System;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.DrivingSchool namespace ReallifeGamemode.Server.DrivingSchool
{ {
internal class DrivingSchool : Script internal class DrivingSchool : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<DrivingSchool>();
private static TextLabel informationLabel; private static TextLabel informationLabel;
private static Marker marker; private static Marker marker;
private static ColShape _colShape; private static ColShape _colShape;
public static Vector3 Position { get; } public static Vector3 Position { get; }
private const int FAILPOINTS = 2; private const int FAILPOINTS = 2;
private const int CAR_LICENSE_PRICE = 2500;
private const int BIKE_LICENSE_PRICE = 3500;
private readonly IReadOnlyCollection<Vector3> BikeRoute = new List<Vector3> private readonly IReadOnlyCollection<Vector3> BikeRoute = new List<Vector3>
{ {
new Vector3(-741.98, -1283.46, 6.17), new Vector3(-741.98, -1283.46, 6.17),
@@ -122,14 +129,14 @@ namespace ReallifeGamemode.Server.DrivingSchool
public void StartDrivingSchool(Player client) public void StartDrivingSchool(Player client)
{ {
User user = client.GetUser(); User user = client.GetUser();
if (user.DriverLicenseVehicle || client.HasData("ActiveSchool")) if (user.DriverLicenseVehicle || client.HasData("ActiveSchool"))
{ {
client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Führerschein."); client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Führerschein.");
return; 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); client.SendNotification("~r~[FEHLER]~s~ Du hast nicht genug Geld auf der Hand($2.500)!", true);
return; return;
@@ -138,7 +145,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User payer = client.GetUser(dbContext); 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); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
@@ -174,8 +182,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
[RemoteEvent("drivingSchoolEventEnd")] [RemoteEvent("drivingSchoolEventEnd")]
public void DrivingSchoolEventEnd(Player user, int checkpoint) public void DrivingSchoolEventEnd(Player user, int checkpoint)
{ {
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User drivingUser = user.GetUser(dbContext); User drivingUser = user.GetUser(dbContext);
if (drivingUser.failpoints > FAILPOINTS) if (drivingUser.failpoints > FAILPOINTS)
@@ -186,13 +194,13 @@ namespace ReallifeGamemode.Server.DrivingSchool
else else
{ {
user.TriggerEvent("renderTextOnScreen", "Du hast den Führerschein bestanden. Glückwunsch!"); user.TriggerEvent("renderTextOnScreen", "Du hast den Führerschein bestanden. Glückwunsch!");
user.ResetData("ActiveSchool"); user.ResetData("ActiveSchool");
drivingUser.DriverLicenseVehicle = true; drivingUser.DriverLicenseVehicle = true;
drivingUser.failpoints = 0; drivingUser.failpoints = 0;
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
} }
Vehicle veh = user.Vehicle; Vehicle veh = user.Vehicle;
user.WarpOutOfVehicle(); user.WarpOutOfVehicle();
ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh); ServerVehicle sVeh = VehicleManager.GetServerVehicleFromVehicle(veh);
@@ -208,31 +216,31 @@ namespace ReallifeGamemode.Server.DrivingSchool
[RemoteEvent("drivingSchoolEvent")] [RemoteEvent("drivingSchoolEvent")]
public void DrivingSchoolEvent(Player user, int checkpoint) public void DrivingSchoolEvent(Player user, int checkpoint)
{ {
/* for (int i = 0; i >= 33; i++) /* for (int i = 0; i >= 33; i++)
{ {
if (checkpoint <= 24) if (checkpoint <= 24)
{ {
user.TriggerEvent("kmh100"); user.TriggerEvent("kmh100");
} }
else if (checkpoint >= 25 && checkpoint <= 26) else if (checkpoint >= 25 && checkpoint <= 26)
{ {
user.TriggerEvent("kmh150"); user.TriggerEvent("kmh150");
} }
else if (checkpoint >= 26 && checkpoint <= 28) else if (checkpoint >= 26 && checkpoint <= 28)
{ {
user.TriggerEvent("kmh100"); user.TriggerEvent("kmh100");
} }
else if (checkpoint >= 29 && checkpoint <= 31) else if (checkpoint >= 29 && checkpoint <= 31)
{ {
user.TriggerEvent("kmh150"); user.TriggerEvent("kmh150");
} }
else if (checkpoint >= 32 && checkpoint <= 33) else if (checkpoint >= 32 && checkpoint <= 33)
{ {
user.TriggerEvent("kmh100"); user.TriggerEvent("kmh100");
} }
} }
*/ */
switch(checkpoint) switch (checkpoint)
{ {
case 25: case 25:
case 26: case 26:
@@ -275,7 +283,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Motorradschein."); client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Motorradschein.");
return; 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); client.SendNotification("~r~[FEHLER]~s~Du hast nicht genug Geld auf der Hand($3.500)!", true);
return; return;
@@ -284,7 +292,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User payer = client.GetUser(dbContext); 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); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
dbContext.SaveChanges(); dbContext.SaveChanges();
} }

View File

@@ -1,8 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
@@ -15,8 +17,12 @@ namespace ReallifeGamemode.Server.DrivingSchool
private static ColShape _colShape1; private static ColShape _colShape1;
public static Vector3 Position { get; } public static Vector3 Position { get; }
private static readonly ILogger logger = LogManager.GetLogger<PlaneSchool>();
private const int CHECKPOINT_MARKER_ID = 6; private const int CHECKPOINT_MARKER_ID = 6;
private const int PLANE_LICENSE_PRICE = 5000;
private readonly IReadOnlyCollection<Vector3> planeRoute = new List<Vector3> private readonly IReadOnlyCollection<Vector3> planeRoute = new List<Vector3>
{ {
new Vector3(-1114.39, -2333.09, 14.87), 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."); client.SendChatMessage("~b~[INFO]~s~ Du besitzt schon einen Flugschein.");
return; 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); client.SendNotification("~r~Du brauchst ~g~$5.000~r~ auf der Hand, um die Prüfung starten zu können.", true);
return; return;
@@ -82,7 +88,8 @@ namespace ReallifeGamemode.Server.DrivingSchool
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
User payer = client.GetUser(dbContext); 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); //client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
@@ -171,7 +178,7 @@ namespace ReallifeGamemode.Server.DrivingSchool
case 14: case 14:
user.TriggerEvent("renderTextOnScreen", "Setzen Sie zum Landeanflug an. Drücken Sie 'G', um das Fahrwerk auszufahren."); 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; break;
} }
} }

View File

@@ -6,11 +6,15 @@ using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using System; using System;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.Events namespace ReallifeGamemode.Server.Events
{ {
public class UpdateCharacterCloth : Script public class UpdateCharacterCloth : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<UpdateCharacterCloth>();
[RemoteEvent("updateDutyProp")] [RemoteEvent("updateDutyProp")]
public void UpdateDutyProp(Player player, int componentId, int componentVariation) 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); User payer = client.GetUser(dbContext);
payer.GetCharacter(dbContext); payer.GetCharacter(dbContext);
payer.Character.Hair = Convert.ToByte(data[2]); payer.Character.Hair = Convert.ToByte(data[2]);
@@ -288,13 +293,14 @@ namespace ReallifeGamemode.Server.Events
} }
client.GetUser(dbContext).Handmoney -= data[6]; 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(); dbContext.SaveChanges();
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
} }
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
} }
} }
[RemoteEvent("SERVER:BuyHairColor")] [RemoteEvent("SERVER:BuyHairColor")]
public void BuyHairColor(Player client, byte HairColor) public void BuyHairColor(Player client, byte HairColor)
@@ -332,7 +338,7 @@ namespace ReallifeGamemode.Server.Events
User payer = client.GetUser(dbContext); User payer = client.GetUser(dbContext);
payer.GetCharacter(dbContext); payer.GetCharacter(dbContext);
payer.Handmoney -= 50; payer.Handmoney -= 50;
payer.Character.HairHighlightColor = HairlightColor; payer.Character.HairHighlightColor = HairlightColor;
// client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney); // client.TriggerEvent("SERVER:SET_HANDMONEY", payer.Handmoney);
dbContext.SaveChanges(); dbContext.SaveChanges();
} }

View File

@@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server.Events
player.SendNotification("Du hast nicht genügend Geld bei dir"); player.SendNotification("Du hast nicht genügend Geld bei dir");
return; 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; user.Handmoney -= price;
dbContext.SaveChanges(); dbContext.SaveChanges();
player.GiveWeapon(NAPI.Util.WeaponNameToModel(weaponmodel), ammo); player.GiveWeapon(NAPI.Util.WeaponNameToModel(weaponmodel), ammo);

View File

@@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Admin; using ReallifeGamemode.Server.Admin;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
@@ -22,6 +24,8 @@ namespace ReallifeGamemode.Server.Extensions
{ {
public static class PlayerExtension public static class PlayerExtension
{ {
private static ILogger Logger => LogManager.GetLogger(typeof(PlayerExtension));
/// <summary> /// <summary>
/// Gibt das User-Objekt eines Player's zurück. /// Gibt das User-Objekt eines Player's zurück.
/// Gibt nichts zurück, wenn der Player nicht eingeloggt ist /// Gibt nichts zurück, wenn der Player nicht eingeloggt ist
@@ -108,6 +112,8 @@ namespace ReallifeGamemode.Server.Extensions
faction.BankAccount.Balance += factionMoney; 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.Wanteds = 0;
user.JailTime = time; user.JailTime = time;
} }

View File

@@ -9,6 +9,8 @@ using ReallifeGamemode.Database.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
/** /**
* @overview Life of German Reallife - Server Factions Medic Medic.cs * @overview Life of German Reallife - Server Factions Medic Medic.cs
@@ -20,6 +22,8 @@ namespace ReallifeGamemode.Server.Factions.Medic
{ {
public class Medic : Script public class Medic : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<Medic>();
public static List<MedicTask> ReviveTasks = new List<MedicTask>(); public static List<MedicTask> ReviveTasks = new List<MedicTask>();
public static List<MedicTask> HealTasks = new List<MedicTask>(); public static List<MedicTask> HealTasks = new List<MedicTask>();
public static List<MedicTask> FireTasks = new List<MedicTask>(); public static List<MedicTask> FireTasks = new List<MedicTask>();
@@ -34,7 +38,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public Player dTarget; public Player dTarget;
public int dPrice; public int dPrice;
} }
public static void AddTaskToList(MedicTask task) public static void AddTaskToList(MedicTask task)
{ {
if (task == null) if (task == null)
@@ -84,7 +88,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void UpdateReviveSperre() public static void UpdateReviveSperre()
{ {
var allRevivedPlayers = NAPI.Pools.GetAllPlayers().Where(c => c.HasData("reviveSperre")); var allRevivedPlayers = NAPI.Pools.GetAllPlayers().Where(c => c.HasData("reviveSperre"));
foreach(var player in allRevivedPlayers) foreach (var player in allRevivedPlayers)
{ {
var timeLeft = player.GetData<int>("reviveSperre"); var timeLeft = player.GetData<int>("reviveSperre");
@@ -101,7 +105,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void CheckHealDecisionDistance() 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) 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) public static void MakeHealDecision(Player target, bool decision)
{ {
var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target); 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); activeDecision.dTarget.SendNotification("Du hast den Heal ~r~abgelehnt", false);
} }
else else
@@ -141,6 +145,8 @@ namespace ReallifeGamemode.Server.Factions.Medic
targetUser.BankAccount.Balance -= bankMoney; 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; 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; activeDecision.dMedic.GetUser(dbContext).Wage += activeDecision.dPrice / 2;
@@ -149,7 +155,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
activeDecision.dTarget.SafeSetHealth(100); activeDecision.dTarget.SafeSetHealth(100);
activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false); 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); 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); 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)); var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime));
task.TimeLeft = taskTimeLeft; task.TimeLeft = taskTimeLeft;
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName); 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) 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 medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
var victim = PlayerService.GetPlayerByNameOrId(task.Victim); var victim = PlayerService.GetPlayerByNameOrId(task.Victim);
if(medic == null || victim == null) if (medic == null || victim == null)
{ {
continue; continue;
} }
@@ -241,11 +247,11 @@ namespace ReallifeGamemode.Server.Factions.Medic
{ {
reviveTask.MedicName = "none"; reviveTask.MedicName = "none";
} }
else else
{ {
reviveTask.MedicName = player.Name; reviveTask.MedicName = player.Name;
} }
ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Reviveauftrag von " + victim + " angenommen.", new List<int>() { 2 }); ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Reviveauftrag von " + victim + " angenommen.", new List<int>() { 2 });
target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ eilt zur Rettung."); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ eilt zur Rettung.");
break; break;
@@ -261,7 +267,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
healTask.MedicName = player.Name; healTask.MedicName = player.Name;
ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Healauftrag von " + victim + " angenommen.", new List<int>() { 2 }); ChatService.BroadcastFaction("~y~[MEDIC] ~w~" + player.Name + " hat den Healauftrag von " + victim + " angenommen.", new List<int>() { 2 });
target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ hat deinen Auftrag angenommen."); target.SendNotification("~w~Sanitäter~g~ " + player.Name + "~w~ hat deinen Auftrag angenommen.");
} }
break; break;
case 2: case 2:
@@ -275,7 +281,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
{ {
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name); MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name);
if (task != null) if (task != null)
{ {
player.SetData("healauftrag", false); player.SetData("healauftrag", false);
var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName); var medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName);
if (medicPlayer != null) if (medicPlayer != null)

View File

@@ -9,9 +9,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Server.Wanted;
@@ -19,6 +21,8 @@ namespace ReallifeGamemode.Server.Finance
{ {
public class Economy public class Economy
{ {
private static readonly ILogger logger = LogManager.GetLogger<Economy>();
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>(); public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
public static (int, float, float) GetEconomyClass(Player client, int wage) 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.BankAccount.Balance += paycheck.Amount;
u.Wage = 0; u.Wage = 0;
u.otheramount = 0; u.otheramount = 0;
@@ -173,7 +179,7 @@ namespace ReallifeGamemode.Server.Finance
.Where(hR => hR.UserId == u.Id); .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); 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()) if (rentals.Any())
{ {
foreach (var rental in rentals) foreach (var rental in rentals)
@@ -181,6 +187,7 @@ namespace ReallifeGamemode.Server.Finance
if (rental?.House?.BankAccount != null) if (rental?.House?.BankAccount != null)
{ {
rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); 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);
} }
} }
} }

View File

@@ -5,16 +5,20 @@ using System.Threading.Tasks;
using System.Timers; using System.Timers;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
namespace ReallifeGamemode.Server.Gangwar namespace ReallifeGamemode.Server.Gangwar
{ {
public class Turf public class Turf
{ {
private static readonly ILogger logger = LogManager.GetLogger<Turf>();
public int TurfID { get; set; } public int TurfID { get; set; }
public string TurfName { get; set; } public string TurfName { get; set; }
public int Color { get; set; } public int Color { get; set; }
@@ -203,7 +207,7 @@ namespace ReallifeGamemode.Server.Gangwar
public void enter(Player client) public void enter(Player client)
{ {
User user = client.GetUser(); User user = client.GetUser();
if(user == null || user.FactionId == null) if (user == null || user.FactionId == null)
{ {
return; return;
} }
@@ -276,6 +280,7 @@ namespace ReallifeGamemode.Server.Gangwar
a.TriggerEvent("CLIENT:loose"); a.TriggerEvent("CLIENT:loose");
} }
ownerFaction.BankAccount.Balance += 15000; 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) else if (getOwner() != FactionName)
{ {
@@ -292,6 +297,7 @@ namespace ReallifeGamemode.Server.Gangwar
if (a != null) if (a != null)
a.TriggerEvent("CLIENT:win"); 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; this.Owner = FactionName;
attackerFaction.BankAccount.Balance += 10000; attackerFaction.BankAccount.Balance += 10000;
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
@@ -379,7 +385,7 @@ namespace ReallifeGamemode.Server.Gangwar
{ {
if (getOwner() == FactionName) if (getOwner() == FactionName)
{ {
NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}"); NAPI.Util.ConsoleOutput($"GangwarKill - Adding Point for Faction {getAttacker()}");
Att_Score += 1; Att_Score += 1;
} }
else if (getAttacker() == FactionName) else if (getAttacker() == FactionName)

View File

@@ -29,212 +29,212 @@ using System.IO;
namespace ReallifeGamemode.Server 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()
{ {
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 static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
public void OnResourceStart()
{ private Core.Events.EventHandler eventHandler;
try
{ private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX");
if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true")
public Main()
{ {
using var dbContext = new DatabaseContext(true); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
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() [ServerEvent(Event.ResourceStart)]
.GetTypes() public void OnResourceStart()
.SelectMany(t => t.GetMethods())
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
.ToArray();
var cmdAttributes = methods.Select(c => c.GetCustomAttribute<CommandAttribute>()).ToList();
var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList();
cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a =>
{ {
registeredCommands.AddRange(a.Alias.Split(',')); try
});
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; 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<CommandAttribute>()).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); string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}";
if(player == null)
{
return;
}
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); var data = dataStr.DeserializeJson<List<object>>();
}; eventHandler.HandleEvent(new RagePlayer(player), data);
}
//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<List<object>>();
eventHandler.HandleEvent(new RagePlayer(player), data);
}
}
} }

View File

@@ -2,9 +2,11 @@
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
/** /**
* @overview Life of German Reallife - Managers ATMManager (ATMManager.cs) * @overview Life of German Reallife - Managers ATMManager (ATMManager.cs)
@@ -18,6 +20,8 @@ namespace ReallifeGamemode.Server.Managers
{ {
public static List<ColShape> ATMColShapes = new List<ColShape>(); public static List<ColShape> ATMColShapes = new List<ColShape>();
private static readonly ILogger logger = LogManager.GetLogger<ATMManager>();
public static void InitATMs() public static void InitATMs()
{ {
var addedATMs = 0; var addedATMs = 0;
@@ -112,15 +116,16 @@ namespace ReallifeGamemode.Server.Managers
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance); //client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
client.SendNotification("~r~Nicht genügend Geld auf der Hand!"); client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
} }
else if(inputField1 < 0) else if (inputField1 < 0)
{ {
client.SendNotification("~r~Ungültiger Betrag!"); client.SendNotification("~r~Ungültiger Betrag!");
} }
else else
{ {
var updateBankMoneyIn = user.BankAccount; var updateBankMoneyIn = user.BankAccount;
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
user.Handmoney -= inputField1; user.Handmoney -= inputField1;
logger.LogInformation("Player {0} did a deposit of {1} dollars at atm {2}", client.Name, inputField1, nearATM);
updateBankMoneyIn.Balance += inputField1; updateBankMoneyIn.Balance += inputField1;
updateATMBalanceIn.Balance += inputField1; updateATMBalanceIn.Balance += inputField1;
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); //client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
@@ -149,6 +154,7 @@ namespace ReallifeGamemode.Server.Managers
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
updateHandMoneyOut.Handmoney += inputField1; updateHandMoneyOut.Handmoney += inputField1;
user.BankAccount.Balance -= 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; updateATMBalanceOut.Balance -= inputField1;
//client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney); //client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
} }

View File

@@ -1,11 +1,13 @@
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Events; using ReallifeGamemode.Server.Events;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.Managers 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 static Vector3 surgeryPoint = new Vector3(342.30032, -1397.7542, 32.50923);
public const int SURGERY_PRICE = 15000; public const int SURGERY_PRICE = 15000;
private static readonly ILogger logger = LogManager.GetLogger<CharacterCreator>();
public CharacterCreator() public CharacterCreator()
{ {
//LoadSurgery(); //LoadSurgery();
@@ -273,6 +277,7 @@ namespace ReallifeGamemode.Server.Managers
} }
else else
{ {
logger.LogInformation("Player {0} bought a surgery for {1} dollars", player.Name, SURGERY_PRICE);
user.BankAccount.Balance -= SURGERY_PRICE; user.BankAccount.Balance -= SURGERY_PRICE;
} }
saveCharacter.Remove(oldChar); saveCharacter.Remove(oldChar);

View File

@@ -1,9 +1,11 @@
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
@@ -11,8 +13,11 @@ namespace ReallifeGamemode.Server.Managers
{ {
internal class CityHallManager : Script 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 Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
private static readonly ILogger logger = LogManager.GetLogger<CityHallManager>();
public static void LoadCityHall() 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)); 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.Group = group;
u.GroupRank = GroupRank.OWNER; 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"); ChatService.ErrorMessage(player, "Du hast nicht genug Geld");
return; 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(); dbContext.SaveChanges();
ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group); ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group);

View File

@@ -16,6 +16,8 @@ using ReallifeGamemode.Server.Events;
using System; using System;
using ReallifeGamemode.Server.Core.API; using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Factions.Medic;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
/** /**
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)
@@ -27,6 +29,8 @@ namespace ReallifeGamemode.Server.Managers
{ {
public class InteractionManager : Script public class InteractionManager : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<InteractionManager>();
#region Eigeninteraktionen Taste-M #region Eigeninteraktionen Taste-M
[RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")] [RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")]
@@ -484,8 +488,8 @@ namespace ReallifeGamemode.Server.Managers
using var dbContext = new DatabaseContext(); using var dbContext = new DatabaseContext();
var user = player.GetUser(dbContext); var user = player.GetUser(dbContext);
ServerVehicle serverVehicle = dbContext.ServerVehicles.FirstOrDefault(v => v.Id == id); 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(); UserVehicle userVehicle = dbContext.UserVehicles.Where(v => v.Id == id && v.UserId == user.Id).FirstOrDefault();
var vehPrice = userVehicle.Price; var vehPrice = userVehicle.Price;
@@ -493,25 +497,29 @@ namespace ReallifeGamemode.Server.Managers
GTANetworkAPI.Vehicle veh = VehicleManager.GetVehicleFromServerVehicle(userVehicle); GTANetworkAPI.Vehicle veh = VehicleManager.GetVehicleFromServerVehicle(userVehicle);
user.BankAccount.Balance += backPrice; 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); VehicleManager.DeleteVehicle(veh);
dbContext.UserVehicles.Remove(userVehicle); dbContext.UserVehicles.Remove(userVehicle);
player.SendNotification("~g~Du hast dein Fahrzeug verkauft"); 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); FactionVehicle factionVehicle = dbContext.FactionVehicles.FirstOrDefault(v => v.Id == id);
var backPrice = (int)(factionVehicle.BuyPrice * 1.5 * 0.4); var backPrice = (int)(factionVehicle.BuyPrice * 1.5 * 0.4);
user.Faction.BankAccount.Balance += backPrice; 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."); ChatService.SendMessage(player, $"~b~[INFO]~s~ Die Fraktionskasse hat ~g~{backPrice.ToMoneyString()}~s~ erhalten.");
VehicleManager.DeleteVehicle(VehicleManager.GetVehicleFromServerVehicle(factionVehicle)); VehicleManager.DeleteVehicle(VehicleManager.GetVehicleFromServerVehicle(factionVehicle));
dbContext.FactionVehicles.Remove(factionVehicle); dbContext.FactionVehicles.Remove(factionVehicle);
player.SendNotification("~g~Du hast dein Fraktionsfahrzeug verkauft"); player.SendNotification("~g~Du hast dein Fraktionsfahrzeug verkauft");
} }
dbContext.SaveChanges(); 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"); ChatService.ErrorMessage(player, "Das Fahrzeug konnte nicht verkauft werden. Bitte melde dich bei der Leaderverwaltung");
return; return;
} }
var backPrice = (int)(price.Price * 1.5 * 0.4); var backPrice = (int)(price.Price * 1.5 * 0.4);
player.SetData<bool>("SellVehicleDecision", true); player.SetData<bool>("SellVehicleDecision", true);
player.SetData<int>("VehicleToSell", id); player.SetData<int>("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); fibBankAccount.Balance += (int)(ticket_amount / 100 * 60);
lspdBankAccount.Balance += (int)(ticket_amount / 100 * 40); lspdBankAccount.Balance += (int)(ticket_amount / 100 * 40);
} }
logger.LogInformation("Player {0} accepted a ticket of {1} dollars", player.Name, ticket_amount);
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
target.ResetData("ticket_boolean"); target.ResetData("ticket_boolean");
@@ -798,6 +807,7 @@ namespace ReallifeGamemode.Server.Managers
if (amount > 0 && amount <= 5000) 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."); player.SendNotification($"~w~Du hast ~y~{targetname} ~w~{amount.ToMoneyString()} gegeben.");
target.SendNotification($"~w~ Du hast von ~y~{playername} ~w~{amount.ToMoneyString()} erhalten.", true); target.SendNotification($"~w~ Du hast von ~y~{playername} ~w~{amount.ToMoneyString()} erhalten.", true);

View File

@@ -14,6 +14,8 @@ using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Types;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Server.Log;
/** /**
* @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs) * @overview Life of German Reallife - Managers InventoryManager (InventoryManager.cs)
@@ -25,6 +27,9 @@ namespace ReallifeGamemode.Server.Managers
{ {
public class InventoryManager : Script public class InventoryManager : Script
{ {
private const int MAX_USER_INVENTORY = 40000;
private static readonly ILogger logger = LogManager.GetLogger<InventoryManager>();
public static List<IItem> itemList; public static List<IItem> itemList;
private static Dictionary<int, (int[], int[])> TradeItems { get; set; } = new Dictionary<int, (int[], int[])>(); private static Dictionary<int, (int[], int[])> TradeItems { get; set; } = new Dictionary<int, (int[], int[])>();
@@ -224,7 +229,7 @@ namespace ReallifeGamemode.Server.Managers
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == user.Id); List<UserItem> userItems = context.UserItems.Where(i => i.UserId == user.Id).ToList();
foreach (var item in userItems) foreach (var item in userItems)
{ {
IItem iItem = GetItemById(item.ItemId); IItem iItem = GetItemById(item.ItemId);
@@ -381,7 +386,7 @@ namespace ReallifeGamemode.Server.Managers
int setAmount = 0; int setAmount = 0;
for (int i = 1; i <= amount; i++) 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; break;
} }
@@ -589,7 +594,7 @@ namespace ReallifeGamemode.Server.Managers
break; break;
} }
context.SaveChanges(); context.SaveChanges();
} }
} }
@@ -608,6 +613,14 @@ namespace ReallifeGamemode.Server.Managers
return; 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(); UserItem item = dbContext.UserItems.Where(i => i.ItemId == shopItem.Id && i.UserId == user.Id).FirstOrDefault();
if (item == null) if (item == null)
{ {

View File

@@ -2,14 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
{ {
internal class TuningManager : Script internal class TuningManager : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<TuningManager>();
private static List<ColShape> tuningGarages = new List<ColShape>(); private static List<ColShape> tuningGarages = new List<ColShape>();
public static void LoadTuningGarages() public static void LoadTuningGarages()
@@ -220,6 +223,7 @@ namespace ReallifeGamemode.Server.Managers
ServerVehicle sV = player.Vehicle.GetServerVehicle(dbContext); ServerVehicle sV = player.Vehicle.GetServerVehicle(dbContext);
if (sV == null) return; 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); VehicleMod vMod = dbContext.VehicleMods.FirstOrDefault(m => m.ServerVehicleId == sV.Id && m.Slot == slot);
if (vMod == null && index != -1) if (vMod == null && index != -1)
@@ -265,7 +269,7 @@ namespace ReallifeGamemode.Server.Managers
veh.SecondaryColor = color; veh.SecondaryColor = color;
} }
using var dbContext = new DatabaseContext(true); using var dbContext = new DatabaseContext();
ServerVehicle serverVeh = VehicleManager.GetServerVehicleFromVehicle(veh, dbContext); ServerVehicle serverVeh = VehicleManager.GetServerVehicleFromVehicle(veh, dbContext);
if (serverVeh == null) if (serverVeh == null)
@@ -311,6 +315,7 @@ namespace ReallifeGamemode.Server.Managers
if (serverVehicle != null) 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(); VehicleMod typeMod = dbContext.VehicleMods.Where(m => m.ServerVehicleId == serverVehicle.Id && m.Slot == -2).FirstOrDefault();
if (typeMod == null) if (typeMod == null)
{ {

View File

@@ -2,9 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI; using GTANetworkAPI;
using Microsoft.Extensions.Logging;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Log;
using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
@@ -12,6 +14,7 @@ namespace ReallifeGamemode.Server.Util
{ {
class Rentcar : Script class Rentcar : Script
{ {
private static readonly ILogger logger = LogManager.GetLogger<Rentcar>();
//In Sekunden //In Sekunden
public static int PAY_TIMER = 180; public static int PAY_TIMER = 180;
@@ -69,6 +72,7 @@ namespace ReallifeGamemode.Server.Util
{ {
User user = player.GetUser(dbContext); User user = player.GetUser(dbContext);
user.BankAccount.Balance -= mapPlayerRentcarBill[player.Name].Item2; 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(); dbContext.SaveChanges();
} }
@@ -105,9 +109,9 @@ namespace ReallifeGamemode.Server.Util
{ {
return; return;
} }
player.TriggerEvent("BN_Show", "Fahrzeug seit ~b~" + (int)(time / 60) + "~w~ Minuten gemietet (Gesamtkosten: ~g~$~s~" + bill + ")."); 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")] [RemoteEvent("SERVER:rentcarBooked")]