Merge branch 'develop' into 'feature/atm-system'
# Conflicts: # ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs
This commit is contained in:
@@ -1074,6 +1074,53 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
#endregion
|
||||
#region ALevel1337
|
||||
[Command("sethandmoney", "~m~Benutzung: ~s~/sethandmoney [Target] [Geld]")]
|
||||
public void CmdAdminSetUserHandMoney(Client admin, string targetname, int amount)
|
||||
{
|
||||
if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(admin);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(targetname);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(target);
|
||||
return;
|
||||
}
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var user = target.GetUser(context);
|
||||
user.Handmoney = amount;
|
||||
context.SaveChanges();
|
||||
}
|
||||
target.TriggerEvent("SERVER:SET_HANDMONEY", amount);
|
||||
}
|
||||
|
||||
[Command("givehandmoney", "~m~Benutzung: ~s~/givehandmoney [Target] [Geld]")]
|
||||
public void CmdAdminGiveUserHandMoney(Client admin, string targetname, int amount)
|
||||
{
|
||||
if (!admin.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(admin);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(targetname);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(target);
|
||||
return;
|
||||
}
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var user = target.GetUser(context);
|
||||
user.Handmoney += amount;
|
||||
context.SaveChanges();
|
||||
target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]\nModi (klein schreiben): ~g~blip, ~r~atm")]
|
||||
public void CmdAdminSetQuickSaveMode(Client player, string mode)
|
||||
@@ -1089,7 +1136,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("giveitem", "~m~Benutzung: ~s~/giveitem [Target] [Item ID] [Anzahl]")]
|
||||
public void CmdAdminGiveItem(Client player, string targetname, int itemId, int amount)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -1127,7 +1174,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
|
||||
public void CmdAdminGiveItem(Client player, string targetname)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
public AdminLevel AdminLevel { get; set; }
|
||||
|
||||
public bool Dead { get; set; }
|
||||
public int Handmoney { get; set; }
|
||||
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,6 +728,8 @@ namespace ReallifeGamemode.Migrations
|
||||
|
||||
b.Property<int?>("FactionRankId");
|
||||
|
||||
b.Property<int>("Handmoney");
|
||||
|
||||
b.Property<int>("LogUserId");
|
||||
|
||||
b.Property<string>("Name")
|
||||
|
||||
Reference in New Issue
Block a user