maybe fix knast

This commit is contained in:
hydrant
2021-04-07 23:32:52 +02:00
parent 79ab18b65b
commit 3f2cdbeea8
7 changed files with 148 additions and 184 deletions

View File

@@ -35,9 +35,10 @@ namespace ReallifeGamemode.Server.Wanted
public static void Timer_Elapsed()
{
using var dbContext = new DatabaseContext();
foreach (var player in NAPI.Pools.GetAllPlayers())
{
User user = player.GetUser();
User user = player.GetUser(dbContext);
if (user != null && user.Wanteds > 0)
{
if (!waTimer.ContainsKey(user.Id))
@@ -68,30 +69,10 @@ namespace ReallifeGamemode.Server.Wanted
{
ResetWantedTimeToElapse(player);
player.SendChatMessage("~y~Du hast erfolgtreich einen Wanted abgetaucht.");
using (var dbContext = new DatabaseContext())
user.Wanteds -= 1;
if (user.Wanteds == 0)
{
player.GetUser(dbContext).Wanteds -= 1;
if (player.GetUser(dbContext).Wanteds == 0)
{
switch (player.GetUser(dbContext).FactionId)
{
case null:
player.SetSharedData("blipColor", 0);
break;
case 8:
player.SetSharedData("blipColor", 83);
break;
case 7:
player.SetSharedData("blipColor", 52);
break;
case 4:
player.SetSharedData("blipColor", 5);
break;
}
}
user.SetBlipAndNametagColor();
dbContext.SaveChanges();
}
}