Merge develop into feature/inventory-system
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers BankManager (BankManager.cs)
|
||||
@@ -17,99 +18,42 @@ namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
public class BankManager : Script
|
||||
{
|
||||
public static void TransferUserMoneyToUser(User sender, User receiver, int amount, string origin)
|
||||
public static TransactionResult TransferMoney(IBankAccountOwner sender, IBankAccountOwner receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new Model.DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount = sender.GetBankAccount(transferMoney);
|
||||
IBankAccount receiverAccount = receiver.GetBankAccount(transferMoney);
|
||||
|
||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||
|
||||
var transactionLog = new Logs.BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.Name,
|
||||
SenderBalance = sender.GetUserBankAccount().Balance,
|
||||
MoneySent = amount,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiver.GetUserBankAccount().Balance,
|
||||
NewReceiverBalance = receiver.GetUserBankAccount().Balance + amount,
|
||||
NewSenderBalance = sender.GetUserBankAccount().Balance - amount,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
sender.GetUserBankAccount(transferMoney).Balance -= amount;
|
||||
receiver.GetUserBankAccount(transferMoney).Balance += amount;
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransferUserMoneyToFaction(User sender, Faction receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new Model.DatabaseContext())
|
||||
{
|
||||
var transactionLog = new Logs.BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.Name,
|
||||
SenderBalance = sender.GetUserBankAccount().Balance,
|
||||
MoneySent = amount,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiver.BankAccount,
|
||||
NewReceiverBalance = receiver.BankAccount + amount,
|
||||
NewSenderBalance = sender.GetUserBankAccount().Balance - amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
sender.GetUserBankAccount(transferMoney).Balance -= amount;
|
||||
receiver.BankAccount += amount;
|
||||
transferMoney.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransferFactionMoneyToUser(Faction sender, User receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new Model.DatabaseContext())
|
||||
{
|
||||
var transactionLog = new Logs.BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.Name,
|
||||
SenderBalance = sender.BankAccount,
|
||||
MoneySent = amount,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiver.GetUserBankAccount().Balance,
|
||||
NewReceiverBalance = receiver.GetUserBankAccount().Balance + amount,
|
||||
NewSenderBalance = sender.BankAccount - amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
sender.BankAccount -= amount;
|
||||
receiver.GetUserBankAccount(transferMoney).Balance += amount;
|
||||
transferMoney.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void TransferFactionMoneyToFaction(Faction sender, Faction receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new Model.DatabaseContext())
|
||||
{
|
||||
var transactionLog = new Logs.BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.Name,
|
||||
SenderBalance = sender.GetFactionBankAccount().Balance,
|
||||
MoneySent = amount,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiver.BankAccount,
|
||||
NewReceiverBalance = receiver.BankAccount + amount,
|
||||
NewSenderBalance = sender.BankAccount - amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
sender.BankAccount -= amount;
|
||||
receiver.BankAccount += amount;
|
||||
transferMoney.SaveChanges();
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,10 @@ namespace reallife_gamemode.Server.Managers
|
||||
player.Dimension = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wendet den Character eines Spielers auf diesen an
|
||||
/// </summary>
|
||||
/// <param name="player">Der Client, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Client player)
|
||||
{
|
||||
var userId = player.GetUser().Id;
|
||||
|
||||
51
Server/Managers/DoorManager.cs
Normal file
51
Server/Managers/DoorManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers BankManager (BankManager.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
public class DoorManager : Script
|
||||
{
|
||||
public static void ChangeDoorState(Client player)
|
||||
{
|
||||
List<Door> NearDoors = new List<Door>();
|
||||
var user = player.GetUser();
|
||||
|
||||
using (var saveDoor = new DatabaseContext())
|
||||
{
|
||||
NearDoors = saveDoor.Doors.ToList().FindAll(d => new Vector3(d.X, d.Y, d.Z).DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
Door currentDoor = saveDoor.Doors.FirstOrDefault(c => c.Id == d.Id);
|
||||
|
||||
if(!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
currentDoor.Locked = !currentDoor.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (currentDoor.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
saveDoor.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ namespace reallife_gamemode.Server.Managers
|
||||
public static List<Vehicle> ShopVehicleList = new List<Vehicle>();
|
||||
public static List<Vehicle> UserVehicleList = new List<Vehicle>();
|
||||
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
@@ -69,7 +68,7 @@ namespace reallife_gamemode.Server.Managers
|
||||
NAPI.Vehicle.SetVehicleEngineHealth(current, 0);
|
||||
var tLabel = NAPI.TextLabel.CreateTextLabel(v.ModelName + " | " + v.Price + "~g~$", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), 10, 1, 0, new Color(255, 255, 255), false, v.Dimension);
|
||||
current.SetData("shopVehicleId", v.Id);
|
||||
tLabel.AttachTo(current, "SKEL_ROOT", new Vector3(v.PositionX, v.PositionY, v.PositionZ + 1.5), new Vector3(0, 0, 0));
|
||||
tLabel.AttachTo(current, "chassis", new Vector3(0, 0, 1.5), new Vector3(0, 0, 0));
|
||||
}
|
||||
}
|
||||
foreach (UserVehicle v in loadData.UserVehicles)
|
||||
|
||||
41
Server/Managers/PositionManager.cs
Normal file
41
Server/Managers/PositionManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
|
||||
namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
public class PositionManager : Script
|
||||
{
|
||||
public static List<DutyPoint> DutyPoints = new List<DutyPoint>();
|
||||
public static List<ColShape> DutyColShapes = new List<ColShape>();
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
DutyPoint dutyPointLSPD = new DutyPoint()
|
||||
{
|
||||
Position = new Vector3(458.24, -990.86, 30.68),
|
||||
FactionId = 1
|
||||
};
|
||||
|
||||
DutyPoints.Add(dutyPointLSPD);
|
||||
|
||||
foreach (DutyPoint d in DutyPoints)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1),
|
||||
new Vector3(0,0,0), 3, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DutyPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public int FactionId { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace reallife_gamemode.Server.Events
|
||||
public class SaveManager : Script
|
||||
{
|
||||
[RemoteEvent("OnSaveBlipData")]
|
||||
public void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||
public static void OnSaveBlipData(Client player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
||||
{
|
||||
float x = player.Position.X;
|
||||
@@ -162,7 +162,7 @@ namespace reallife_gamemode.Server.Events
|
||||
foreach (Vehicle v in LoadManager.FactionVehicleList)
|
||||
{
|
||||
int factionId = v.GetData("factionId");
|
||||
Entities.UserVehicle factionVehicle = saveAll.UserVehicles.FirstOrDefault(u => u.UserId == factionId);
|
||||
Entities.FactionVehicle factionVehicle = saveAll.FactionVehicles.FirstOrDefault(u => u.FactionId == factionId);
|
||||
factionVehicle.PositionX = v.Position.X;
|
||||
factionVehicle.PositionY = v.Position.Y;
|
||||
factionVehicle.PositionZ = v.Position.Z;
|
||||
|
||||
@@ -7,15 +7,19 @@ namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
private static List<ColShape> tuningGarages = new List<ColShape>();
|
||||
|
||||
public static void AddTuningGarage(Vector3 pos1, Vector3 pos2)
|
||||
/// <summary>
|
||||
/// Fügt eine Tuning-Garage zum Spiel hinzu
|
||||
/// </summary>
|
||||
/// <param name="pos">Die Position der Garage</param>
|
||||
public static void AddTuningGarage(Vector3 pos)
|
||||
{
|
||||
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos1, 10, 0);
|
||||
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos, 10, 0);
|
||||
|
||||
colShape.OnEntityEnterColShape += (cs, c) =>
|
||||
{
|
||||
if(c.IsInVehicle)
|
||||
{
|
||||
c.TriggerEvent("showTuningInfo");
|
||||
c.TriggerEvent("showTuningInfo", c.GetData("duty"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user