bank account refactor

This commit is contained in:
hydrant
2020-03-15 21:33:04 +01:00
parent 75e26b8e8a
commit 92c054c90c
30 changed files with 2088 additions and 300 deletions

View File

@@ -16,6 +16,12 @@ using ReallifeGamemode.Server.Common;
using System.Reflection;
using System.Linq;
using ReallifeGamemode.Server.Job;
using ReallifeGamemode.Database.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Services;
/**
* @overview Life of German Reallife - Main Class (Main.cs)
@@ -105,6 +111,16 @@ namespace ReallifeGamemode.Server
Jail.JailTimer();
Economy.PaydayTimer();
WeaponDealManager.WeaponDealTimer();
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;
PlayerService.GetPlayerByNameOrId(user).TriggerEvent("updateMoney", account.Balance);
}
};
}
[RemoteEvent("CLIENT:Event")]