[HOTFIX] punkte vergeben aufgeräumt
This commit is contained in:
@@ -486,7 +486,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
using var dbContext = new DatabaseContext();
|
||||
var user = player.GetUser(dbContext);
|
||||
|
||||
if(user.FactionId == null)
|
||||
if (user.FactionId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
|
||||
var factionVehicleCount = dbContext.FactionVehicles.ToList().Where(v => v.Id == id && v.GetOwners().Contains(user.FactionId.Value)).Count();
|
||||
if(factionVehicleCount <= 6)
|
||||
if (factionVehicleCount <= 6)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Die Fraktion braucht mindestens 6 Fahrzeuge");
|
||||
return;
|
||||
@@ -589,85 +589,76 @@ namespace ReallifeGamemode.Server.Managers
|
||||
public void InteractionMenu_LSPD_Points3(Player player, string jsonNameOrId, string jsoAmount, string jsonReason)
|
||||
{
|
||||
string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId);
|
||||
int amount = Int32.Parse((string)JsonConvert.DeserializeObject(jsoAmount));
|
||||
string reason = (string)JsonConvert.DeserializeObject(jsonReason);
|
||||
Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
|
||||
string playername = NAPI.Player.GetPlayerName(player);
|
||||
string targetname = NAPI.Player.GetPlayerName(target);
|
||||
|
||||
if (!int.TryParse((string)JsonConvert.DeserializeObject(jsoAmount), out int amount))
|
||||
{
|
||||
player.SendNotification("~r~Es muss eine gültige Zahl für die Punkte angegeben werden!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
else if (target.GetUser().DriverLicenseVehicle == false && target.GetUser().DriverLicenseBike == false)
|
||||
{
|
||||
player.SendNotification("~r~Spieler hat weder Auto- noch Motorradführerschein!");
|
||||
}
|
||||
else if (target == player)
|
||||
|
||||
if (target == player)
|
||||
{
|
||||
player.SendNotification("~r~Du kannst dir selbst keine Punkte setzen!");
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
User targetUser = target.GetUser(dbContext);
|
||||
|
||||
if(targetUser == null)
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser.DriverLicenseVehicle == false && targetUser.DriverLicenseBike == false)
|
||||
{
|
||||
player.SendNotification("~r~Spieler hat weder Auto- noch Motorradführerschein!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount < -13 || amount > 13)
|
||||
{
|
||||
player.SendNotification("~r~Du kannst nur zwischen 1 und 12 Punkte verteilen!");
|
||||
return;
|
||||
}
|
||||
|
||||
targetUser.Points += amount;
|
||||
|
||||
player.SendNotification($"~w~Du hast ~y~{targetname} ~b~{amount} ~w~Strafpunkte gegeben. Grund: ~g~{reason}~w~.");
|
||||
target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ~y~{amount} ~w~Strafpunkte gegeben.", true);
|
||||
ChatService.HQMessage(targetname + " hat von " + playername + " " + amount + " Strafpunkt(e) erhalten. Gesamt: " + targetUser.Points);
|
||||
|
||||
if (targetUser.Points < 0)
|
||||
{
|
||||
targetUser.Points = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
else if (targetUser.Points >= 12)
|
||||
{
|
||||
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~12/12 ~x~Strafpunkten.", true);
|
||||
target.SendNotification($"~w~Dir wird ~r~Auto- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); //FlashNotif
|
||||
|
||||
ChatService.HQMessage(targetname + " besitzt nun keinen Führerschein mehr.");
|
||||
|
||||
targetUser.Points = 0;
|
||||
targetUser.DriverLicenseVehicle = false;
|
||||
targetUser.DriverLicenseBike = false;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (amount > -13 && amount < 13)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User target2 = target.GetUser(dbContext);
|
||||
target2.Points += amount;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
player.SendNotification($"~w~Du hast ~y~{targetname} ~b~{amount} ~w~Strafpunkte gegeben. Grund: ~g~{reason}~w~.");
|
||||
target.SendNotification($"~b~{player.GetUser().FactionRank.RankName} | {playername} ~w~hat dir ~y~{amount} ~w~Strafpunkte gegeben.", true);
|
||||
ChatService.BroadcastFaction("!{#8181E9}HQ: " + targetname + " hat von " + playername + " " + amount + " Strafpunkt(e) erhalten. Gesamt: " + target.GetUser().Points, new List<int>() { 1, 3 });
|
||||
if (target.GetUser().Points < 0)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User target2 = target.GetUser(dbContext);
|
||||
target2.Points = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (target.GetUser().Points >= 12)
|
||||
{
|
||||
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~r~12/12 ~x~Strafpunkten.", true);
|
||||
target.SendNotification($"~w~Dir wird ~r~Auto- ~w~und ~r~Motorradführerschein ~w~entzogen.", true); //FlashNotif
|
||||
ChatService.HQMessage(targetname + "hat von" + playername + " " + amount + " Strafpunkt erhalten(e). Gesamt: " + target.GetUser().Points);
|
||||
foreach (var copPlayer in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
User copUser = copPlayer.GetUser();
|
||||
if (copUser == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (copUser.FactionId == 1 || copUser.FactionId == 3)
|
||||
{
|
||||
if (copUser.GetData<bool>("duty") == true)
|
||||
{
|
||||
ChatService.HQMessage(targetname + " besitzt nun keinen Führerschein mehr.");
|
||||
}
|
||||
}
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User target2 = target.GetUser(dbContext);
|
||||
target2.Points = 0;
|
||||
target2.DriverLicenseVehicle = false;
|
||||
target2.DriverLicenseBike = false;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~y~{target.GetUser().Points}/12 ~x~Strafpunkten.", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du kannst nur zwischen 1 und 12 Punkte verteilen!");
|
||||
}
|
||||
target.SendNotification($"~w~Grund: ~g~{reason}~w~. ~x~Du hast nun ~y~{targetUser.Points}/12 ~x~Strafpunkten.", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user