Merge branch 'develop' into feature/inventory-system
This commit is contained in:
31
Server/Entities/BusinessBankAccount.cs
Normal file
31
Server/Entities/BusinessBankAccount.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using reallife_gamemode.Server.Business;
|
||||
using reallife_gamemode.Server.Managers;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class BusinessBankAccount : IBankAccount
|
||||
{
|
||||
[NotMapped]
|
||||
private int _balance;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public int Balance {
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
BusinessManager.GetBusiness(BusinessId).Update(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int BusinessId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
@@ -14,28 +16,19 @@ using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class FactionVehicle
|
||||
[Table("FactionVehicles")]
|
||||
public class FactionVehicle : ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("Faction")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public byte PrimaryColor { get; set; }
|
||||
public byte SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Engine { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public Faction GetFaction()
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
Server/Entities/ServerVehicle.cs
Normal file
47
Server/Entities/ServerVehicle.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Managers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public abstract class ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public int PrimaryColor { get; set; }
|
||||
public int SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Active { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(PositionX, PositionY, PositionZ);
|
||||
|
||||
public Vehicle Spawn(Vehicle currentVeh = null)
|
||||
{
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vehicle veh = NAPI.Vehicle.CreateVehicle(this.Model, this.Position, this.Heading, this.PrimaryColor, this.SecondaryColor, this.NumberPlate, locked: this.Locked, engine: false);
|
||||
VehicleManager.AddVehicle(this, veh);
|
||||
|
||||
if(this is FactionVehicle fV)
|
||||
{
|
||||
veh.NumberPlate = fV.GetFaction().Name;
|
||||
}
|
||||
|
||||
return veh;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,30 +14,12 @@ using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class ShopVehicle
|
||||
[Table("ShopVehicles")]
|
||||
public class ShopVehicle : ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Shop")]
|
||||
public int? ShopId { get; set; }
|
||||
public Shop Shop { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
[StringLength(32)]
|
||||
public string ModelName { get; set; }
|
||||
public int Price { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public byte PrimaryColor { get; set; }
|
||||
public byte SecondaryColor { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities User (User.cs)
|
||||
@@ -59,6 +57,8 @@ namespace reallife_gamemode.Server.Entities
|
||||
public int? FactionRankId { get; set; }
|
||||
public FactionRank FactionRank { get;set; }
|
||||
|
||||
public int? BusinessId { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
using(var context = new DatabaseContext())
|
||||
@@ -100,14 +100,16 @@ namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + this.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = this.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
//TODO user.Kick();
|
||||
|
||||
GetClient()?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + this.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = this.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
//TODO user.Kick();
|
||||
GetClient()?.Kick();
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
@@ -119,12 +121,11 @@ namespace reallife_gamemode.Server.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbanPlayer(Client admin)
|
||||
public void UnbanPlayer()
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
User user = admin.GetUser();
|
||||
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == this.Id);
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
@@ -153,5 +154,10 @@ namespace reallife_gamemode.Server.Entities
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public Client GetClient()
|
||||
{
|
||||
return NAPI.Player.GetPlayerFromName(Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,11 @@ using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class UserVehicle
|
||||
[Table("UserVehicles")]
|
||||
public class UserVehicle : ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public byte PrimaryColor { get; set; }
|
||||
public byte SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Engine { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
22
Server/Entities/VehicleMod.cs
Normal file
22
Server/Entities/VehicleMod.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class VehicleMod
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Vehicle")]
|
||||
public int ServerVehicleId { get; set; }
|
||||
public ServerVehicle Vehicle { get; set; }
|
||||
|
||||
public int Slot { get; set; }
|
||||
public int ModId { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user