userbankaccount balancechanged dont crash server
This commit is contained in:
@@ -187,21 +187,23 @@ namespace ReallifeGamemode.Server.Finance
|
||||
public static void Timer_Elapsed()
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers())
|
||||
foreach (var player in NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn()))
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
if (player.IsLoggedIn())
|
||||
if(user == null)
|
||||
{
|
||||
user.PlayedMinutes += 1;
|
||||
if (user.PaydayTimer <= 0)
|
||||
{
|
||||
Economy.SetPaycheck(player);
|
||||
user.PaydayTimer = 60;
|
||||
}
|
||||
else if (user.PaydayTimer > 0)
|
||||
{
|
||||
user.PaydayTimer -= 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
user.PlayedMinutes += 1;
|
||||
if (user.PaydayTimer <= 0)
|
||||
{
|
||||
Economy.SetPaycheck(player);
|
||||
user.PaydayTimer = 60;
|
||||
}
|
||||
else if (user.PaydayTimer > 0)
|
||||
{
|
||||
user.PaydayTimer -= 1;
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
|
||||
Reference in New Issue
Block a user