Merge branch 'develop' into 'feature/atm-system'
# Conflicts: # ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
|
||||
/**
|
||||
@@ -20,21 +21,24 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static void InitATMs()
|
||||
{
|
||||
var addedATMs = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.Blips)
|
||||
{
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if(dbContext.ATMs.FirstOrDefault(a => a.X == currentATM.PositionX && a.Y == currentATM.PositionY && a.Z == currentATM.PositionZ) == null)
|
||||
if(dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
{
|
||||
var dataSet = new ATM
|
||||
{
|
||||
Id = currentATM.Id,
|
||||
X = currentATM.PositionX,
|
||||
Y = currentATM.PositionY,
|
||||
Z = currentATM.PositionZ
|
||||
};
|
||||
dbContext.Add(dataSet);
|
||||
addedATMs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -42,6 +46,15 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
}
|
||||
if(addedATMs > 0)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
}
|
||||
@@ -56,16 +69,13 @@ namespace ReallifeGamemode.Server.Managers
|
||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||
ATMColShapes.Add(currentColShape);
|
||||
currentColShape.SetData("id", currentATM.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void EnterATMRange(ColShape colShape, Client client)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var nearATM = dbContext.ATMs.FirstOrDefault(a => a.X == colShape.Position.X && a.Y == colShape.Position.Y && a.Z == colShape.Position.Z);
|
||||
client.SetData("nearATM", nearATM.Id);
|
||||
}
|
||||
client.SetData("nearATM", colShape.GetData("id"));
|
||||
}
|
||||
public static void ExitATMRange(ColShape colShape, Client client)
|
||||
{
|
||||
@@ -73,11 +83,41 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
public static void ShowAtmUi(Client player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_ACTION")]
|
||||
public void AtmAction(Client client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
var user = client.GetUser();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var atmBalance = dbContext.ATMs.FirstOrDefault(a => a.Id == atmId);
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId, atmBalance.Balance);
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
var updateHandMoneyIn = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateBankMoneyIn = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
updateHandMoneyIn.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateBankMoneyOut = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
updateBankMoneyOut.Balance -= inputField1;
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user