Finished business system
This commit is contained in:
@@ -11,7 +11,7 @@ namespace reallife_gamemode.Server.Business
|
|||||||
|
|
||||||
public override string Name => "24/7 Business";
|
public override string Name => "24/7 Business";
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3();
|
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||||
|
|
||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using GTANetworkAPI;
|
|
||||||
using reallife_gamemode.Model;
|
|
||||||
using reallife_gamemode.Server.Util;
|
|
||||||
|
|
||||||
namespace reallife_gamemode.Server.Business
|
|
||||||
{
|
|
||||||
class TestBusiness : BusinessBase
|
|
||||||
{
|
|
||||||
public override int Id => 0;
|
|
||||||
|
|
||||||
public override string Name => "Test Business";
|
|
||||||
|
|
||||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
|
||||||
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using reallife_gamemode.Server.Business;
|
using reallife_gamemode.Server.Business;
|
||||||
|
using reallife_gamemode.Server.Entities;
|
||||||
|
using reallife_gamemode.Server.Extensions;
|
||||||
|
using reallife_gamemode.Server.Util;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -22,7 +25,7 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
NAPI.Util.ConsoleOutput($"Loading Business {item.Name}");
|
NAPI.Util.ConsoleOutput($"Loading Business {item.Name}");
|
||||||
if (Activator.CreateInstance(item) is BusinessBase o)
|
if (Activator.CreateInstance(item) is BusinessBase o)
|
||||||
{
|
{
|
||||||
if (Businesses.Any(x => x.Id == o.Id))
|
if (GetBusiness(o.Id) != null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Double Business ID found: {o.Id} | {o.Name}");
|
throw new InvalidOperationException($"Double Business ID found: {o.Id} | {o.Name}");
|
||||||
}
|
}
|
||||||
@@ -43,5 +46,67 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
return Businesses.Find(b => b.Id == id);
|
return Businesses.Find(b => b.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("Business_DepositMoney")]
|
||||||
|
public void BusinessDepositMoney(Client player, int amount)
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
if(user == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||||
|
|
||||||
|
TransactionResult result = BankManager.TransferMoney(user, playerBusiness, amount, "Überweisung");
|
||||||
|
|
||||||
|
if(result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du hast nicht genug Geld");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(result == TransactionResult.SUCCESS)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||||
|
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("Business_WithdrawMoney")]
|
||||||
|
public void BusinessWithdrawMoney(Client player, int amount)
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||||
|
|
||||||
|
TransactionResult result = BankManager.TransferMoney(playerBusiness, user, amount, "Überweisung");
|
||||||
|
|
||||||
|
if (result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Es ist nicht genug Geld auf der Businesskasse vorhanden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (result == TransactionResult.SUCCESS)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||||
|
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user