bank account refactor
This commit is contained in:
@@ -9,6 +9,7 @@ using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -27,6 +28,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.BankAccount)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
@@ -54,17 +56,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
if (player.GetUser().FactionLeader)
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.GetBankAccount();
|
||||
var userBankAccount = user.BankAccount;
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
@@ -110,7 +112,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.Rotation = new Vector3(0,0,180);
|
||||
player.Rotation = new Vector3(0, 0, 180);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -18,29 +18,29 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
|
||||
if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
var user = new Database.Entities.User
|
||||
player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
|
||||
}
|
||||
else if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
|
||||
{
|
||||
var user = new User
|
||||
{
|
||||
Name = player.Name,
|
||||
SocialClubName = player.SocialClubName,
|
||||
Password = NAPI.Util.GetHashSha256(password),
|
||||
PositionX = Main.DEFAULT_SPAWN_POSITION.X,
|
||||
PositionY = Main.DEFAULT_SPAWN_POSITION.Y,
|
||||
PositionZ = Main.DEFAULT_SPAWN_POSITION.Z
|
||||
PositionZ = Main.DEFAULT_SPAWN_POSITION.Z,
|
||||
BankAccount = new UserBankAccount
|
||||
{
|
||||
Balance = 5000,
|
||||
Active = true
|
||||
}
|
||||
};
|
||||
|
||||
dbContext.Users.Add(user);
|
||||
dbContext.SaveChanges();
|
||||
var userBankAccount = new Database.Entities.UserBankAccount
|
||||
{
|
||||
UserId = user.Id,
|
||||
Balance = 5000,
|
||||
Active = true
|
||||
};
|
||||
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
@@ -54,10 +54,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
}
|
||||
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzername kann nicht registriert werden.");
|
||||
|
||||
Reference in New Issue
Block a user