From 2c648d52ddcc3d7b80865a0eeb09dfc35a616749 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 10 May 2020 22:54:18 +0200 Subject: [PATCH] bissl formattiert --- ReallifeGamemode.DataService/Startup.cs | 2 +- .../Entities/JobVehicle.cs | 2 +- ReallifeGamemode.Database/Entities/Turfs.cs | 2 +- .../Migrations/20200126141420_Initial.cs | 2552 ++++++++--------- .../Migrations/20200202153232_ShopItems.cs | 50 +- .../20200313203304_UserWeaponLicense.cs | 32 +- .../20200317192534_VehicleAddPrice.cs | 30 +- .../20200324175347_HouseWeeklyRentalFee.cs | 32 +- .../20200330201122_HouseBankAccounts.cs | 98 +- .../20200403035225_TurfSurplusValue.cs | 50 +- .../Migrations/20200405102619_TurfMaxValue.cs | 32 +- .../Migrations/20200407014500_PedType.cs | 32 +- .../Migrations/20200408151729_UserPoints.cs | 32 +- .../Commands/CommandHandler.cs | 2 +- .../Business/BikeDealerBusiness.cs | 30 +- .../Business/BoatDealerBusiness.cs | 30 +- .../Business/BusinessBase.cs | 358 +-- .../Business/CarDealerBusinessBase.cs | 6 +- ...remiumDeluxeMotorsportCarDealerBusiness.cs | 26 +- .../Business/ShopBusiness.cs | 18 +- .../Business/TelefonBusiness.cs | 18 +- .../Business/VapidCarDealerBusiness.cs | 26 +- ReallifeGamemode.Server/Classes/TempBlip.cs | 16 +- .../DrivingSchool/Licenses.cs | 38 +- ReallifeGamemode.Server/Events/Chat.cs | 22 +- ReallifeGamemode.Server/Events/Death.cs | 218 +- ReallifeGamemode.Server/Events/Disconnect.cs | 76 +- .../Events/EnterVehicleAttempt.cs | 82 +- ReallifeGamemode.Server/Events/Inventory.cs | 108 +- ReallifeGamemode.Server/Events/Login.cs | 266 +- .../Events/ResourceStop.cs | 30 +- .../Events/UpdateCharacterCloth.cs | 494 ++-- .../Events/UpdateCharacterElevator.cs | 18 +- .../Events/UpdateCharacterWeapon.cs | 186 +- ReallifeGamemode.Server/Events/Vehicle.cs | 510 ++-- .../Extensions/ClientExtension.cs | 328 +-- .../Extensions/EnumExtensions.cs | 90 +- .../Extensions/IntegerExtension.cs | 18 +- .../Extensions/ServerVehicleExtensions.cs | 120 +- .../Extensions/VehicleExtension.cs | 18 +- .../Factions/Medic/Medic.cs | 168 +- .../Factions/Medic/MedicTask.cs | 32 +- ReallifeGamemode.Server/Finance/Economy.cs | 262 +- ReallifeGamemode.Server/Finance/Paycheck.cs | 36 +- ReallifeGamemode.Server/Gangwar/Gangwar.cs | 418 +-- ReallifeGamemode.Server/Gangwar/Turf.cs | 668 ++--- .../Inventory/Interfaces/IDroppableItem.cs | 6 +- .../Inventory/Interfaces/IItem.cs | 16 +- .../Inventory/Interfaces/IUsableItem.cs | 6 +- .../Inventory/Interfaces/IWeaponDealItem.cs | 6 +- .../Inventory/Items/DropItem.cs | 28 +- .../Inventory/Items/FoodItem.cs | 42 +- .../Inventory/Items/WeaponDealItem.cs | 32 +- ReallifeGamemode.Server/Job/JobBase.cs | 102 +- .../Job/RefuseCollectorJob.cs | 626 ++-- ReallifeGamemode.Server/Main.cs | 162 +- .../Managers/ATMManager.cs | 246 +- .../Managers/BankManager.cs | 174 +- .../Managers/CharacterCreator.cs | 624 ++-- .../Managers/DoorManager.cs | 126 +- .../Managers/JobManager.cs | 622 ++-- .../Managers/LoadManager.cs | 42 +- .../Managers/PedManager.cs | 4 +- .../Managers/SaveManager.cs | 348 +-- .../Managers/ShopManager.cs | 92 +- .../Managers/TimeManager.cs | 44 +- .../Migrations/20190226185806_Initial.cs | 1742 +++++------ .../20190306194826_VehicleDistanceDriven.cs | 30 +- .../Migrations/20190307163335_VehicleTank.cs | 30 +- .../Migrations/20190309184251_ATM.cs | 52 +- .../Migrations/20190408143319_Handmoney.cs | 30 +- .../Migrations/20190411180607_TuningGarage.cs | 46 +- .../Migrations/20190505154643_Groups.cs | 220 +- .../20190513111017_UnusedColumnRemove.cs | 28 +- .../Migrations/20190513161249_Jobs.cs | 150 +- .../Migrations/20190516094446_JobFix.cs | 118 +- .../20190624153156_ClothesTexture.cs | 30 +- .../20190625202943_ClientWanteds.cs | 30 +- .../Migrations/20190626193631_House.cs | 84 +- .../20190626202159_HousePosition.cs | 66 +- .../20190627162731_UserHouseReference.cs | 38 +- .../Migrations/20190706132925_UserWage.cs | 30 +- .../Migrations/20190707184050_BusRoutes.cs | 100 +- .../20190708161922_UserHouseReferenceFix.cs | 66 +- .../Migrations/20190715192123_JailTime.cs | 30 +- .../Migrations/20190719210722_PaydayTimer.cs | 30 +- .../20190721144830_FactionWeapons.cs | 68 +- .../20190722201850_VehicleLivery.cs | 30 +- .../20190728142431_HouseEnhancments.cs | 120 +- .../Migrations/20190805184145_VehicleItems.cs | 68 +- .../Migrations/20190911192912_BusinessData.cs | 44 +- .../Shop/Clothing/ClotheShop.cs | 54 +- .../Shop/SevenEleven/ItemShop.cs | 56 +- .../Util/CheckPointHandle.cs | 182 +- ReallifeGamemode.Server/Util/Converter.cs | 50 +- ReallifeGamemode.Server/Util/GlobalHelper.cs | 10 +- ReallifeGamemode.Server/Util/IndicatorData.cs | 8 +- .../Util/SmoothThrottle.cs | 64 +- ReallifeGamemode.Server/Util/TaxiContract.cs | 10 +- ReallifeGamemode.Server/Util/ThreadTimers.cs | 82 +- .../Util/TransactionResult.cs | 14 +- ReallifeGamemode.Server/Util/VehicleSync.cs | 974 +++---- ReallifeGamemode.Server/Wanted/Autowanted.cs | 32 +- ReallifeGamemode.Server/Wanted/Jail.cs | 430 +-- .../Wanted/WantedEscapeTimer.cs | 92 +- 105 files changed, 8184 insertions(+), 8184 deletions(-) diff --git a/ReallifeGamemode.DataService/Startup.cs b/ReallifeGamemode.DataService/Startup.cs index 06830c90..a6349227 100644 --- a/ReallifeGamemode.DataService/Startup.cs +++ b/ReallifeGamemode.DataService/Startup.cs @@ -29,7 +29,7 @@ namespace ReallifeGamemode.DataService private readonly IConfiguration configuration; private readonly IWebHostEnvironment environment; - public Startup(IConfiguration configuration,IWebHostEnvironment environment, ILogger logger) + public Startup(IConfiguration configuration, IWebHostEnvironment environment, ILogger logger) { this.configuration = configuration; this.environment = environment; diff --git a/ReallifeGamemode.Database/Entities/JobVehicle.cs b/ReallifeGamemode.Database/Entities/JobVehicle.cs index 712fa83a..8a66bdad 100644 --- a/ReallifeGamemode.Database/Entities/JobVehicle.cs +++ b/ReallifeGamemode.Database/Entities/JobVehicle.cs @@ -1,6 +1,6 @@ namespace ReallifeGamemode.Database.Entities { - public partial class JobVehicle : ServerVehicle + public partial class JobVehicle : ServerVehicle { public int JobId { get; set; } } diff --git a/ReallifeGamemode.Database/Entities/Turfs.cs b/ReallifeGamemode.Database/Entities/Turfs.cs index 9ca8a6be..a6db8b19 100644 --- a/ReallifeGamemode.Database/Entities/Turfs.cs +++ b/ReallifeGamemode.Database/Entities/Turfs.cs @@ -22,7 +22,7 @@ namespace ReallifeGamemode.Database.Entities public float Range { get; set; } public int Color { get; set; } public string Vector { get; set; } = null; - public int Value {get; set;} = 0; + public int Value { get; set; } = 0; public int MaxValue { get; set; } = 0; public bool Surplus { get; set; } = false; diff --git a/ReallifeGamemode.Database/Migrations/20200126141420_Initial.cs b/ReallifeGamemode.Database/Migrations/20200126141420_Initial.cs index 617406c5..7d1b77ab 100644 --- a/ReallifeGamemode.Database/Migrations/20200126141420_Initial.cs +++ b/ReallifeGamemode.Database/Migrations/20200126141420_Initial.cs @@ -4,1282 +4,1282 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { - public partial class Initial : Migration + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ATMs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Balance = table.Column(nullable: false), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Faulty = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ATMs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BankAccountTransactionLogs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Sender = table.Column(maxLength: 32, nullable: true), - SenderBalance = table.Column(nullable: false), - MoneySent = table.Column(nullable: false), - Receiver = table.Column(maxLength: 32, nullable: true), - ReceiverBalance = table.Column(nullable: false), - NewSenderBalance = table.Column(nullable: false), - NewReceiverBalance = table.Column(nullable: false), - Fee = table.Column(nullable: false), - Origin = table.Column(maxLength: 32, nullable: true), - Timestamp = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - }, - constraints: table => - { - table.PrimaryKey("PK_BankAccountTransactionLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Blips", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Sprite = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Name = table.Column(nullable: true), - Scale = table.Column(nullable: false), - Color = table.Column(nullable: false), - Alpha = table.Column(nullable: false), - DrawDistance = table.Column(nullable: false), - ShortRange = table.Column(nullable: false), - Rotation = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Blips", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BusinessBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Balance = table.Column(nullable: false), - BusinessId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BusinessData", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - BusinessId = table.Column(nullable: false), - Price = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BusinessData", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BusRoutes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BusRoutes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ClothCombinations", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Gender = table.Column(nullable: false), - Top = table.Column(nullable: false), - Torso = table.Column(nullable: false), - Undershirt = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ClothCombinations", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Factions", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 32, nullable: true), - StateOwned = table.Column(nullable: false), - WeaponDealTime = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Factions", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "GotoPoints", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(maxLength: 32, nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GotoPoints", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Groups", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Groups", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Interiors", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), - EnterPosition = table.Column(nullable: true), - ExitPosition = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Interiors", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Locations", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Heading = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Locations", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Markers", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Scale = table.Column(nullable: false), - DirectionX = table.Column(nullable: false), - DirectionY = table.Column(nullable: false), - DirectionZ = table.Column(nullable: false), - RotationX = table.Column(nullable: false), - RotationY = table.Column(nullable: false), - RotationZ = table.Column(nullable: false), - ColorR = table.Column(nullable: false), - ColorG = table.Column(nullable: false), - ColorB = table.Column(nullable: false), - ColorA = table.Column(nullable: false), - Visible = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Markers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Peds", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - HashModel = table.Column(nullable: true), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Heading = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Peds", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Pickups", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - PositionX = table.Column(maxLength: 128, nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - RotationX = table.Column(nullable: false), - RotationY = table.Column(nullable: false), - RotationZ = table.Column(nullable: false), - Vehicle = table.Column(nullable: false), - RespawnTime = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Pickups", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ShopClothes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ClotheId = table.Column(nullable: false), - Gender = table.Column(nullable: false), - TypeId = table.Column(nullable: true), - ComponentId = table.Column(nullable: false), - Category = table.Column(nullable: false), - Price = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ShopClothes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TextLabels", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Text = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - LOS = table.Column(nullable: false), - Font = table.Column(nullable: false), - DrawDistance = table.Column(nullable: false), - ColorR = table.Column(nullable: false), - ColorG = table.Column(nullable: false), - ColorB = table.Column(nullable: false), - ColorA = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TextLabels", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TuningGarages", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TuningGarages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Turfs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: true), - Owner = table.Column(nullable: true), - Name = table.Column(nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Rotation = table.Column(nullable: false), - Range = table.Column(nullable: false), - Color = table.Column(nullable: false), - Vector = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Turfs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "WhitelistEntries", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - SocialClubName = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_WhitelistEntries", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BusRoutesPoints", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - BusRouteId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BusRoutesPoints", x => x.Id); - table.ForeignKey( - name: "FK_BusRoutesPoints_BusRoutes_BusRouteId", - column: x => x.BusRouteId, - principalTable: "BusRoutes", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Doors", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Category = table.Column(nullable: true), - Name = table.Column(nullable: true), - Locked = table.Column(nullable: false), - Model = table.Column(nullable: false), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Radius = table.Column(nullable: false), - FactionId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Doors", x => x.Id); - table.ForeignKey( - name: "FK_Doors_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "DutyClothes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: false), - Gender = table.Column(nullable: false), - SlotType = table.Column(nullable: false), - SlotId = table.Column(nullable: false), - ClothId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DutyClothes", x => x.Id); - table.ForeignKey( - name: "FK_DutyClothes_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FactionBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: false), - Bic = table.Column(maxLength: 12, nullable: true), - Iban = table.Column(maxLength: 32, nullable: true), - Balance = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_FactionBankAccounts_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FactionRanks", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RankName = table.Column(nullable: true), - Order = table.Column(nullable: false), - FactionId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionRanks", x => x.Id); - table.ForeignKey( - name: "FK_FactionRanks_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FactionWeapons", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: true), - WeaponModel = table.Column(nullable: true), - SlotID = table.Column(nullable: false), - Rank = table.Column(nullable: false), - Ammount = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionWeapons", x => x.Id); - table.ForeignKey( - name: "FK_FactionWeapons_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "GroupBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GroupId = table.Column(nullable: true), - Balance = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_GroupBankAccounts_Groups_GroupId", - column: x => x.GroupId, - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 32, nullable: true), - SocialClubName = table.Column(maxLength: 32, nullable: true), - Password = table.Column(maxLength: 64, nullable: true), - LogUserId = table.Column(nullable: false), - RegistrationDate = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Email = table.Column(maxLength: 64, nullable: true), - AdminLevel = table.Column(nullable: false), - Dead = table.Column(nullable: false), - Handmoney = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - CharacterId = table.Column(nullable: true), - BanId = table.Column(nullable: true), - BusinessId = table.Column(nullable: true), - FactionId = table.Column(nullable: true), - FactionLeader = table.Column(nullable: false), - FactionRankId = table.Column(nullable: true), - GroupId = table.Column(nullable: true), - GroupRank = table.Column(nullable: false), - HouseId = table.Column(nullable: true), - JobId = table.Column(nullable: true), - Wanteds = table.Column(nullable: false), - Wage = table.Column(nullable: false), - JailTime = table.Column(nullable: false), - PaydayTimer = table.Column(nullable: false), - DriverLicenseVehicle = table.Column(nullable: false), - FlyingLicensePlane = table.Column(nullable: false), - DriverLicenseBike = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - table.ForeignKey( - name: "FK_Users_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Users_FactionRanks_FactionRankId", - column: x => x.FactionRankId, - principalTable: "FactionRanks", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Users_Groups_GroupId", - column: x => x.GroupId, - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Bans", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Reason = table.Column(nullable: true), - BannedBy = table.Column(nullable: true), - Applied = table.Column(nullable: false), - UntilDateTime = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Bans", x => x.Id); - table.ForeignKey( - name: "FK_Bans_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CharacterClothes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Duty = table.Column(nullable: false), - SlotType = table.Column(nullable: false), - SlotId = table.Column(nullable: false), - ClothId = table.Column(nullable: false), - Texture = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CharacterClothes", x => x.Id); - table.ForeignKey( - name: "FK_CharacterClothes_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Characters", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Gender = table.Column(nullable: false), - Father = table.Column(nullable: false), - Mother = table.Column(nullable: false), - Similarity = table.Column(nullable: false), - SkinSimilarity = table.Column(nullable: false), - NoseWidth = table.Column(nullable: false), - NoseBottomHeight = table.Column(nullable: false), - NoseTipLength = table.Column(nullable: false), - NoseBridgeDepth = table.Column(nullable: false), - NoseTipHeight = table.Column(nullable: false), - NoseBroken = table.Column(nullable: false), - BrowHeight = table.Column(nullable: false), - BrowDepth = table.Column(nullable: false), - CheekboneHeight = table.Column(nullable: false), - CheekboneWidth = table.Column(nullable: false), - CheekDepth = table.Column(nullable: false), - EyeSize = table.Column(nullable: false), - LipThickness = table.Column(nullable: false), - JawWidth = table.Column(nullable: false), - JawShape = table.Column(nullable: false), - ChinHeight = table.Column(nullable: false), - ChinDepth = table.Column(nullable: false), - ChinWidth = table.Column(nullable: false), - ChinIndent = table.Column(nullable: false), - NeckWidth = table.Column(nullable: false), - Blemishes = table.Column(nullable: false), - BlemishesOpacity = table.Column(nullable: false), - FacialHair = table.Column(nullable: false), - FacialHairOpacity = table.Column(nullable: false), - Eyebrows = table.Column(nullable: false), - EyebrowsOpacity = table.Column(nullable: false), - Ageing = table.Column(nullable: false), - AgeingOpacity = table.Column(nullable: false), - Makeup = table.Column(nullable: false), - MakeupOpacity = table.Column(nullable: false), - Blush = table.Column(nullable: false), - BlushOpacity = table.Column(nullable: false), - Complexion = table.Column(nullable: false), - ComplexionOpacity = table.Column(nullable: false), - SunDamage = table.Column(nullable: false), - SunDamageOpacity = table.Column(nullable: false), - Lipstick = table.Column(nullable: false), - LipstickOpacity = table.Column(nullable: false), - Freckles = table.Column(nullable: false), - FrecklesOpacity = table.Column(nullable: false), - ChestHair = table.Column(nullable: false), - ChestHairOpacity = table.Column(nullable: false), - Hair = table.Column(nullable: false), - HairColor = table.Column(nullable: false), - HairHighlightColor = table.Column(nullable: false), - EyebrowColor = table.Column(nullable: false), - BeardColor = table.Column(nullable: false), - EyeColor = table.Column(nullable: false), - BlushColor = table.Column(nullable: false), - LipstickColor = table.Column(nullable: false), - ChestHairColor = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Characters", x => x.Id); - table.ForeignKey( - name: "FK_Characters_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "DeathLogs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - VictimId = table.Column(nullable: false), - KillerId = table.Column(nullable: true), - VictimPositionX = table.Column(nullable: false), - VictimPositionY = table.Column(nullable: false), - VictimPositionZ = table.Column(nullable: false), - VictimHeading = table.Column(nullable: false), - KillerPositionX = table.Column(nullable: false), - KillerPositionY = table.Column(nullable: false), - KillerPositionZ = table.Column(nullable: false), - KillerHeading = table.Column(nullable: false), - CauseOfDeath = table.Column(maxLength: 64, nullable: true), - Timestamp = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - }, - constraints: table => - { - table.PrimaryKey("PK_DeathLogs", x => x.Id); - table.ForeignKey( - name: "FK_DeathLogs_Users_KillerId", - column: x => x.KillerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_DeathLogs_Users_VictimId", - column: x => x.VictimId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Houses", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(nullable: true), - Price = table.Column(nullable: false), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - RentalFee = table.Column(nullable: false), - CanRentIn = table.Column(nullable: false), - OwnerId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Houses", x => x.Id); - table.ForeignKey( - name: "FK_Houses_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "News", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: true), - Caption = table.Column(nullable: true), - Content = table.Column(nullable: true), - Active = table.Column(nullable: false), - Timestamp = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_News", x => x.Id); - table.ForeignKey( - name: "FK_News_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "ServerVehicles", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Model = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Heading = table.Column(nullable: false), - NumberPlate = table.Column(maxLength: 8, nullable: true), - PrimaryColor = table.Column(nullable: false), - SecondaryColor = table.Column(nullable: false), - Locked = table.Column(nullable: false), - Active = table.Column(nullable: false, defaultValue: true), - DistanceDriven = table.Column(nullable: false), - TankAmount = table.Column(nullable: false), - Livery = table.Column(nullable: false), - Discriminator = table.Column(nullable: false), - FactionId = table.Column(nullable: true), - GroupId = table.Column(nullable: true), - JobId = table.Column(nullable: true), - SchoolId = table.Column(nullable: true), - BusinessId = table.Column(nullable: true), - Price = table.Column(nullable: true), - UserId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerVehicles", x => x.Id); - table.ForeignKey( - name: "FK_ServerVehicles_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ServerVehicles_Groups_GroupId", - column: x => x.GroupId, - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ServerVehicles_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Bic = table.Column(maxLength: 12, nullable: true), - Iban = table.Column(maxLength: 32, nullable: true), - Balance = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_UserBankAccounts_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserItems", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ItemId = table.Column(nullable: false), - UserId = table.Column(nullable: false), - Amount = table.Column(nullable: false), - Slot = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserItems", x => x.Id); - table.ForeignKey( - name: "FK_UserItems_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "HouseRentals", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - HouseId = table.Column(nullable: true), - UserId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_HouseRentals", x => x.Id); - table.ForeignKey( - name: "FK_HouseRentals_Houses_HouseId", - column: x => x.HouseId, - principalTable: "Houses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_HouseRentals_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "VehicleItems", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ItemId = table.Column(nullable: false), - VehicleId = table.Column(nullable: false), - Amount = table.Column(nullable: false), - Slot = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VehicleItems", x => x.Id); - table.ForeignKey( - name: "FK_VehicleItems_ServerVehicles_VehicleId", - column: x => x.VehicleId, - principalTable: "ServerVehicles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "VehicleMods", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ServerVehicleId = table.Column(nullable: false), - Slot = table.Column(nullable: false), - ModId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VehicleMods", x => x.Id); - table.ForeignKey( - name: "FK_VehicleMods_ServerVehicles_ServerVehicleId", - column: x => x.ServerVehicleId, - principalTable: "ServerVehicles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Bans_UserId", - table: "Bans", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_BusinessBankAccounts_BusinessId", - table: "BusinessBankAccounts", - column: "BusinessId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_BusRoutesPoints_BusRouteId", - table: "BusRoutesPoints", - column: "BusRouteId"); - - migrationBuilder.CreateIndex( - name: "IX_CharacterClothes_UserId", - table: "CharacterClothes", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Characters_UserId", - table: "Characters", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_DeathLogs_KillerId", - table: "DeathLogs", - column: "KillerId"); - - migrationBuilder.CreateIndex( - name: "IX_DeathLogs_VictimId", - table: "DeathLogs", - column: "VictimId"); - - migrationBuilder.CreateIndex( - name: "IX_Doors_FactionId", - table: "Doors", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_DutyClothes_FactionId", - table: "DutyClothes", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_FactionBankAccounts_FactionId", - table: "FactionBankAccounts", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_FactionRanks_FactionId", - table: "FactionRanks", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_FactionWeapons_FactionId", - table: "FactionWeapons", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_GroupBankAccounts_GroupId", - table: "GroupBankAccounts", - column: "GroupId"); - - migrationBuilder.CreateIndex( - name: "IX_HouseRentals_HouseId", - table: "HouseRentals", - column: "HouseId"); - - migrationBuilder.CreateIndex( - name: "IX_HouseRentals_UserId", - table: "HouseRentals", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Houses_OwnerId", - table: "Houses", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_News_UserId", - table: "News", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_FactionId", - table: "ServerVehicles", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_GroupId", - table: "ServerVehicles", - column: "GroupId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_UserId", - table: "ServerVehicles", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_UserBankAccounts_UserId", - table: "UserBankAccounts", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_UserItems_UserId", - table: "UserItems", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_BanId", - table: "Users", - column: "BanId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_BusinessId", - table: "Users", - column: "BusinessId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Users_CharacterId", - table: "Users", - column: "CharacterId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_FactionId", - table: "Users", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_FactionRankId", - table: "Users", - column: "FactionRankId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_GroupId", - table: "Users", - column: "GroupId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_HouseId", - table: "Users", - column: "HouseId"); - - migrationBuilder.CreateIndex( - name: "IX_VehicleItems_VehicleId", - table: "VehicleItems", - column: "VehicleId"); - - migrationBuilder.CreateIndex( - name: "IX_VehicleMods_ServerVehicleId_Slot", - table: "VehicleMods", - columns: new[] { "ServerVehicleId", "Slot" }, - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Houses_HouseId", - table: "Users", - column: "HouseId", - principalTable: "Houses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Bans_BanId", - table: "Users", - column: "BanId", - principalTable: "Bans", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Characters_CharacterId", - table: "Users", - column: "CharacterId", - principalTable: "Characters", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Bans_Users_UserId", - table: "Bans"); - - migrationBuilder.DropForeignKey( - name: "FK_Characters_Users_UserId", - table: "Characters"); - - migrationBuilder.DropForeignKey( - name: "FK_Houses_Users_OwnerId", - table: "Houses"); - - migrationBuilder.DropTable( - name: "ATMs"); - - migrationBuilder.DropTable( - name: "BankAccountTransactionLogs"); - - migrationBuilder.DropTable( - name: "Blips"); - - migrationBuilder.DropTable( - name: "BusinessBankAccounts"); - - migrationBuilder.DropTable( - name: "BusinessData"); - - migrationBuilder.DropTable( - name: "BusRoutesPoints"); - - migrationBuilder.DropTable( - name: "CharacterClothes"); - - migrationBuilder.DropTable( - name: "ClothCombinations"); - - migrationBuilder.DropTable( - name: "DeathLogs"); - - migrationBuilder.DropTable( - name: "Doors"); - - migrationBuilder.DropTable( - name: "DutyClothes"); - - migrationBuilder.DropTable( - name: "FactionBankAccounts"); - - migrationBuilder.DropTable( - name: "FactionWeapons"); - - migrationBuilder.DropTable( - name: "GotoPoints"); - - migrationBuilder.DropTable( - name: "GroupBankAccounts"); - - migrationBuilder.DropTable( - name: "HouseRentals"); - - migrationBuilder.DropTable( - name: "Interiors"); - - migrationBuilder.DropTable( - name: "Locations"); - - migrationBuilder.DropTable( - name: "Markers"); - - migrationBuilder.DropTable( - name: "News"); - - migrationBuilder.DropTable( - name: "Peds"); - - migrationBuilder.DropTable( - name: "Pickups"); - - migrationBuilder.DropTable( - name: "ShopClothes"); - - migrationBuilder.DropTable( - name: "TextLabels"); - - migrationBuilder.DropTable( - name: "TuningGarages"); - - migrationBuilder.DropTable( - name: "Turfs"); - - migrationBuilder.DropTable( - name: "UserBankAccounts"); - - migrationBuilder.DropTable( - name: "UserItems"); - - migrationBuilder.DropTable( - name: "VehicleItems"); - - migrationBuilder.DropTable( - name: "VehicleMods"); - - migrationBuilder.DropTable( - name: "WhitelistEntries"); - - migrationBuilder.DropTable( - name: "BusRoutes"); - - migrationBuilder.DropTable( - name: "ServerVehicles"); - - migrationBuilder.DropTable( - name: "Users"); - - migrationBuilder.DropTable( - name: "Bans"); - - migrationBuilder.DropTable( - name: "Characters"); - - migrationBuilder.DropTable( - name: "FactionRanks"); - - migrationBuilder.DropTable( - name: "Groups"); - - migrationBuilder.DropTable( - name: "Houses"); - - migrationBuilder.DropTable( - name: "Factions"); - } + migrationBuilder.CreateTable( + name: "ATMs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Faulty = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ATMs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BankAccountTransactionLogs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Sender = table.Column(maxLength: 32, nullable: true), + SenderBalance = table.Column(nullable: false), + MoneySent = table.Column(nullable: false), + Receiver = table.Column(maxLength: 32, nullable: true), + ReceiverBalance = table.Column(nullable: false), + NewSenderBalance = table.Column(nullable: false), + NewReceiverBalance = table.Column(nullable: false), + Fee = table.Column(nullable: false), + Origin = table.Column(maxLength: 32, nullable: true), + Timestamp = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) + }, + constraints: table => + { + table.PrimaryKey("PK_BankAccountTransactionLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Blips", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Sprite = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Name = table.Column(nullable: true), + Scale = table.Column(nullable: false), + Color = table.Column(nullable: false), + Alpha = table.Column(nullable: false), + DrawDistance = table.Column(nullable: false), + ShortRange = table.Column(nullable: false), + Rotation = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Blips", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BusinessBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + BusinessId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BusinessData", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + BusinessId = table.Column(nullable: false), + Price = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BusinessData", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BusRoutes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BusRoutes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ClothCombinations", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Gender = table.Column(nullable: false), + Top = table.Column(nullable: false), + Torso = table.Column(nullable: false), + Undershirt = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClothCombinations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Factions", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(maxLength: 32, nullable: true), + StateOwned = table.Column(nullable: false), + WeaponDealTime = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Factions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GotoPoints", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(maxLength: 32, nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GotoPoints", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Interiors", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true), + EnterPosition = table.Column(nullable: true), + ExitPosition = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Interiors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Locations", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Heading = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Locations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Markers", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Type = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Scale = table.Column(nullable: false), + DirectionX = table.Column(nullable: false), + DirectionY = table.Column(nullable: false), + DirectionZ = table.Column(nullable: false), + RotationX = table.Column(nullable: false), + RotationY = table.Column(nullable: false), + RotationZ = table.Column(nullable: false), + ColorR = table.Column(nullable: false), + ColorG = table.Column(nullable: false), + ColorB = table.Column(nullable: false), + ColorA = table.Column(nullable: false), + Visible = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Markers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Peds", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + HashModel = table.Column(nullable: true), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Heading = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Peds", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Pickups", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + PositionX = table.Column(maxLength: 128, nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + RotationX = table.Column(nullable: false), + RotationY = table.Column(nullable: false), + RotationZ = table.Column(nullable: false), + Vehicle = table.Column(nullable: false), + RespawnTime = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Pickups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ShopClothes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ClotheId = table.Column(nullable: false), + Gender = table.Column(nullable: false), + TypeId = table.Column(nullable: true), + ComponentId = table.Column(nullable: false), + Category = table.Column(nullable: false), + Price = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopClothes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TextLabels", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Text = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + LOS = table.Column(nullable: false), + Font = table.Column(nullable: false), + DrawDistance = table.Column(nullable: false), + ColorR = table.Column(nullable: false), + ColorG = table.Column(nullable: false), + ColorB = table.Column(nullable: false), + ColorA = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TextLabels", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TuningGarages", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TuningGarages", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Turfs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: true), + Owner = table.Column(nullable: true), + Name = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Rotation = table.Column(nullable: false), + Range = table.Column(nullable: false), + Color = table.Column(nullable: false), + Vector = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Turfs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WhitelistEntries", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + SocialClubName = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WhitelistEntries", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BusRoutesPoints", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + BusRouteId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BusRoutesPoints", x => x.Id); + table.ForeignKey( + name: "FK_BusRoutesPoints_BusRoutes_BusRouteId", + column: x => x.BusRouteId, + principalTable: "BusRoutes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Doors", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Category = table.Column(nullable: true), + Name = table.Column(nullable: true), + Locked = table.Column(nullable: false), + Model = table.Column(nullable: false), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Radius = table.Column(nullable: false), + FactionId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Doors", x => x.Id); + table.ForeignKey( + name: "FK_Doors_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "DutyClothes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: false), + Gender = table.Column(nullable: false), + SlotType = table.Column(nullable: false), + SlotId = table.Column(nullable: false), + ClothId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DutyClothes", x => x.Id); + table.ForeignKey( + name: "FK_DutyClothes_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FactionBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: false), + Bic = table.Column(maxLength: 12, nullable: true), + Iban = table.Column(maxLength: 32, nullable: true), + Balance = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_FactionBankAccounts_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FactionRanks", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + RankName = table.Column(nullable: true), + Order = table.Column(nullable: false), + FactionId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionRanks", x => x.Id); + table.ForeignKey( + name: "FK_FactionRanks_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FactionWeapons", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: true), + WeaponModel = table.Column(nullable: true), + SlotID = table.Column(nullable: false), + Rank = table.Column(nullable: false), + Ammount = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionWeapons", x => x.Id); + table.ForeignKey( + name: "FK_FactionWeapons_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "GroupBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GroupId = table.Column(nullable: true), + Balance = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_GroupBankAccounts_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(maxLength: 32, nullable: true), + SocialClubName = table.Column(maxLength: 32, nullable: true), + Password = table.Column(maxLength: 64, nullable: true), + LogUserId = table.Column(nullable: false), + RegistrationDate = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Email = table.Column(maxLength: 64, nullable: true), + AdminLevel = table.Column(nullable: false), + Dead = table.Column(nullable: false), + Handmoney = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + CharacterId = table.Column(nullable: true), + BanId = table.Column(nullable: true), + BusinessId = table.Column(nullable: true), + FactionId = table.Column(nullable: true), + FactionLeader = table.Column(nullable: false), + FactionRankId = table.Column(nullable: true), + GroupId = table.Column(nullable: true), + GroupRank = table.Column(nullable: false), + HouseId = table.Column(nullable: true), + JobId = table.Column(nullable: true), + Wanteds = table.Column(nullable: false), + Wage = table.Column(nullable: false), + JailTime = table.Column(nullable: false), + PaydayTimer = table.Column(nullable: false), + DriverLicenseVehicle = table.Column(nullable: false), + FlyingLicensePlane = table.Column(nullable: false), + DriverLicenseBike = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + table.ForeignKey( + name: "FK_Users_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Users_FactionRanks_FactionRankId", + column: x => x.FactionRankId, + principalTable: "FactionRanks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Users_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Bans", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Reason = table.Column(nullable: true), + BannedBy = table.Column(nullable: true), + Applied = table.Column(nullable: false), + UntilDateTime = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Bans", x => x.Id); + table.ForeignKey( + name: "FK_Bans_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CharacterClothes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Duty = table.Column(nullable: false), + SlotType = table.Column(nullable: false), + SlotId = table.Column(nullable: false), + ClothId = table.Column(nullable: false), + Texture = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CharacterClothes", x => x.Id); + table.ForeignKey( + name: "FK_CharacterClothes_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Characters", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Gender = table.Column(nullable: false), + Father = table.Column(nullable: false), + Mother = table.Column(nullable: false), + Similarity = table.Column(nullable: false), + SkinSimilarity = table.Column(nullable: false), + NoseWidth = table.Column(nullable: false), + NoseBottomHeight = table.Column(nullable: false), + NoseTipLength = table.Column(nullable: false), + NoseBridgeDepth = table.Column(nullable: false), + NoseTipHeight = table.Column(nullable: false), + NoseBroken = table.Column(nullable: false), + BrowHeight = table.Column(nullable: false), + BrowDepth = table.Column(nullable: false), + CheekboneHeight = table.Column(nullable: false), + CheekboneWidth = table.Column(nullable: false), + CheekDepth = table.Column(nullable: false), + EyeSize = table.Column(nullable: false), + LipThickness = table.Column(nullable: false), + JawWidth = table.Column(nullable: false), + JawShape = table.Column(nullable: false), + ChinHeight = table.Column(nullable: false), + ChinDepth = table.Column(nullable: false), + ChinWidth = table.Column(nullable: false), + ChinIndent = table.Column(nullable: false), + NeckWidth = table.Column(nullable: false), + Blemishes = table.Column(nullable: false), + BlemishesOpacity = table.Column(nullable: false), + FacialHair = table.Column(nullable: false), + FacialHairOpacity = table.Column(nullable: false), + Eyebrows = table.Column(nullable: false), + EyebrowsOpacity = table.Column(nullable: false), + Ageing = table.Column(nullable: false), + AgeingOpacity = table.Column(nullable: false), + Makeup = table.Column(nullable: false), + MakeupOpacity = table.Column(nullable: false), + Blush = table.Column(nullable: false), + BlushOpacity = table.Column(nullable: false), + Complexion = table.Column(nullable: false), + ComplexionOpacity = table.Column(nullable: false), + SunDamage = table.Column(nullable: false), + SunDamageOpacity = table.Column(nullable: false), + Lipstick = table.Column(nullable: false), + LipstickOpacity = table.Column(nullable: false), + Freckles = table.Column(nullable: false), + FrecklesOpacity = table.Column(nullable: false), + ChestHair = table.Column(nullable: false), + ChestHairOpacity = table.Column(nullable: false), + Hair = table.Column(nullable: false), + HairColor = table.Column(nullable: false), + HairHighlightColor = table.Column(nullable: false), + EyebrowColor = table.Column(nullable: false), + BeardColor = table.Column(nullable: false), + EyeColor = table.Column(nullable: false), + BlushColor = table.Column(nullable: false), + LipstickColor = table.Column(nullable: false), + ChestHairColor = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Characters", x => x.Id); + table.ForeignKey( + name: "FK_Characters_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DeathLogs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + VictimId = table.Column(nullable: false), + KillerId = table.Column(nullable: true), + VictimPositionX = table.Column(nullable: false), + VictimPositionY = table.Column(nullable: false), + VictimPositionZ = table.Column(nullable: false), + VictimHeading = table.Column(nullable: false), + KillerPositionX = table.Column(nullable: false), + KillerPositionY = table.Column(nullable: false), + KillerPositionZ = table.Column(nullable: false), + KillerHeading = table.Column(nullable: false), + CauseOfDeath = table.Column(maxLength: 64, nullable: true), + Timestamp = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) + }, + constraints: table => + { + table.PrimaryKey("PK_DeathLogs", x => x.Id); + table.ForeignKey( + name: "FK_DeathLogs_Users_KillerId", + column: x => x.KillerId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_DeathLogs_Users_VictimId", + column: x => x.VictimId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Houses", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Type = table.Column(nullable: true), + Price = table.Column(nullable: false), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + RentalFee = table.Column(nullable: false), + CanRentIn = table.Column(nullable: false), + OwnerId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Houses", x => x.Id); + table.ForeignKey( + name: "FK_Houses_Users_OwnerId", + column: x => x.OwnerId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "News", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: true), + Caption = table.Column(nullable: true), + Content = table.Column(nullable: true), + Active = table.Column(nullable: false), + Timestamp = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_News", x => x.Id); + table.ForeignKey( + name: "FK_News_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "ServerVehicles", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Model = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Heading = table.Column(nullable: false), + NumberPlate = table.Column(maxLength: 8, nullable: true), + PrimaryColor = table.Column(nullable: false), + SecondaryColor = table.Column(nullable: false), + Locked = table.Column(nullable: false), + Active = table.Column(nullable: false, defaultValue: true), + DistanceDriven = table.Column(nullable: false), + TankAmount = table.Column(nullable: false), + Livery = table.Column(nullable: false), + Discriminator = table.Column(nullable: false), + FactionId = table.Column(nullable: true), + GroupId = table.Column(nullable: true), + JobId = table.Column(nullable: true), + SchoolId = table.Column(nullable: true), + BusinessId = table.Column(nullable: true), + Price = table.Column(nullable: true), + UserId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ServerVehicles", x => x.Id); + table.ForeignKey( + name: "FK_ServerVehicles_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ServerVehicles_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ServerVehicles_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Bic = table.Column(maxLength: 12, nullable: true), + Iban = table.Column(maxLength: 32, nullable: true), + Balance = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_UserBankAccounts_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ItemId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + Slot = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserItems", x => x.Id); + table.ForeignKey( + name: "FK_UserItems_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "HouseRentals", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + HouseId = table.Column(nullable: true), + UserId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_HouseRentals", x => x.Id); + table.ForeignKey( + name: "FK_HouseRentals_Houses_HouseId", + column: x => x.HouseId, + principalTable: "Houses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_HouseRentals_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "VehicleItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ItemId = table.Column(nullable: false), + VehicleId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + Slot = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VehicleItems", x => x.Id); + table.ForeignKey( + name: "FK_VehicleItems_ServerVehicles_VehicleId", + column: x => x.VehicleId, + principalTable: "ServerVehicles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VehicleMods", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ServerVehicleId = table.Column(nullable: false), + Slot = table.Column(nullable: false), + ModId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VehicleMods", x => x.Id); + table.ForeignKey( + name: "FK_VehicleMods_ServerVehicles_ServerVehicleId", + column: x => x.ServerVehicleId, + principalTable: "ServerVehicles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Bans_UserId", + table: "Bans", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_BusinessBankAccounts_BusinessId", + table: "BusinessBankAccounts", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_BusRoutesPoints_BusRouteId", + table: "BusRoutesPoints", + column: "BusRouteId"); + + migrationBuilder.CreateIndex( + name: "IX_CharacterClothes_UserId", + table: "CharacterClothes", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Characters_UserId", + table: "Characters", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_DeathLogs_KillerId", + table: "DeathLogs", + column: "KillerId"); + + migrationBuilder.CreateIndex( + name: "IX_DeathLogs_VictimId", + table: "DeathLogs", + column: "VictimId"); + + migrationBuilder.CreateIndex( + name: "IX_Doors_FactionId", + table: "Doors", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_DutyClothes_FactionId", + table: "DutyClothes", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_FactionBankAccounts_FactionId", + table: "FactionBankAccounts", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_FactionRanks_FactionId", + table: "FactionRanks", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_FactionWeapons_FactionId", + table: "FactionWeapons", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupBankAccounts_GroupId", + table: "GroupBankAccounts", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_HouseRentals_HouseId", + table: "HouseRentals", + column: "HouseId"); + + migrationBuilder.CreateIndex( + name: "IX_HouseRentals_UserId", + table: "HouseRentals", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Houses_OwnerId", + table: "Houses", + column: "OwnerId"); + + migrationBuilder.CreateIndex( + name: "IX_News_UserId", + table: "News", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_FactionId", + table: "ServerVehicles", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_GroupId", + table: "ServerVehicles", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_UserId", + table: "ServerVehicles", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserBankAccounts_UserId", + table: "UserBankAccounts", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserItems_UserId", + table: "UserItems", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_BanId", + table: "Users", + column: "BanId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_BusinessId", + table: "Users", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Users_CharacterId", + table: "Users", + column: "CharacterId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_FactionId", + table: "Users", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_FactionRankId", + table: "Users", + column: "FactionRankId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_GroupId", + table: "Users", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_HouseId", + table: "Users", + column: "HouseId"); + + migrationBuilder.CreateIndex( + name: "IX_VehicleItems_VehicleId", + table: "VehicleItems", + column: "VehicleId"); + + migrationBuilder.CreateIndex( + name: "IX_VehicleMods_ServerVehicleId_Slot", + table: "VehicleMods", + columns: new[] { "ServerVehicleId", "Slot" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Houses_HouseId", + table: "Users", + column: "HouseId", + principalTable: "Houses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Bans_BanId", + table: "Users", + column: "BanId", + principalTable: "Bans", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Characters_CharacterId", + table: "Users", + column: "CharacterId", + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Bans_Users_UserId", + table: "Bans"); + + migrationBuilder.DropForeignKey( + name: "FK_Characters_Users_UserId", + table: "Characters"); + + migrationBuilder.DropForeignKey( + name: "FK_Houses_Users_OwnerId", + table: "Houses"); + + migrationBuilder.DropTable( + name: "ATMs"); + + migrationBuilder.DropTable( + name: "BankAccountTransactionLogs"); + + migrationBuilder.DropTable( + name: "Blips"); + + migrationBuilder.DropTable( + name: "BusinessBankAccounts"); + + migrationBuilder.DropTable( + name: "BusinessData"); + + migrationBuilder.DropTable( + name: "BusRoutesPoints"); + + migrationBuilder.DropTable( + name: "CharacterClothes"); + + migrationBuilder.DropTable( + name: "ClothCombinations"); + + migrationBuilder.DropTable( + name: "DeathLogs"); + + migrationBuilder.DropTable( + name: "Doors"); + + migrationBuilder.DropTable( + name: "DutyClothes"); + + migrationBuilder.DropTable( + name: "FactionBankAccounts"); + + migrationBuilder.DropTable( + name: "FactionWeapons"); + + migrationBuilder.DropTable( + name: "GotoPoints"); + + migrationBuilder.DropTable( + name: "GroupBankAccounts"); + + migrationBuilder.DropTable( + name: "HouseRentals"); + + migrationBuilder.DropTable( + name: "Interiors"); + + migrationBuilder.DropTable( + name: "Locations"); + + migrationBuilder.DropTable( + name: "Markers"); + + migrationBuilder.DropTable( + name: "News"); + + migrationBuilder.DropTable( + name: "Peds"); + + migrationBuilder.DropTable( + name: "Pickups"); + + migrationBuilder.DropTable( + name: "ShopClothes"); + + migrationBuilder.DropTable( + name: "TextLabels"); + + migrationBuilder.DropTable( + name: "TuningGarages"); + + migrationBuilder.DropTable( + name: "Turfs"); + + migrationBuilder.DropTable( + name: "UserBankAccounts"); + + migrationBuilder.DropTable( + name: "UserItems"); + + migrationBuilder.DropTable( + name: "VehicleItems"); + + migrationBuilder.DropTable( + name: "VehicleMods"); + + migrationBuilder.DropTable( + name: "WhitelistEntries"); + + migrationBuilder.DropTable( + name: "BusRoutes"); + + migrationBuilder.DropTable( + name: "ServerVehicles"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "Bans"); + + migrationBuilder.DropTable( + name: "Characters"); + + migrationBuilder.DropTable( + name: "FactionRanks"); + + migrationBuilder.DropTable( + name: "Groups"); + + migrationBuilder.DropTable( + name: "Houses"); + + migrationBuilder.DropTable( + name: "Factions"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs index 6029e7a1..cc56b539 100644 --- a/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs +++ b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs @@ -3,31 +3,31 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { - public partial class ShopItems : Migration + public partial class ShopItems : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ShopItems", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ShopId = table.Column(nullable: false), - ItemId = table.Column(nullable: false), - Amount = table.Column(nullable: false), - Price = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ShopItems", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ShopItems"); - } + migrationBuilder.CreateTable( + name: "ShopItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ShopId = table.Column(nullable: false), + ItemId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + Price = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopItems", x => x.Id); + }); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ShopItems"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.cs b/ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.cs index c4d7d58f..a0636ff9 100644 --- a/ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.cs +++ b/ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.cs @@ -2,22 +2,22 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class UserWeaponLicense : Migration + public partial class UserWeaponLicense : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "WeaponLicense", - table: "Users", - nullable: false, - defaultValue: false); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "WeaponLicense", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "WeaponLicense", + table: "Users", + nullable: false, + defaultValue: false); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "WeaponLicense", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200317192534_VehicleAddPrice.cs b/ReallifeGamemode.Database/Migrations/20200317192534_VehicleAddPrice.cs index 7ec05ec1..38ebad57 100644 --- a/ReallifeGamemode.Database/Migrations/20200317192534_VehicleAddPrice.cs +++ b/ReallifeGamemode.Database/Migrations/20200317192534_VehicleAddPrice.cs @@ -2,21 +2,21 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class VehicleAddPrice : Migration + public partial class VehicleAddPrice : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "UserVehicle_Price", - table: "ServerVehicles", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "UserVehicle_Price", - table: "ServerVehicles"); - } + migrationBuilder.AddColumn( + name: "UserVehicle_Price", + table: "ServerVehicles", + nullable: true); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UserVehicle_Price", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.cs b/ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.cs index 6554a409..105f64ae 100644 --- a/ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.cs +++ b/ReallifeGamemode.Database/Migrations/20200324175347_HouseWeeklyRentalFee.cs @@ -3,22 +3,22 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { - public partial class HouseWeeklyRentalFee : Migration + public partial class HouseWeeklyRentalFee : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "LastRentSetTime", - table: "Houses", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "LastRentSetTime", - table: "Houses"); - } + migrationBuilder.AddColumn( + name: "LastRentSetTime", + table: "Houses", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LastRentSetTime", + table: "Houses"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200330201122_HouseBankAccounts.cs b/ReallifeGamemode.Database/Migrations/20200330201122_HouseBankAccounts.cs index 11683989..e94870c8 100644 --- a/ReallifeGamemode.Database/Migrations/20200330201122_HouseBankAccounts.cs +++ b/ReallifeGamemode.Database/Migrations/20200330201122_HouseBankAccounts.cs @@ -3,58 +3,58 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { - public partial class HouseBankAccounts : Migration + public partial class HouseBankAccounts : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BankAccountId", - table: "Houses", - nullable: true); + migrationBuilder.AddColumn( + name: "BankAccountId", + table: "Houses", + nullable: true); - migrationBuilder.CreateTable( - name: "HouseBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Balance = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_HouseBankAccounts", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "HouseBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_HouseBankAccounts", x => x.Id); + }); - migrationBuilder.CreateIndex( - name: "IX_Houses_BankAccountId", - table: "Houses", - column: "BankAccountId"); + migrationBuilder.CreateIndex( + name: "IX_Houses_BankAccountId", + table: "Houses", + column: "BankAccountId"); - migrationBuilder.AddForeignKey( - name: "FK_Houses_HouseBankAccounts_BankAccountId", - table: "Houses", - column: "BankAccountId", - principalTable: "HouseBankAccounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Houses_HouseBankAccounts_BankAccountId", - table: "Houses"); - - migrationBuilder.DropTable( - name: "HouseBankAccounts"); - - migrationBuilder.DropIndex( - name: "IX_Houses_BankAccountId", - table: "Houses"); - - migrationBuilder.DropColumn( - name: "BankAccountId", - table: "Houses"); - } + migrationBuilder.AddForeignKey( + name: "FK_Houses_HouseBankAccounts_BankAccountId", + table: "Houses", + column: "BankAccountId", + principalTable: "HouseBankAccounts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Houses_HouseBankAccounts_BankAccountId", + table: "Houses"); + + migrationBuilder.DropTable( + name: "HouseBankAccounts"); + + migrationBuilder.DropIndex( + name: "IX_Houses_BankAccountId", + table: "Houses"); + + migrationBuilder.DropColumn( + name: "BankAccountId", + table: "Houses"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200403035225_TurfSurplusValue.cs b/ReallifeGamemode.Database/Migrations/20200403035225_TurfSurplusValue.cs index 7a2460fb..1b155512 100644 --- a/ReallifeGamemode.Database/Migrations/20200403035225_TurfSurplusValue.cs +++ b/ReallifeGamemode.Database/Migrations/20200403035225_TurfSurplusValue.cs @@ -2,32 +2,32 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class TurfSurplusValue : Migration + public partial class TurfSurplusValue : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Surplus", - table: "Turfs", - nullable: false, - defaultValue: false); + migrationBuilder.AddColumn( + name: "Surplus", + table: "Turfs", + nullable: false, + defaultValue: false); - migrationBuilder.AddColumn( - name: "Value", - table: "Turfs", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Surplus", - table: "Turfs"); - - migrationBuilder.DropColumn( - name: "Value", - table: "Turfs"); - } + migrationBuilder.AddColumn( + name: "Value", + table: "Turfs", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Surplus", + table: "Turfs"); + + migrationBuilder.DropColumn( + name: "Value", + table: "Turfs"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200405102619_TurfMaxValue.cs b/ReallifeGamemode.Database/Migrations/20200405102619_TurfMaxValue.cs index a332baa9..0ac59308 100644 --- a/ReallifeGamemode.Database/Migrations/20200405102619_TurfMaxValue.cs +++ b/ReallifeGamemode.Database/Migrations/20200405102619_TurfMaxValue.cs @@ -2,22 +2,22 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class TurfMaxValue : Migration + public partial class TurfMaxValue : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "MaxValue", - table: "Turfs", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "MaxValue", - table: "Turfs"); - } + migrationBuilder.AddColumn( + name: "MaxValue", + table: "Turfs", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MaxValue", + table: "Turfs"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200407014500_PedType.cs b/ReallifeGamemode.Database/Migrations/20200407014500_PedType.cs index 5862fadf..3995794d 100644 --- a/ReallifeGamemode.Database/Migrations/20200407014500_PedType.cs +++ b/ReallifeGamemode.Database/Migrations/20200407014500_PedType.cs @@ -2,22 +2,22 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class PedType : Migration + public partial class PedType : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Type", - table: "Peds", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Type", - table: "Peds"); - } + migrationBuilder.AddColumn( + name: "Type", + table: "Peds", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Type", + table: "Peds"); + } + } } diff --git a/ReallifeGamemode.Database/Migrations/20200408151729_UserPoints.cs b/ReallifeGamemode.Database/Migrations/20200408151729_UserPoints.cs index 3be998db..d74af285 100644 --- a/ReallifeGamemode.Database/Migrations/20200408151729_UserPoints.cs +++ b/ReallifeGamemode.Database/Migrations/20200408151729_UserPoints.cs @@ -2,22 +2,22 @@ namespace ReallifeGamemode.Database.Migrations { - public partial class UserPoints : Migration + public partial class UserPoints : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Points", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Points", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "Points", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Points", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server.Core/Commands/CommandHandler.cs b/ReallifeGamemode.Server.Core/Commands/CommandHandler.cs index 2477a2f0..91819a84 100644 --- a/ReallifeGamemode.Server.Core/Commands/CommandHandler.cs +++ b/ReallifeGamemode.Server.Core/Commands/CommandHandler.cs @@ -33,7 +33,7 @@ namespace ReallifeGamemode.Server.Core.Commands logger.LogInformation("Player '{Name}' executed command '{command}'", player.Name, command); - if(legacyCommands.Contains(command)) + if (legacyCommands.Contains(command)) { return; } diff --git a/ReallifeGamemode.Server/Business/BikeDealerBusiness.cs b/ReallifeGamemode.Server/Business/BikeDealerBusiness.cs index 7c5b2a9e..48fff290 100644 --- a/ReallifeGamemode.Server/Business/BikeDealerBusiness.cs +++ b/ReallifeGamemode.Server/Business/BikeDealerBusiness.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Server.Business { public class BikeDealerBusiness : CarDealerBusinessBase + { + public override int Id => 8; + + public override string Name => "Motorrad Shop"; + + public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635); + + public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199); + + public override float CarSpawnHeading => 356.6f; + + public override int? BlipSprite => 226; + + public override void Load() { - public override int Id => 8; - - public override string Name => "Motorrad Shop"; - - public override Vector3 Position => new Vector3(1180.997, -394.9542, 68.01635); - - public override Vector3 CarSpawnPositon => new Vector3(1148.25, -369.0642, 67.06199); - - public override float CarSpawnHeading => 356.6f; - - public override int? BlipSprite => 226; - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Business/BoatDealerBusiness.cs b/ReallifeGamemode.Server/Business/BoatDealerBusiness.cs index 56344e6d..4c236a67 100644 --- a/ReallifeGamemode.Server/Business/BoatDealerBusiness.cs +++ b/ReallifeGamemode.Server/Business/BoatDealerBusiness.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Server.Business { public class BoatDealerBusiness : CarDealerBusinessBase + { + public override int Id => 5; + + public override string Name => "Boot Shop"; + + public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922); + + public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062); + + public override float CarSpawnHeading => 356.6f; + + public override int? BlipSprite => 410; + + public override void Load() { - public override int Id => 5; - - public override string Name => "Boot Shop"; - - public override Vector3 Position => new Vector3(-712.2401, -1298.818, 5.101922); - - public override Vector3 CarSpawnPositon => new Vector3(-792.5602, -1433.158, 1.333062); - - public override float CarSpawnHeading => 356.6f; - - public override int? BlipSprite => 410; - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Business/BusinessBase.cs b/ReallifeGamemode.Server/Business/BusinessBase.cs index 96041536..2e4e8b01 100644 --- a/ReallifeGamemode.Server/Business/BusinessBase.cs +++ b/ReallifeGamemode.Server/Business/BusinessBase.cs @@ -10,188 +10,188 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Business { public abstract class BusinessBase : BankAccountHolder, IBankAccountOwner + { + private TextLabel _informationLabel; + private ColShape _colShape; + private Blip _blip; + private Marker _marker; + + public virtual int? BlipSprite { get; } = null; + + public abstract int Id { get; } + + public abstract string Name { get; } + + public abstract Vector3 Position { get; } + + public override BusinessBankAccount BankAccount { - private TextLabel _informationLabel; - private ColShape _colShape; - private Blip _blip; - private Marker _marker; - - public virtual int? BlipSprite { get; } = null; - - public abstract int Id { get; } - - public abstract string Name { get; } - - public abstract Vector3 Position { get; } - - public override BusinessBankAccount BankAccount + get + { + using (var dbContext = new DatabaseContext()) { - get - { - using (var dbContext = new DatabaseContext()) - { - return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault(); - } - } - - set => throw new NotImplementedException(); + return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).FirstOrDefault(); } + } - public override int? BankAccountId - { - get - { - using (var dbContext = new DatabaseContext()) - { - return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault(); - } - } - - set => throw new NotImplementedException(); - } - - public override string BankAccountName => Name; - - public IBankAccount GetBankAccount(DatabaseContext databaseContext = null) - { - if (databaseContext == null) - { - using (databaseContext = new DatabaseContext()) - { - return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id); - } - } - else - { - return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id); - } - } - - public void Setup() - { - _informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255)); - _marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255)); - - if (BlipSprite != null) - { - _blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true); - } - - _colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f); - _colShape.OnEntityEnterColShape += EntityEnterBusinessColShape; - _colShape.OnEntityExitColShape += EntityExitBusinessColShape; - - if (GetBankAccount() == null) - { - NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name); - using (var dbContext = new DatabaseContext()) - { - dbContext.BusinessBankAccounts.Add(new BusinessBankAccount() - { - BusinessId = Id, - Balance = 0 - }); - dbContext.SaveChanges(); - } - } - - BusinessData data = GetData(); - - if (data == null) - { - using (var dbContext = new DatabaseContext()) - { - data = new BusinessData() - { - BusinessId = this.Id, - Price = -1 - }; - - dbContext.BusinessData.Add(data); - - dbContext.SaveChanges(); - } - } - } - - private void EntityExitBusinessColShape(ColShape colShape, Player client) - { - client.TriggerEvent("SERVER:Business_RemoveHelp", true); - } - - public BusinessData GetData(DatabaseContext dbContext = null) - { - if (dbContext == null) - { - using (dbContext = new DatabaseContext()) - { - return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault(); - } - } - else - { - return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault(); - } - } - - private void EntityEnterBusinessColShape(ColShape colShape, Player client) - { - if (client.IsInVehicle || !client.IsLoggedIn()) return; - - SendBusinessDataToPlayer(client); - client.TriggerEvent("SERVER:Business_ShowMenuHelp"); - } - - public void SendBusinessDataToPlayer(Player player) - { - User owner = GetOwner(); - - int state = -1; // Keine Beziehung - - if (owner == null) // Kein Besitzer - { - state = 0; - } - else if (owner.Id == player.GetUser()?.Id) // Besitzer - { - state = 1; - } - - var business = new - { - this.Name, - Price = this.GetData().Price.ToMoneyString(), - Balance = this.GetBankAccount().Balance.ToMoneyString() - }; - - player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state); - } - - public void Update(int? money = null) - { - if (money == null) money = GetBankAccount()?.Balance ?? 0; - User owner = GetOwner(); - string infoText = Name; - if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString(); - else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}"; - _informationLabel.Text = infoText; - } - - public User GetOwner(DatabaseContext dbContext = null) - { - if (dbContext == null) - { - using (dbContext = new DatabaseContext()) - { - return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id); - } - } - else - { - return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id); - } - } - - public abstract void Load(); + set => throw new NotImplementedException(); } + + public override int? BankAccountId + { + get + { + using (var dbContext = new DatabaseContext()) + { + return dbContext.BusinessBankAccounts.Where(b => b.BusinessId == this.Id).Select(b => b.Id).FirstOrDefault(); + } + } + + set => throw new NotImplementedException(); + } + + public override string BankAccountName => Name; + + public IBankAccount GetBankAccount(DatabaseContext databaseContext = null) + { + if (databaseContext == null) + { + using (databaseContext = new DatabaseContext()) + { + return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id); + } + } + else + { + return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id); + } + } + + public void Setup() + { + _informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255)); + _marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255)); + + if (BlipSprite != null) + { + _blip = NAPI.Blip.CreateBlip(BlipSprite.Value, Position, 1f, 4, Name, shortRange: true); + } + + _colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f); + _colShape.OnEntityEnterColShape += EntityEnterBusinessColShape; + _colShape.OnEntityExitColShape += EntityExitBusinessColShape; + + if (GetBankAccount() == null) + { + NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name); + using (var dbContext = new DatabaseContext()) + { + dbContext.BusinessBankAccounts.Add(new BusinessBankAccount() + { + BusinessId = Id, + Balance = 0 + }); + dbContext.SaveChanges(); + } + } + + BusinessData data = GetData(); + + if (data == null) + { + using (var dbContext = new DatabaseContext()) + { + data = new BusinessData() + { + BusinessId = this.Id, + Price = -1 + }; + + dbContext.BusinessData.Add(data); + + dbContext.SaveChanges(); + } + } + } + + private void EntityExitBusinessColShape(ColShape colShape, Player client) + { + client.TriggerEvent("SERVER:Business_RemoveHelp", true); + } + + public BusinessData GetData(DatabaseContext dbContext = null) + { + if (dbContext == null) + { + using (dbContext = new DatabaseContext()) + { + return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault(); + } + } + else + { + return dbContext.BusinessData.Where(b => b.BusinessId == this.Id).FirstOrDefault(); + } + } + + private void EntityEnterBusinessColShape(ColShape colShape, Player client) + { + if (client.IsInVehicle || !client.IsLoggedIn()) return; + + SendBusinessDataToPlayer(client); + client.TriggerEvent("SERVER:Business_ShowMenuHelp"); + } + + public void SendBusinessDataToPlayer(Player player) + { + User owner = GetOwner(); + + int state = -1; // Keine Beziehung + + if (owner == null) // Kein Besitzer + { + state = 0; + } + else if (owner.Id == player.GetUser()?.Id) // Besitzer + { + state = 1; + } + + var business = new + { + this.Name, + Price = this.GetData().Price.ToMoneyString(), + Balance = this.GetBankAccount().Balance.ToMoneyString() + }; + + player.TriggerEvent("SERVER:Business_SetData", JsonConvert.SerializeObject(business), state); + } + + public void Update(int? money = null) + { + if (money == null) money = GetBankAccount()?.Balance ?? 0; + User owner = GetOwner(); + string infoText = Name; + if (owner == null) infoText += "\n~g~Zum Verkauf\n~s~Preis: ~y~" + this.GetData().Price.ToMoneyString(); + else infoText += $"\nBesitzer: ~g~{owner.Name}\n~s~Kasse: ~y~{money.ToMoneyString()}"; + _informationLabel.Text = infoText; + } + + public User GetOwner(DatabaseContext dbContext = null) + { + if (dbContext == null) + { + using (dbContext = new DatabaseContext()) + { + return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id); + } + } + else + { + return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id); + } + } + + public abstract void Load(); + } } diff --git a/ReallifeGamemode.Server/Business/CarDealerBusinessBase.cs b/ReallifeGamemode.Server/Business/CarDealerBusinessBase.cs index a2817f1c..66cd65da 100644 --- a/ReallifeGamemode.Server/Business/CarDealerBusinessBase.cs +++ b/ReallifeGamemode.Server/Business/CarDealerBusinessBase.cs @@ -3,9 +3,9 @@ namespace ReallifeGamemode.Server.Business { public abstract class CarDealerBusinessBase : BusinessBase - { - public abstract Vector3 CarSpawnPositon { get; } - public abstract float CarSpawnHeading { get; } + { + public abstract Vector3 CarSpawnPositon { get; } + public abstract float CarSpawnHeading { get; } public override int? BlipSprite => 225; } diff --git a/ReallifeGamemode.Server/Business/PremiumDeluxeMotorsportCarDealerBusiness.cs b/ReallifeGamemode.Server/Business/PremiumDeluxeMotorsportCarDealerBusiness.cs index 3a6ea721..f143c95a 100644 --- a/ReallifeGamemode.Server/Business/PremiumDeluxeMotorsportCarDealerBusiness.cs +++ b/ReallifeGamemode.Server/Business/PremiumDeluxeMotorsportCarDealerBusiness.cs @@ -3,19 +3,19 @@ namespace ReallifeGamemode.Server.Business { internal class PremiumDeluxeMotorsportCarDealerBusiness : CarDealerBusinessBase + { + public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5); + + public override float CarSpawnHeading => 90; + + public override int Id => 4; + + public override string Name => "Premium Deluxe Motorsport"; + + public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42); + + public override void Load() { - public override Vector3 CarSpawnPositon => new Vector3(-59, -1108.1, 26.5); - - public override float CarSpawnHeading => 90; - - public override int Id => 4; - - public override string Name => "Premium Deluxe Motorsport"; - - public override Vector3 Position => new Vector3(-31.56, -1113.5, 26.42); - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Business/ShopBusiness.cs b/ReallifeGamemode.Server/Business/ShopBusiness.cs index 8fc01140..d8f1f5cf 100644 --- a/ReallifeGamemode.Server/Business/ShopBusiness.cs +++ b/ReallifeGamemode.Server/Business/ShopBusiness.cs @@ -3,15 +3,15 @@ namespace ReallifeGamemode.Server.Business { public class ShopBusiness : BusinessBase + { + public override int Id => 2; + + public override string Name => "24/7 Business"; + + public override Vector3 Position => new Vector3(-443, 1134, 326); + + public override void Load() { - public override int Id => 2; - - public override string Name => "24/7 Business"; - - public override Vector3 Position => new Vector3(-443, 1134, 326); - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Business/TelefonBusiness.cs b/ReallifeGamemode.Server/Business/TelefonBusiness.cs index e31e1deb..f77978f5 100644 --- a/ReallifeGamemode.Server/Business/TelefonBusiness.cs +++ b/ReallifeGamemode.Server/Business/TelefonBusiness.cs @@ -3,15 +3,15 @@ namespace ReallifeGamemode.Server.Business { public class TelefonBusiness : BusinessBase + { + public override int Id => 1; + + public override string Name => "Telefon Business"; + + public override Vector3 Position => new Vector3(-423, 1130, 326); + + public override void Load() { - public override int Id => 1; - - public override string Name => "Telefon Business"; - - public override Vector3 Position => new Vector3(-423, 1130, 326); - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Business/VapidCarDealerBusiness.cs b/ReallifeGamemode.Server/Business/VapidCarDealerBusiness.cs index 336ddc55..923aa527 100644 --- a/ReallifeGamemode.Server/Business/VapidCarDealerBusiness.cs +++ b/ReallifeGamemode.Server/Business/VapidCarDealerBusiness.cs @@ -3,19 +3,19 @@ namespace ReallifeGamemode.Server.Business { public class VapidCarDealerBusiness : CarDealerBusinessBase + { + public override int Id => 3; + + public override string Name => "Vapid Autohaus"; + + public override Vector3 Position => new Vector3(-177, -1156, 23); + + public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5); + + public override float CarSpawnHeading => 356.6f; + + public override void Load() { - public override int Id => 3; - - public override string Name => "Vapid Autohaus"; - - public override Vector3 Position => new Vector3(-177, -1156, 23); - - public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5); - - public override float CarSpawnHeading => 356.6f; - - public override void Load() - { - } } + } } diff --git a/ReallifeGamemode.Server/Classes/TempBlip.cs b/ReallifeGamemode.Server/Classes/TempBlip.cs index 8f4113ff..fc27c86d 100644 --- a/ReallifeGamemode.Server/Classes/TempBlip.cs +++ b/ReallifeGamemode.Server/Classes/TempBlip.cs @@ -1,12 +1,12 @@ namespace ReallifeGamemode.Server.Classes { public class TempBlip - { - public byte Color { get; set; } - public string Name { get; set; } - public byte Transparency { get; set; } - public bool ShortRange { get; set; } - public uint Sprite { get; set; } - public float Scale { get; set; } - } + { + public byte Color { get; set; } + public string Name { get; set; } + public byte Transparency { get; set; } + public bool ShortRange { get; set; } + public uint Sprite { get; set; } + public float Scale { get; set; } + } } diff --git a/ReallifeGamemode.Server/DrivingSchool/Licenses.cs b/ReallifeGamemode.Server/DrivingSchool/Licenses.cs index 3fabb853..7b6a8083 100644 --- a/ReallifeGamemode.Server/DrivingSchool/Licenses.cs +++ b/ReallifeGamemode.Server/DrivingSchool/Licenses.cs @@ -3,25 +3,25 @@ namespace ReallifeGamemode.Server.DrivingSchool { public class Licenses + { + [JsonProperty("drivingLicenseCar")] + public bool CarLicense { get; set; } + + [JsonProperty("drivingLicenseBike")] + public bool BikeLicense { get; set; } + + [JsonProperty("flightLicensePlane")] + public bool PlaneLicense { get; set; } + + [JsonProperty("weaponLicense")] + public bool WeaponLicense { get; set; } + + public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense) { - [JsonProperty("drivingLicenseCar")] - public bool CarLicense { get; set; } - - [JsonProperty("drivingLicenseBike")] - public bool BikeLicense { get; set; } - - [JsonProperty("flightLicensePlane")] - public bool PlaneLicense { get; set; } - - [JsonProperty("weaponLicense")] - public bool WeaponLicense { get; set; } - - public Licenses(bool CarLicense, bool BikeLicense, bool PlaneLicense, bool weaponLicense) - { - this.CarLicense = CarLicense; - this.BikeLicense = BikeLicense; - this.PlaneLicense = PlaneLicense; - this.WeaponLicense = weaponLicense; - } + this.CarLicense = CarLicense; + this.BikeLicense = BikeLicense; + this.PlaneLicense = PlaneLicense; + this.WeaponLicense = weaponLicense; } + } } diff --git a/ReallifeGamemode.Server/Events/Chat.cs b/ReallifeGamemode.Server/Events/Chat.cs index cf4619e0..e20a7499 100644 --- a/ReallifeGamemode.Server/Events/Chat.cs +++ b/ReallifeGamemode.Server/Events/Chat.cs @@ -5,16 +5,16 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Events { public class Chat : Script + { + [ServerEvent(Event.ChatMessage)] + public void ChatEvent(Player player, string message) { - [ServerEvent(Event.ChatMessage)] - public void ChatEvent(Player player, string message) - { - string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", ""); - if (serverMsg.Trim().Length == 0) return; - NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p => - { - ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}"); - }); - } + string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", ""); + if (serverMsg.Trim().Length == 0) return; + NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p => + { + ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}"); + }); } -} \ No newline at end of file + } +} diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index be46aac2..ff67e254 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -22,49 +22,49 @@ using ReallifeGamemode.Server.Wanted; namespace ReallifeGamemode.Server.Events { public class Death : Script + { + [ServerEvent(Event.PlayerDeath)] + public void OnPlayerDeath(Player player, Player killer, uint reason) { - [ServerEvent(Event.PlayerDeath)] - public void OnPlayerDeath(Player player, Player killer, uint reason) + if (!player.IsLoggedIn()) player.Kick(); + player.SetData("isDead", true); + + //TODO: Zum Full Release entfernen + ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString()); + + int? killerId; + float killerPosX; + float killerPosY; + float killerPosZ; + float killerHeading; + + if (killer == null || killer.IsNull) + { + killerId = null; + killerPosX = -1; + killerPosY = -1; + killerPosZ = -1; + killerHeading = -1; + } + else + { + killerId = killer.GetUser().Id; + killerPosX = killer.Position.X; + killerPosY = killer.Position.Y; + killerPosZ = killer.Position.Z; + killerHeading = killer.Heading; + if (player.HasData("inGangWar") && killer.HasData("inGangWar")) { - if (!player.IsLoggedIn()) player.Kick(); - player.SetData("isDead", true); + Gangwar.Gangwar.GangwarKill(killer, player); + } - //TODO: Zum Full Release entfernen - ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString()); - - int? killerId; - float killerPosX; - float killerPosY; - float killerPosZ; - float killerHeading; - - if (killer == null || killer.IsNull) - { - killerId = null; - killerPosX = -1; - killerPosY = -1; - killerPosZ = -1; - killerHeading = -1; - } - else - { - killerId = killer.GetUser().Id; - killerPosX = killer.Position.X; - killerPosY = killer.Position.Y; - killerPosZ = killer.Position.Z; - killerHeading = killer.Heading; - if (player.HasData("inGangWar") && killer.HasData("inGangWar")) - { - Gangwar.Gangwar.GangwarKill(killer, player); - } - - if (player != killer) - { - Autowanted.Check_AutoWanted(killer, player); - string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")"; - ChatService.BroadcastAdmin(message, AdminLevel.ADMIN); - } - } + if (player != killer) + { + Autowanted.Check_AutoWanted(killer, player); + string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")"; + ChatService.BroadcastAdmin(message, AdminLevel.ADMIN); + } + } User user = player.GetUser(); if (user.JailTime <= 0) @@ -83,75 +83,75 @@ namespace ReallifeGamemode.Server.Events }; Medic.AddTaskToList(reviveTask); - if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true) - { - player.TriggerEvent("startDeathTimer", true); - } - else - { - player.TriggerEvent("startDeathTimer", false); - } - - //TODO PICTURE NOTIFICATION + SOUND für Medics - - player.ClearAttachments(); - - using (var userDeath = new DatabaseContext()) - { - List fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList(); - foreach (var item in fItem) - { - IItem iItem = InventoryManager.GetItemById(item.ItemId); - if (iItem is IWeaponDealItem obj) - { - int amount = item.Amount; - - Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0); - //new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f); - Random r = new Random(); - GTANetworkAPI.Object grndObject; - Vector3 textPos = dropPosition; - - dropPosition.Z -= 1.05f; - grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0); - - GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition }; - TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0); - GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl); - - userDeath.Remove(item); - } - } - - var dead = new Database.Entities.Logs.Death - { - VictimId = player.GetUser().Id, - KillerId = killerId, - KillerPositionX = killerPosX, - KillerPositionY = killerPosY, - KillerPositionZ = killerPosZ, - KillerHeading = killerHeading, - VictimPositionX = player.Position.X, - VictimPositionY = player.Position.Y, - VictimPositionZ = player.Position.Z, - VictimHeading = player.Heading, - CauseOfDeath = reason.ToString() - }; - userDeath.DeathLogs.Add(dead); - userDeath.SaveChanges(); - } - } - - //JailTime.cs - Jail.Check_PutBehindBars(player); - } - - [RemoteEvent("RespawnPlayerAtHospital")] - public void RespawnPlayerAtHospital(Player player) + if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true) { - player.SetData("isDead", false); - player.RemoveAllWeapons(); - NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5)); + player.TriggerEvent("startDeathTimer", true); } + else + { + player.TriggerEvent("startDeathTimer", false); + } + + //TODO PICTURE NOTIFICATION + SOUND für Medics + + player.ClearAttachments(); + + using (var userDeath = new DatabaseContext()) + { + List fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList(); + foreach (var item in fItem) + { + IItem iItem = InventoryManager.GetItemById(item.ItemId); + if (iItem is IWeaponDealItem obj) + { + int amount = item.Amount; + + Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0); + //new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f); + Random r = new Random(); + GTANetworkAPI.Object grndObject; + Vector3 textPos = dropPosition; + + dropPosition.Z -= 1.05f; + grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0); + + GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition }; + TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0); + GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl); + + userDeath.Remove(item); + } + } + + var dead = new Database.Entities.Logs.Death + { + VictimId = player.GetUser().Id, + KillerId = killerId, + KillerPositionX = killerPosX, + KillerPositionY = killerPosY, + KillerPositionZ = killerPosZ, + KillerHeading = killerHeading, + VictimPositionX = player.Position.X, + VictimPositionY = player.Position.Y, + VictimPositionZ = player.Position.Z, + VictimHeading = player.Heading, + CauseOfDeath = reason.ToString() + }; + userDeath.DeathLogs.Add(dead); + userDeath.SaveChanges(); + } + } + + //JailTime.cs + Jail.Check_PutBehindBars(player); } -} \ No newline at end of file + + [RemoteEvent("RespawnPlayerAtHospital")] + public void RespawnPlayerAtHospital(Player player) + { + player.SetData("isDead", false); + player.RemoveAllWeapons(); + NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5)); + } + } +} diff --git a/ReallifeGamemode.Server/Events/Disconnect.cs b/ReallifeGamemode.Server/Events/Disconnect.cs index 4da12d49..1efbaf96 100644 --- a/ReallifeGamemode.Server/Events/Disconnect.cs +++ b/ReallifeGamemode.Server/Events/Disconnect.cs @@ -16,50 +16,50 @@ using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Events { public class Disconnect : Script + { + [ServerEvent(Event.PlayerDisconnected)] + public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason) { - [ServerEvent(Event.PlayerDisconnected)] - public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason) - { - if (!player.IsLoggedIn()) return; + if (!player.IsLoggedIn()) return; - if (type == DisconnectionType.Left) - { - NAPI.Util.ConsoleOutput(player.Name + " left"); - } - if (type == DisconnectionType.Kicked) - { - NAPI.Util.ConsoleOutput(player.Name + " kicked"); - } - if (type == DisconnectionType.Timeout) - { - NAPI.Util.ConsoleOutput(player.Name + " Timeoutet"); - } + if (type == DisconnectionType.Left) + { + NAPI.Util.ConsoleOutput(player.Name + " left"); + } + if (type == DisconnectionType.Kicked) + { + NAPI.Util.ConsoleOutput(player.Name + " kicked"); + } + if (type == DisconnectionType.Timeout) + { + NAPI.Util.ConsoleOutput(player.Name + " Timeoutet"); + } - if (GlobalHelper.DutyAdmins.Contains(player)) - { - GlobalHelper.DutyAdmins.Remove(player); - } + if (GlobalHelper.DutyAdmins.Contains(player)) + { + GlobalHelper.DutyAdmins.Remove(player); + } - if (player.GetUser().IsAdmin(AdminLevel.MAPPING)) - { - ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING); - } + if (player.GetUser().IsAdmin(AdminLevel.MAPPING)) + { + ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING); + } - JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1); - if (job != null) job.StopJob(player, true); + JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1); + if (job != null) job.StopJob(player, true); - using (var saveUser = new DatabaseContext()) - { - var user = player.GetUser(saveUser); - Vector3 pos = player.Position; + using (var saveUser = new DatabaseContext()) + { + var user = player.GetUser(saveUser); + Vector3 pos = player.Position; - user.PositionX = pos.X; - user.PositionY = pos.Y; - user.PositionZ = pos.Z; - saveUser.SaveChanges(); - user.Dead = player.HasData("isDead") ? (bool)player.GetData("isDead") : false; - } - player.SetData("isLoggedIn", false); - } + user.PositionX = pos.X; + user.PositionY = pos.Y; + user.PositionZ = pos.Z; + saveUser.SaveChanges(); + user.Dead = player.HasData("isDead") ? (bool)player.GetData("isDead") : false; + } + player.SetData("isLoggedIn", false); } + } } diff --git a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs index 9da246ef..09ad23c7 100644 --- a/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs +++ b/ReallifeGamemode.Server/Events/EnterVehicleAttempt.cs @@ -8,49 +8,49 @@ using ReallifeGamemode.Server.WeaponDeal; namespace ReallifeGamemode.Server.Events { public class EnterVehicleAttempt : Script + { + [ServerEvent(Event.PlayerEnterVehicleAttempt)] + public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat) { - [ServerEvent(Event.PlayerEnterVehicleAttempt)] - public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat) + if ((VehicleHash)vehicle.Model == VehicleHash.Dune3) + { + if (seat == 1) seat = 0; + else if (seat == 0) seat = 1; + } + + if (seat != 0) return; + + User u = player.GetUser(); + + if (vehicle.GetServerVehicle() is FactionVehicle veh) + { + if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player))) { - if ((VehicleHash)vehicle.Model == VehicleHash.Dune3) - { - if (seat == 1) seat = 0; - else if (seat == 0) seat = 1; - } - - if (seat != 0) return; - - User u = player.GetUser(); - - if (vehicle.GetServerVehicle() is FactionVehicle veh) - { - if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player))) - { - if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3) - { - if (WeaponDealManager.checkWeaponDbyVehicle(vehicle)) - return; - } - player.StopAnimation(); - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); - return; - } - } - if (vehicle.GetServerVehicle() is SchoolVehicle sVeh) - { - if (!player.HasData("ActiveSchool")) - { - player.StopAnimation(); - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); - return; - } - if (sVeh.SchoolId != player.GetData("ActiveSchool")) - { - player.StopAnimation(); - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); - return; - } - } + if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3) + { + if (WeaponDealManager.checkWeaponDbyVehicle(vehicle)) + return; + } + player.StopAnimation(); + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); + return; } + } + if (vehicle.GetServerVehicle() is SchoolVehicle sVeh) + { + if (!player.HasData("ActiveSchool")) + { + player.StopAnimation(); + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); + return; + } + if (sVeh.SchoolId != player.GetData("ActiveSchool")) + { + player.StopAnimation(); + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true); + return; + } + } } + } } diff --git a/ReallifeGamemode.Server/Events/Inventory.cs b/ReallifeGamemode.Server/Events/Inventory.cs index c2c7df99..e0aec817 100644 --- a/ReallifeGamemode.Server/Events/Inventory.cs +++ b/ReallifeGamemode.Server/Events/Inventory.cs @@ -11,65 +11,65 @@ using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Events { public class Inventory : Script + { + [RemoteEvent("getNearVehicles")] + public void SrvEvent_GetNearVehicles(Player client) { - [RemoteEvent("getNearVehicles")] - public void SrvEvent_GetNearVehicles(Player client) + var user = client.GetUser(); + if (!client.IsInVehicle) + { + using (var context = new DatabaseContext()) { - var user = client.GetUser(); - if (!client.IsInVehicle) - { - using (var context = new DatabaseContext()) - { - foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles()) - { - List vehicleInventory = new List(); - if (veh.Position.DistanceTo(client.Position) < 5f) - { - if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen) - { - vehicleInventory = getVehItem(veh); - } - client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray()); - return; - } - } - } - } - } - - public List getVehItem(GTANetworkAPI.Vehicle veh) - { - List iName = new List(); - List iAmount = new List(); - List iId = new List(); + foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles()) + { List vehicleInventory = new List(); - var inventoryWeight = 0; - using (var context = new DatabaseContext()) + if (veh.Position.DistanceTo(client.Position) < 5f) { - ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context); - List vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id); - foreach (var vehItem in vehicleItems) - { - IItem iItem = InventoryManager.GetItemById(vehItem.ItemId); - var currentItemWeight = iItem.Gewicht * vehItem.Amount; - inventoryWeight += currentItemWeight; - - iName.Add(iItem.Name); - iAmount.Add(vehItem.Amount); - iId.Add(iItem.Id); - } - var vehInv = new VehicleInventory - { - ID = serverVehicle.Id, - currentWeight = inventoryWeight, - totalWeight = 250, - ivehName = iName.ToArray(), - ivehAmount = iAmount.ToArray(), - ivehId = iId.ToArray() - }; - vehicleInventory.Add(vehInv); + if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen) + { + vehicleInventory = getVehItem(veh); + } + client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray()); + return; } - return vehicleInventory; + } } + } } + + public List getVehItem(GTANetworkAPI.Vehicle veh) + { + List iName = new List(); + List iAmount = new List(); + List iId = new List(); + List vehicleInventory = new List(); + var inventoryWeight = 0; + using (var context = new DatabaseContext()) + { + ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context); + List vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id); + foreach (var vehItem in vehicleItems) + { + IItem iItem = InventoryManager.GetItemById(vehItem.ItemId); + var currentItemWeight = iItem.Gewicht * vehItem.Amount; + inventoryWeight += currentItemWeight; + + iName.Add(iItem.Name); + iAmount.Add(vehItem.Amount); + iId.Add(iItem.Id); + } + var vehInv = new VehicleInventory + { + ID = serverVehicle.Id, + currentWeight = inventoryWeight, + totalWeight = 250, + ivehName = iName.ToArray(), + ivehAmount = iAmount.ToArray(), + ivehId = iId.ToArray() + }; + vehicleInventory.Add(vehInv); + } + return vehicleInventory; + } + } } diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index 301c1fbc..0638c157 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -19,141 +19,141 @@ using ReallifeGamemode.Server.Wanted; namespace ReallifeGamemode.Server.Events { public class Login : Script + { + [RemoteEvent("CLIENT:Login_LoginRequest")] + public void OnPlayerLogin(Player player, string username, string password) { - [RemoteEvent("CLIENT:Login_LoginRequest")] - public void OnPlayerLogin(Player player, string username, string password) + using (var dbContext = new DatabaseContext()) + { + var user = dbContext.Users + .Include(u => u.Group) + .Include(u => u.BankAccount) + .SingleOrDefault(b => b.Name == username); + + if (user == null) { - using (var dbContext = new DatabaseContext()) - { - var user = dbContext.Users - .Include(u => u.Group) - .Include(u => u.BankAccount) - .SingleOrDefault(b => b.Name == username); - - if (user == null) - { - player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!"); - } - else - { - if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password)) - { - player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!"); - //TODO ?? Log einbauen für den bösen Bub. - player.Kick(); - } - if (user.Password != NAPI.Util.GetHashSha256(password)) - { - player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!"); - } - else - { - player.Name = username; - player.TriggerEvent("SERVER:Login_Success"); - player.SetData("isLoggedIn", true); - player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true)); - player.SetData("spec", true); - player.SetData("duty", false); - player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0); - Gangwar.Gangwar.loadPlayer(player); - if (user.FactionLeader) - { - player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); - } - if (user.IsAdmin(AdminLevel.HEADADMIN)) - { - player.SetData("editmode", false); - player.SetData("quicksavemode", "none"); - } - - var userBankAccount = user.BankAccount; - userBankAccount.Balance = userBankAccount.Balance; - - user.Wanteds = user.Wanteds; - - if (user.Group != null) - { - string msg = $"{player.Name} ist wieder online."; - ChatService.BroadcastGroup(msg, user.Group); - } - - if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName)) - { - ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING); - } - else if (user.IsAdmin(AdminLevel.MAPPING)) - { - ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING); - } - - var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList(); - player.SetData("items", userItems); - - switch (user.FactionId) - { - case null: - player.SetSharedData("blipColor", 0); - break; - - case 8: - player.SetSharedData("blipColor", 83); - break; - - case 7: - player.SetSharedData("blipColor", 52); - break; - - case 4: - player.SetSharedData("blipColor", 5); - break; - } - - if (user.CharacterId == null) - { - var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension"); - currentPlayerCreatorDimension++; - NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension); - player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension"); - player.Position = new Vector3(402.8664, -996.4108, -99.00027); - player.Rotation = new Vector3(0, 0, 180); - player.TriggerEvent("toggleCreator"); - } - else - { - CharacterCreator.ApplyCharacter(player); - UpdateCharacterCloth.LoadCharacterDefaults(player); - if (user.JailTime <= 0) - { - NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0); - } - else - { - Jail.Check_PutBehindBars(player); - } - } - - player.TriggerEvent("draw", player.Name, player.Handle.Value); - if (user.Dead == true) - { - if (user.IsAdmin(AdminLevel.ADMIN) == true) - { - player.TriggerEvent("startDeathTimer", true); - player.Health = 0; - } - else - { - player.TriggerEvent("startDeathTimer", false); - player.Health = 0; - } - player.SetData("isDead", true); - } - else - { - player.SetData("isDead", false); - } - } - } - } + player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!"); } + else + { + if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password)) + { + player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!"); + //TODO ?? Log einbauen für den bösen Bub. + player.Kick(); + } + if (user.Password != NAPI.Util.GetHashSha256(password)) + { + player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!"); + } + else + { + player.Name = username; + player.TriggerEvent("SERVER:Login_Success"); + player.SetData("isLoggedIn", true); + player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true)); + player.SetData("spec", true); + player.SetData("duty", false); + player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0); + Gangwar.Gangwar.loadPlayer(player); + if (user.FactionLeader) + { + player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + } + if (user.IsAdmin(AdminLevel.HEADADMIN)) + { + player.SetData("editmode", false); + player.SetData("quicksavemode", "none"); + } + + var userBankAccount = user.BankAccount; + userBankAccount.Balance = userBankAccount.Balance; + + user.Wanteds = user.Wanteds; + + if (user.Group != null) + { + string msg = $"{player.Name} ist wieder online."; + ChatService.BroadcastGroup(msg, user.Group); + } + + if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName)) + { + ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING); + } + else if (user.IsAdmin(AdminLevel.MAPPING)) + { + ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING); + } + + var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList(); + player.SetData("items", userItems); + + switch (user.FactionId) + { + case null: + player.SetSharedData("blipColor", 0); + break; + + case 8: + player.SetSharedData("blipColor", 83); + break; + + case 7: + player.SetSharedData("blipColor", 52); + break; + + case 4: + player.SetSharedData("blipColor", 5); + break; + } + + if (user.CharacterId == null) + { + var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension"); + currentPlayerCreatorDimension++; + NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension); + player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension"); + player.Position = new Vector3(402.8664, -996.4108, -99.00027); + player.Rotation = new Vector3(0, 0, 180); + player.TriggerEvent("toggleCreator"); + } + else + { + CharacterCreator.ApplyCharacter(player); + UpdateCharacterCloth.LoadCharacterDefaults(player); + if (user.JailTime <= 0) + { + NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0); + } + else + { + Jail.Check_PutBehindBars(player); + } + } + + player.TriggerEvent("draw", player.Name, player.Handle.Value); + if (user.Dead == true) + { + if (user.IsAdmin(AdminLevel.ADMIN) == true) + { + player.TriggerEvent("startDeathTimer", true); + player.Health = 0; + } + else + { + player.TriggerEvent("startDeathTimer", false); + player.Health = 0; + } + player.SetData("isDead", true); + } + else + { + player.SetData("isDead", false); + } + } + } + } } + } } diff --git a/ReallifeGamemode.Server/Events/ResourceStop.cs b/ReallifeGamemode.Server/Events/ResourceStop.cs index 285c3844..8673d4c1 100644 --- a/ReallifeGamemode.Server/Events/ResourceStop.cs +++ b/ReallifeGamemode.Server/Events/ResourceStop.cs @@ -11,24 +11,24 @@ using ReallifeGamemode.Database.Models; namespace ReallifeGamemode.Server.Events { public class ResourceStop : Script + { + [ServerEvent(Event.ResourceStop)] + public void OnResourceStop() { - [ServerEvent(Event.ResourceStop)] - public void OnResourceStop() + var users = NAPI.Pools.GetAllPlayers(); + + foreach (Player user in users) + { + using (var saveUsers = new DatabaseContext()) { - var users = NAPI.Pools.GetAllPlayers(); + var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name); - foreach (Player user in users) - { - using (var saveUsers = new DatabaseContext()) - { - var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name); - - saveUser.PositionX = user.Position.X; - saveUser.PositionY = user.Position.Y; - saveUser.PositionZ = user.Position.Z; - saveUsers.SaveChanges(); - } - } + saveUser.PositionX = user.Position.X; + saveUser.PositionY = user.Position.Y; + saveUser.PositionZ = user.Position.Z; + saveUsers.SaveChanges(); } + } } + } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index 4e91d05a..ad040010 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -9,253 +9,253 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Events { public class UpdateCharacterCloth : Script + { + [RemoteEvent("updateDutyProp")] + public void UpdateDutyProp(Player player, int componentId, int componentVariation) { - [RemoteEvent("updateDutyProp")] - public void UpdateDutyProp(Player player, int componentId, int componentVariation) - { - if (componentId != -1) - { - player.SetAccessories(componentId, componentVariation, 0); - } - else - { - player.ClearAccessory(0); - player.ClearAccessory(1); - player.ClearAccessory(2); - } - } - - [RemoteEvent("updateDutyCloth")] - public void UpdateDutyCloth(Player player, int componentId, int componentVariation) - { - if (componentId == 11) - { - //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) - using (var context = new DatabaseContext()) - { - var character = player.GetUser().GetCharacter(); - - var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender); - player.SetClothes(11, componentVariation, 0); - if (combination != null) - { - player.SetClothes(3, combination.Torso, 0); - player.SetClothes(8, combination.Undershirt, 0); - } - } - } - else - { - player.SetClothes(componentId, componentVariation, 0); - } - } - - [RemoteEvent("saveCharacterCloth")] - public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId) - { - using (var context = new DatabaseContext()) - { - int[] slotType = JsonConvert.DeserializeObject(JSlotType); - int[] slotId = JsonConvert.DeserializeObject(JSlotId); - int[] clothId = JsonConvert.DeserializeObject(JClothId); - - User user = client.GetUser(); - user = context.Users.FirstOrDefault(u => u.Id == user.Id); - - var character = client.GetUser().GetCharacter(); - - var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id); - if (charClothes == null) - { - for (var x = 0; x < slotType.Length; x++) - { - CharacterCloth newCloth = new CharacterCloth - { - UserId = user.Id, - - Duty = true, - - SlotType = (byte)slotType[x], - SlotId = slotId[x], - ClothId = clothId[x] - }; - context.CharacterClothes.Add(newCloth); - } - if (user.GetCharacter().Gender == false) - { - CharacterCloth newTorso = new CharacterCloth - { - UserId = user.Id, - - Duty = true, - - SlotType = 0, - SlotId = 3, - ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso - }; - CharacterCloth newUndershirt = new CharacterCloth - { - UserId = user.Id, - - Duty = true, - - SlotType = 0, - SlotId = 8, - ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt - }; - context.CharacterClothes.Add(newTorso); - context.CharacterClothes.Add(newUndershirt); - } - } - else - { - for (var x = 0; x < slotType.Length; x++) - { - var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]); - loopCloth.ClothId = clothId[x]; - } - CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); - CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8); - - torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso; - undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt; - } - context.SaveChanges(); - } - LoadCharacterDefaults(client); - } - - [RemoteEvent("defaultCharacterCloth")] - public static void LoadCharacterDefaults(Player player) - { - User user = player.GetUser(); - using (var context = new DatabaseContext()) - { - List charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false); - player.ClearAccessory(0); - player.ClearAccessory(1); - player.ClearAccessory(2); - player.ClearAccessory(6); - player.ClearAccessory(7); - - foreach (var cloth in charClothes) - { - if (cloth.SlotType == 1) - { - player.SetAccessories(cloth.SlotId, cloth.ClothId, 0); - } - else - { - player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture); - } - } - } - } - - [RemoteEvent("SERVER:BuyCharacterClothes")] - public void RmtEvent_BuyClothes(Player client, string type, string jsonData) - { - /* - * [0] ComponentID - * [1] TextureID - * [2] ClotheID - * [3] TorsoID - * [4] UndershirtID - * [5] UndershirtTextureID - * [6] Price - */ - - int[] data = JsonConvert.DeserializeObject(jsonData); - User user = client.GetUser(); - if (user.Handmoney < data[6]) - { - client.TriggerEvent("clothesMenu:Error"); - return; - } - - if (type == "clothe") - { - if (data[0] == 11)//for tops - { - client.SetClothes(11, data[2], data[1]); //set Top - client.SetClothes(8, data[4], data[5]); //set undershirt - client.SetClothes(3, data[3], 0); //set Torso - } - else - { - client.SetClothes(data[0], data[2], data[1]); - } - using (var dbContext = new DatabaseContext()) - { - var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false); - - if (clothes == null) - { - CharacterCloth newCloth = new CharacterCloth - { - UserId = user.Id, - - Duty = false, - - SlotType = 0, - SlotId = data[0], - ClothId = data[2], - Texture = data[1] - }; - dbContext.CharacterClothes.Add(newCloth); - } - else - { - clothes.ClothId = data[2]; - clothes.Texture = data[1]; - } - if (data[0] == 11) - { - var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false); - var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false); - if (torso == null) - { - CharacterCloth newTorso = new CharacterCloth - { - UserId = user.Id, - - Duty = false, - - SlotType = 0, - SlotId = 3, - ClothId = data[3] - }; - dbContext.CharacterClothes.Add(newTorso); - } - else - { - torso.ClothId = data[3]; - } - if (undershirt == null) - { - CharacterCloth newUndershirt = new CharacterCloth - { - UserId = user.Id, - Duty = false, - SlotType = 0, - SlotId = 8, - ClothId = data[4], - Texture = data[5] - }; - dbContext.CharacterClothes.Add(newUndershirt); - } - else - { - undershirt.ClothId = data[4]; - undershirt.Texture = data[5]; - } - } - client.GetUser(dbContext).Handmoney -= data[6]; - dbContext.SaveChanges(); - client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); - } - client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); - } - } + if (componentId != -1) + { + player.SetAccessories(componentId, componentVariation, 0); + } + else + { + player.ClearAccessory(0); + player.ClearAccessory(1); + player.ClearAccessory(2); + } } + + [RemoteEvent("updateDutyCloth")] + public void UpdateDutyCloth(Player player, int componentId, int componentVariation) + { + if (componentId == 11) + { + //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) + using (var context = new DatabaseContext()) + { + var character = player.GetUser().GetCharacter(); + + var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender); + player.SetClothes(11, componentVariation, 0); + if (combination != null) + { + player.SetClothes(3, combination.Torso, 0); + player.SetClothes(8, combination.Undershirt, 0); + } + } + } + else + { + player.SetClothes(componentId, componentVariation, 0); + } + } + + [RemoteEvent("saveCharacterCloth")] + public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId) + { + using (var context = new DatabaseContext()) + { + int[] slotType = JsonConvert.DeserializeObject(JSlotType); + int[] slotId = JsonConvert.DeserializeObject(JSlotId); + int[] clothId = JsonConvert.DeserializeObject(JClothId); + + User user = client.GetUser(); + user = context.Users.FirstOrDefault(u => u.Id == user.Id); + + var character = client.GetUser().GetCharacter(); + + var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id); + if (charClothes == null) + { + for (var x = 0; x < slotType.Length; x++) + { + CharacterCloth newCloth = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = (byte)slotType[x], + SlotId = slotId[x], + ClothId = clothId[x] + }; + context.CharacterClothes.Add(newCloth); + } + if (user.GetCharacter().Gender == false) + { + CharacterCloth newTorso = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = 0, + SlotId = 3, + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso + }; + CharacterCloth newUndershirt = new CharacterCloth + { + UserId = user.Id, + + Duty = true, + + SlotType = 0, + SlotId = 8, + ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt + }; + context.CharacterClothes.Add(newTorso); + context.CharacterClothes.Add(newUndershirt); + } + } + else + { + for (var x = 0; x < slotType.Length; x++) + { + var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]); + loopCloth.ClothId = clothId[x]; + } + CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); + CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8); + + torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso; + undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt; + } + context.SaveChanges(); + } + LoadCharacterDefaults(client); + } + + [RemoteEvent("defaultCharacterCloth")] + public static void LoadCharacterDefaults(Player player) + { + User user = player.GetUser(); + using (var context = new DatabaseContext()) + { + List charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false); + player.ClearAccessory(0); + player.ClearAccessory(1); + player.ClearAccessory(2); + player.ClearAccessory(6); + player.ClearAccessory(7); + + foreach (var cloth in charClothes) + { + if (cloth.SlotType == 1) + { + player.SetAccessories(cloth.SlotId, cloth.ClothId, 0); + } + else + { + player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture); + } + } + } + } + + [RemoteEvent("SERVER:BuyCharacterClothes")] + public void RmtEvent_BuyClothes(Player client, string type, string jsonData) + { + /* + * [0] ComponentID + * [1] TextureID + * [2] ClotheID + * [3] TorsoID + * [4] UndershirtID + * [5] UndershirtTextureID + * [6] Price + */ + + int[] data = JsonConvert.DeserializeObject(jsonData); + User user = client.GetUser(); + if (user.Handmoney < data[6]) + { + client.TriggerEvent("clothesMenu:Error"); + return; + } + + if (type == "clothe") + { + if (data[0] == 11)//for tops + { + client.SetClothes(11, data[2], data[1]); //set Top + client.SetClothes(8, data[4], data[5]); //set undershirt + client.SetClothes(3, data[3], 0); //set Torso + } + else + { + client.SetClothes(data[0], data[2], data[1]); + } + using (var dbContext = new DatabaseContext()) + { + var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false); + + if (clothes == null) + { + CharacterCloth newCloth = new CharacterCloth + { + UserId = user.Id, + + Duty = false, + + SlotType = 0, + SlotId = data[0], + ClothId = data[2], + Texture = data[1] + }; + dbContext.CharacterClothes.Add(newCloth); + } + else + { + clothes.ClothId = data[2]; + clothes.Texture = data[1]; + } + if (data[0] == 11) + { + var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false); + var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false); + if (torso == null) + { + CharacterCloth newTorso = new CharacterCloth + { + UserId = user.Id, + + Duty = false, + + SlotType = 0, + SlotId = 3, + ClothId = data[3] + }; + dbContext.CharacterClothes.Add(newTorso); + } + else + { + torso.ClothId = data[3]; + } + if (undershirt == null) + { + CharacterCloth newUndershirt = new CharacterCloth + { + UserId = user.Id, + Duty = false, + SlotType = 0, + SlotId = 8, + ClothId = data[4], + Texture = data[5] + }; + dbContext.CharacterClothes.Add(newUndershirt); + } + else + { + undershirt.ClothId = data[4]; + undershirt.Texture = data[5]; + } + } + client.GetUser(dbContext).Handmoney -= data[6]; + dbContext.SaveChanges(); + client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + } + client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); + } + } + } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs b/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs index 204ece77..33955c27 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterElevator.cs @@ -4,15 +4,15 @@ using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Events { public class UpdateCharacterElevator : Script + { + [RemoteEvent("sendPlayerToStage")] + public void SaveWeaponSelection(Player client, string stage) { - [RemoteEvent("sendPlayerToStage")] - public void SaveWeaponSelection(Player client, string stage) - { - ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage); - if (elevator != null) - { - client.Position = elevator.Position; - } - } + ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage); + if (elevator != null) + { + client.Position = elevator.Position; + } } + } } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterWeapon.cs b/ReallifeGamemode.Server/Events/UpdateCharacterWeapon.cs index 1e29236b..84b41b59 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterWeapon.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterWeapon.cs @@ -7,101 +7,101 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Events { public class UpdateCharacterWeapon : Script + { + [RemoteEvent("updateWeaponSelection")] + public void UpdateWeaponSelection(Player client, string weaponModel, int slot) { - [RemoteEvent("updateWeaponSelection")] - public void UpdateWeaponSelection(Player client, string weaponModel, int slot) - { - if (weaponModel == "Keine") - { - client.RemoveAllWeapons(); - return; - } + if (weaponModel == "Keine") + { + client.RemoveAllWeapons(); + return; + } - WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel); + WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel); - if (slot == 1) - { - client.RemoveAllWeapons(); - client.GiveWeapon(weaponHash, 0); - } - if (slot == 2) - { - client.RemoveAllWeapons(); - client.GiveWeapon(weaponHash, 0); - } - if (slot == 3) - { - client.RemoveAllWeapons(); - client.GiveWeapon(weaponHash, 0); - } - if (slot == 4) - { - client.RemoveAllWeapons(); - client.GiveWeapon(weaponHash, 0); - } - } - - [RemoteEvent("cancelWeaponSelection")] - public void CancelWeaponSelection(Player client) - { - client.RemoveAllWeapons(); - } - - [RemoteEvent("saveWeaponSelection")] - public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel) - { - client.RemoveAllWeapons(); - if (!uint.TryParse(primaryModel, out uint primary)) - { - if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2"); - primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}"); - } - if (!uint.TryParse(secondaryModel, out uint secondary)) - { - if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2"); - secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}"); - } - if (!uint.TryParse(meleeModel, out uint melee)) - { - if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2"); - melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}"); - } - - client.GiveWeapon((WeaponHash)primary, 50); - client.GiveWeapon((WeaponHash)secondary, 150); - client.GiveWeapon((WeaponHash)melee, 1); - if (specialModel != "Schutzweste") - { - client.Armor = 0; - if (!uint.TryParse(specialModel, out uint special)) - { - if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2"); - special = NAPI.Util.GetHashKey($"weapon_{specialModel}"); - } - client.GiveWeapon((WeaponHash)special, 50); - } - else - { - client.Armor = 50; - } - - using (var context = new DatabaseContext()) - { - User user = client.GetUser(); - FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault(); - if (slot1 != null) - slot1.Ammount -= 1; - FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault(); - if (slot2 != null) - slot2.Ammount -= 1; - FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault(); - if (slot3 != null) - slot3.Ammount -= 1; - FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault(); - if (slot4 != null) - slot4.Ammount -= 1; - context.SaveChanges(); - } - } + if (slot == 1) + { + client.RemoveAllWeapons(); + client.GiveWeapon(weaponHash, 0); + } + if (slot == 2) + { + client.RemoveAllWeapons(); + client.GiveWeapon(weaponHash, 0); + } + if (slot == 3) + { + client.RemoveAllWeapons(); + client.GiveWeapon(weaponHash, 0); + } + if (slot == 4) + { + client.RemoveAllWeapons(); + client.GiveWeapon(weaponHash, 0); + } } + + [RemoteEvent("cancelWeaponSelection")] + public void CancelWeaponSelection(Player client) + { + client.RemoveAllWeapons(); + } + + [RemoteEvent("saveWeaponSelection")] + public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel) + { + client.RemoveAllWeapons(); + if (!uint.TryParse(primaryModel, out uint primary)) + { + if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2"); + primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}"); + } + if (!uint.TryParse(secondaryModel, out uint secondary)) + { + if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2"); + secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}"); + } + if (!uint.TryParse(meleeModel, out uint melee)) + { + if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2"); + melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}"); + } + + client.GiveWeapon((WeaponHash)primary, 50); + client.GiveWeapon((WeaponHash)secondary, 150); + client.GiveWeapon((WeaponHash)melee, 1); + if (specialModel != "Schutzweste") + { + client.Armor = 0; + if (!uint.TryParse(specialModel, out uint special)) + { + if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2"); + special = NAPI.Util.GetHashKey($"weapon_{specialModel}"); + } + client.GiveWeapon((WeaponHash)special, 50); + } + else + { + client.Armor = 50; + } + + using (var context = new DatabaseContext()) + { + User user = client.GetUser(); + FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault(); + if (slot1 != null) + slot1.Ammount -= 1; + FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault(); + if (slot2 != null) + slot2.Ammount -= 1; + FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault(); + if (slot3 != null) + slot3.Ammount -= 1; + FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault(); + if (slot4 != null) + slot4.Ammount -= 1; + context.SaveChanges(); + } + } + } } diff --git a/ReallifeGamemode.Server/Events/Vehicle.cs b/ReallifeGamemode.Server/Events/Vehicle.cs index 58e8e1e2..d8c8815e 100644 --- a/ReallifeGamemode.Server/Events/Vehicle.cs +++ b/ReallifeGamemode.Server/Events/Vehicle.cs @@ -9,274 +9,274 @@ using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Events { public class Vehicle : Script + { + [RemoteEvent("VehicleMenu_ToggleEngine")] + public void VehicleMenuToggleEngineEvent(Player player) { - [RemoteEvent("VehicleMenu_ToggleEngine")] - public void VehicleMenuToggleEngineEvent(Player player) + if (player.IsInVehicle && player.VehicleSeat == 0) + { + GTANetworkAPI.Vehicle v = player.Vehicle; + + User u = player.GetUser(); + if (u == null) return; + + if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16) { - if (player.IsInVehicle && player.VehicleSeat == 0) - { - GTANetworkAPI.Vehicle v = player.Vehicle; - - User u = player.GetUser(); - if (u == null) return; - - if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16) - { - player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true); - return; - } - - bool state = VehicleStreaming.GetEngineState(v); - ServerVehicle sV = v.GetServerVehicle(); - if (sV != null) - { - if (sV is ShopVehicle) - { - VehicleStreaming.SetEngineState(v, false); - return; - } - else if (sV is FactionVehicle fV) - { - if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player))) - { - player.SendNotification("~r~Du hast keinen Schlüssel."); - return; - } - } - else if (sV is GroupVehicle gV) - { - if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3)) - { - player.SendNotification("~r~Du hast keinen Schlüssel."); - return; - } - } - else if (sV is JobVehicle jV) - { - if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3)) - { - player.SendNotification("~r~Du hast keinen Schlüssel."); - return; - } - } - else if (sV is UserVehicle uV) - { - if (uV.UserId != u.Id) - { - return; - } - } - } - VehicleStreaming.SetEngineState(v, !state); - } + player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true); + return; } - [RemoteEvent("VehicleMenu_LockCar")] - public static void VehicleMenuLockCarEvent(Player player) + bool state = VehicleStreaming.GetEngineState(v); + ServerVehicle sV = v.GetServerVehicle(); + if (sV != null) { - if (player.IsInVehicle && player.VehicleSeat == 0) + if (sV is ShopVehicle) + { + VehicleStreaming.SetEngineState(v, false); + return; + } + else if (sV is FactionVehicle fV) + { + if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player))) { - GTANetworkAPI.Vehicle v = player.Vehicle; - - User u = player.GetUser(); - if (u == null) return; - - bool state = VehicleStreaming.GetLockState(v); - ServerVehicle sV = v.GetServerVehicle(); - - if (sV != null) - { - if (sV is ShopVehicle) - { - VehicleStreaming.SetEngineState(v, false); - return; - } - else if (sV is FactionVehicle fV) - { - if (!fV.GetOwners().Contains(u.FactionId ?? 0)) - { - return; - } - } - else if (sV is UserVehicle uV) - { - if (uV.UserId != u.Id) - { - player.SendNotification("~r~Du hast keinen Schlüssel."); - return; - } - } - else if (sV is JobVehicle) - { - return; - } - else if (sV is SchoolVehicle) - { - return; - } - } - state = !state; - VehicleStreaming.SetLockStatus(v, state); - string msg = "Fahrzeug "; - msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen"; - player.TriggerEvent("vehsync:OpenCar", state); - player.SendNotification(msg); + player.SendNotification("~r~Du hast keinen Schlüssel."); + return; } - else if (!player.IsInVehicle) + } + else if (sV is GroupVehicle gV) + { + if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3)) { - GTANetworkAPI.Vehicle vehicle = null; - foreach (var veh in NAPI.Pools.GetAllVehicles()) - { - if (player.Position.DistanceTo(veh.Position) <= 3f) - { - vehicle = veh; - break; - } - } - - if (vehicle == null) - return; - User u = player.GetUser(); - if (u == null) return; - - bool state = VehicleStreaming.GetLockState(vehicle); - ServerVehicle sV = vehicle.GetServerVehicle(); - - if (sV != null) - { - if (sV is ShopVehicle) - { - VehicleStreaming.SetEngineState(vehicle, false); - return; - } - else if (sV is FactionVehicle fV) - { - if (!fV.GetOwners().Contains(u.FactionId ?? 0)) - { - return; - } - } - else if (sV is UserVehicle uV) - { - if (uV.UserId != u.Id) - { - return; - } - } - else if (sV is JobVehicle) - { - return; - } - } - state = !state; - VehicleStreaming.SetLockStatus(vehicle, state); - string msg = "Fahrzeug "; - msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen"; - player.TriggerEvent("vehsync:OpenCar", state); - player.SendNotification(msg); + player.SendNotification("~r~Du hast keinen Schlüssel."); + return; } - } - - [RemoteEvent("CLIENT:VehicleMenu_ParkCar")] - public void VehicleMenuParkCarEvent(Player player) - { - if (player.IsInVehicle && player.VehicleSeat == 0) + } + else if (sV is JobVehicle jV) + { + if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3)) { - GTANetworkAPI.Vehicle v = player.Vehicle; - - User u = player.GetUser(); - if (u == null) return; - - using (var dbContext = new DatabaseContext()) - { - ServerVehicle sV = v.GetServerVehicle(dbContext); - - if (sV == null) return; - - if (sV is UserVehicle uV) - { - if (uV.UserId != u.Id) - { - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); - return; - } - } - else if (sV is FactionVehicle fV) - { - if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader) - { - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); - return; - } - } - else if (sV is GroupVehicle gV) - { - if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER) - { - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); - return; - } - } - else if (sV is JobVehicle) - { - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); - return; - } - else if (sV is SchoolVehicle) - { - player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); - return; - } - - Vector3 pos = v.Position; - - sV.PositionX = pos.X; - sV.PositionY = pos.Y; - sV.PositionZ = pos.Z; - sV.Heading = v.Heading; - - player.SendNotification("~g~Das Fahrzeug wurde geparkt."); - - dbContext.SaveChanges(); - } + player.SendNotification("~r~Du hast keinen Schlüssel."); + return; } - } - - [RemoteEvent("VehicleMenu_ToggleSingleDoor")] - public void VehicleMenuToggleSingleDoorEvent(Player player, int door) - { - if (!player.IsInVehicle) return; - GTANetworkAPI.Vehicle veh = player.Vehicle; - - DoorID doorId = (DoorID)door; - - DoorState state = VehicleStreaming.GetDoorState(veh, doorId); - - VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen); - } - - [RemoteEvent("VehicleMenu_OpenAllDoors")] - public void VehicleMenuOpenAllDoorsEvent(Player player) - { - if (!player.IsInVehicle) return; - GTANetworkAPI.Vehicle veh = player.Vehicle; - - foreach (DoorID doorId in Enum.GetValues(typeof(DoorID))) + } + else if (sV is UserVehicle uV) + { + if (uV.UserId != u.Id) { - VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen); - } - } - - [RemoteEvent("VehicleMenu_CloseAllDoors")] - public void VehicleMenuCloseAllDoorsEvent(Player player) - { - if (!player.IsInVehicle) return; - GTANetworkAPI.Vehicle veh = player.Vehicle; - - foreach (DoorID doorId in Enum.GetValues(typeof(DoorID))) - { - VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed); + return; } + } } + VehicleStreaming.SetEngineState(v, !state); + } } + + [RemoteEvent("VehicleMenu_LockCar")] + public static void VehicleMenuLockCarEvent(Player player) + { + if (player.IsInVehicle && player.VehicleSeat == 0) + { + GTANetworkAPI.Vehicle v = player.Vehicle; + + User u = player.GetUser(); + if (u == null) return; + + bool state = VehicleStreaming.GetLockState(v); + ServerVehicle sV = v.GetServerVehicle(); + + if (sV != null) + { + if (sV is ShopVehicle) + { + VehicleStreaming.SetEngineState(v, false); + return; + } + else if (sV is FactionVehicle fV) + { + if (!fV.GetOwners().Contains(u.FactionId ?? 0)) + { + return; + } + } + else if (sV is UserVehicle uV) + { + if (uV.UserId != u.Id) + { + player.SendNotification("~r~Du hast keinen Schlüssel."); + return; + } + } + else if (sV is JobVehicle) + { + return; + } + else if (sV is SchoolVehicle) + { + return; + } + } + state = !state; + VehicleStreaming.SetLockStatus(v, state); + string msg = "Fahrzeug "; + msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen"; + player.TriggerEvent("vehsync:OpenCar", state); + player.SendNotification(msg); + } + else if (!player.IsInVehicle) + { + GTANetworkAPI.Vehicle vehicle = null; + foreach (var veh in NAPI.Pools.GetAllVehicles()) + { + if (player.Position.DistanceTo(veh.Position) <= 3f) + { + vehicle = veh; + break; + } + } + + if (vehicle == null) + return; + User u = player.GetUser(); + if (u == null) return; + + bool state = VehicleStreaming.GetLockState(vehicle); + ServerVehicle sV = vehicle.GetServerVehicle(); + + if (sV != null) + { + if (sV is ShopVehicle) + { + VehicleStreaming.SetEngineState(vehicle, false); + return; + } + else if (sV is FactionVehicle fV) + { + if (!fV.GetOwners().Contains(u.FactionId ?? 0)) + { + return; + } + } + else if (sV is UserVehicle uV) + { + if (uV.UserId != u.Id) + { + return; + } + } + else if (sV is JobVehicle) + { + return; + } + } + state = !state; + VehicleStreaming.SetLockStatus(vehicle, state); + string msg = "Fahrzeug "; + msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen"; + player.TriggerEvent("vehsync:OpenCar", state); + player.SendNotification(msg); + } + } + + [RemoteEvent("CLIENT:VehicleMenu_ParkCar")] + public void VehicleMenuParkCarEvent(Player player) + { + if (player.IsInVehicle && player.VehicleSeat == 0) + { + GTANetworkAPI.Vehicle v = player.Vehicle; + + User u = player.GetUser(); + if (u == null) return; + + using (var dbContext = new DatabaseContext()) + { + ServerVehicle sV = v.GetServerVehicle(dbContext); + + if (sV == null) return; + + if (sV is UserVehicle uV) + { + if (uV.UserId != u.Id) + { + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); + return; + } + } + else if (sV is FactionVehicle fV) + { + if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader) + { + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); + return; + } + } + else if (sV is GroupVehicle gV) + { + if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER) + { + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); + return; + } + } + else if (sV is JobVehicle) + { + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); + return; + } + else if (sV is SchoolVehicle) + { + player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken."); + return; + } + + Vector3 pos = v.Position; + + sV.PositionX = pos.X; + sV.PositionY = pos.Y; + sV.PositionZ = pos.Z; + sV.Heading = v.Heading; + + player.SendNotification("~g~Das Fahrzeug wurde geparkt."); + + dbContext.SaveChanges(); + } + } + } + + [RemoteEvent("VehicleMenu_ToggleSingleDoor")] + public void VehicleMenuToggleSingleDoorEvent(Player player, int door) + { + if (!player.IsInVehicle) return; + GTANetworkAPI.Vehicle veh = player.Vehicle; + + DoorID doorId = (DoorID)door; + + DoorState state = VehicleStreaming.GetDoorState(veh, doorId); + + VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen); + } + + [RemoteEvent("VehicleMenu_OpenAllDoors")] + public void VehicleMenuOpenAllDoorsEvent(Player player) + { + if (!player.IsInVehicle) return; + GTANetworkAPI.Vehicle veh = player.Vehicle; + + foreach (DoorID doorId in Enum.GetValues(typeof(DoorID))) + { + VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen); + } + } + + [RemoteEvent("VehicleMenu_CloseAllDoors")] + public void VehicleMenuCloseAllDoorsEvent(Player player) + { + if (!player.IsInVehicle) return; + GTANetworkAPI.Vehicle veh = player.Vehicle; + + foreach (DoorID doorId in Enum.GetValues(typeof(DoorID))) + { + VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed); + } + } + } } diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index ddfccc05..9237290a 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -17,53 +17,53 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Extensions { public static class PlayerExtension + { + /// + /// Gibt das User-Objekt eines Player's zurück. + /// Gibt nichts zurück, wenn der Player nicht eingeloggt ist + /// + /// Der Player, dessen User man bekommen möchte + /// Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will + /// + public static User GetUser(this Player client, DatabaseContext context = null) { - /// - /// Gibt das User-Objekt eines Player's zurück. - /// Gibt nichts zurück, wenn der Player nicht eingeloggt ist - /// - /// Der Player, dessen User man bekommen möchte - /// Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will - /// - public static User GetUser(this Player client, DatabaseContext context = null) - { - context = context ?? new DatabaseContext(); - if (!client.IsLoggedIn()) return null; - return context - .Users - .Include(u => u.Faction) - .Include(u => u.FactionRank) - .Include(u => u.Group) - .Include(u => u.House) - .Include(u => u.BankAccount) - .Where(u => u.Name == client.Name) - .FirstOrDefault(); - } + context = context ?? new DatabaseContext(); + if (!client.IsLoggedIn()) return null; + return context + .Users + .Include(u => u.Faction) + .Include(u => u.FactionRank) + .Include(u => u.Group) + .Include(u => u.House) + .Include(u => u.BankAccount) + .Where(u => u.Name == client.Name) + .FirstOrDefault(); + } - public static Character GetCharacter(this User user, DatabaseContext context = null) + public static Character GetCharacter(this User user, DatabaseContext context = null) + { + if (context == null) + { + using (context = new DatabaseContext()) { - if (context == null) - { - using (context = new DatabaseContext()) - { - return context.Characters.FirstOrDefault(u => u.UserId == user.Id); - } - } - else - { - return context.Characters.FirstOrDefault(u => u.UserId == user.Id); - } + return context.Characters.FirstOrDefault(u => u.UserId == user.Id); } + } + else + { + return context.Characters.FirstOrDefault(u => u.UserId == user.Id); + } + } - /// - /// Gibt zurück, ob ein Player eingeloggt ist - /// - /// Der Player, dessen Login-Status man bekommen möchte - /// - public static bool IsLoggedIn(this Player player) - { - return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false; - } + /// + /// Gibt zurück, ob ein Player eingeloggt ist + /// + /// Der Player, dessen Login-Status man bekommen möchte + /// + public static bool IsLoggedIn(this Player player) + { + return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false; + } public static bool IsDuty(this Player player) { @@ -81,126 +81,126 @@ namespace ReallifeGamemode.Server.Extensions return newpos; } - internal static T GetData(this User user, string key, T nullValue) - { - key += "data_"; - if (!user.Player.HasData(key)) return nullValue; - return JsonConvert.DeserializeObject(user.Player.GetData(key)); - } - - internal static T GetData(this User user, string key) => user.GetData(key, default); - - internal static void SetData(this User user, string key, object value) - { - key += "data_"; - user.Player.SetData(key, JsonConvert.SerializeObject(value)); - } - - internal static void GiveWanteds(this User user, Player cop, int amount, string reason) - { - if (user.Wanteds + amount > 50) - { - ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten"); - return; - } - int newWanteds = user.Wanteds + amount; - using (var dbContext = new DatabaseContext()) - { - User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault(); - dbUser.Wanteds = newWanteds; - dbContext.SaveChanges(); - } - user.Player.SetSharedData("blipColor", 64); - ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : "")); - ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds); - - foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) - { - User copUser = copPlayer.GetUser(); - if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3)) - { - ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + "."); - ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + "."); - ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); - } - else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null) - { - ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + "."); - ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); - } - } - } - - public static FactionRank GetFactionRank(this User user) - { - using (var dbContext = new DatabaseContext()) - { - FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId); - if (toReturn == null) - { - toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId); - } - - if (toReturn == null) - { - toReturn = new FactionRank - { - RankName = "Rang-Fehler" - }; - } - - return toReturn; - } - } - - public static void BanPlayer(this User user, Player admin, string reason, int mins) - { - using (var banUserContext = new DatabaseContext()) - { - int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; - Ban banUser; - - if (mins == 0) - { - ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]"); - banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp }; - - user.Player?.Kick(); - - mins--; - } - else - { - ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]"); - banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 }; - user.Player?.Kick(); - } - - banUserContext.Bans.Add(banUser); - banUserContext.SaveChanges(); - - var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault(); - targetUser.BanId = banUser.Id; - banUserContext.SaveChanges(); - } - } - - public static void UnbanPlayer(this User user) - { - using (var unbanUser = new DatabaseContext()) - { - var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault(); - targetUser.BanId = null; - unbanUser.SaveChanges(); - } - } - - public static List GetItems(this User user) - { - using (var dbContext = new DatabaseContext()) - { - return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList(); - } - } + internal static T GetData(this User user, string key, T nullValue) + { + key += "data_"; + if (!user.Player.HasData(key)) return nullValue; + return JsonConvert.DeserializeObject(user.Player.GetData(key)); } -} \ No newline at end of file + + internal static T GetData(this User user, string key) => user.GetData(key, default); + + internal static void SetData(this User user, string key, object value) + { + key += "data_"; + user.Player.SetData(key, JsonConvert.SerializeObject(value)); + } + + internal static void GiveWanteds(this User user, Player cop, int amount, string reason) + { + if (user.Wanteds + amount > 50) + { + ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 50 nicht überschreiten"); + return; + } + int newWanteds = user.Wanteds + amount; + using (var dbContext = new DatabaseContext()) + { + User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault(); + dbUser.Wanteds = newWanteds; + dbContext.SaveChanges(); + } + user.Player.SetSharedData("blipColor", 64); + ChatService.SendMessage(user.Player, "!{#FF614A}Du hast ein Verbrechen begangen: " + reason + "" + (cop != null ? " | Gemeldet von: " + cop.Name + "." : "")); + ChatService.SendMessage(user.Player, " !{#FFFF00}Fahnundgslevel:~s~ " + newWanteds); + + foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) + { + User copUser = copPlayer.GetUser(); + if (cop != null && (copUser.FactionId == 1 || copUser.FactionId == 3)) + { + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Straftat gemeldet von " + cop.Name + " mit Fahndungslevel " + amount + ". Straftäter: " + user.Name + "."); + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Grund: " + reason + "."); + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); + } + else if ((copUser.FactionId == 1 || copUser.FactionId == 3) && cop == null) + { + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: " + user.Name + " hat eine Straftat begangen. Grund: " + reason + "."); + ChatService.SendMessage(copPlayer, "!{#8181E9}HQ: Der Straftäter: " + user.Name + " wird nun mit Fahndungslevel " + newWanteds + " gesucht."); + } + } + } + + public static FactionRank GetFactionRank(this User user) + { + using (var dbContext = new DatabaseContext()) + { + FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId); + if (toReturn == null) + { + toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId); + } + + if (toReturn == null) + { + toReturn = new FactionRank + { + RankName = "Rang-Fehler" + }; + } + + return toReturn; + } + } + + public static void BanPlayer(this User user, Player admin, string reason, int mins) + { + using (var banUserContext = new DatabaseContext()) + { + int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; + Ban banUser; + + if (mins == 0) + { + ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]"); + banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp }; + + user.Player?.Kick(); + + mins--; + } + else + { + ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]"); + banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 }; + user.Player?.Kick(); + } + + banUserContext.Bans.Add(banUser); + banUserContext.SaveChanges(); + + var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault(); + targetUser.BanId = banUser.Id; + banUserContext.SaveChanges(); + } + } + + public static void UnbanPlayer(this User user) + { + using (var unbanUser = new DatabaseContext()) + { + var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault(); + targetUser.BanId = null; + unbanUser.SaveChanges(); + } + } + + public static List GetItems(this User user) + { + using (var dbContext = new DatabaseContext()) + { + return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList(); + } + } + } +} diff --git a/ReallifeGamemode.Server/Extensions/EnumExtensions.cs b/ReallifeGamemode.Server/Extensions/EnumExtensions.cs index 035e226a..99c0c7f7 100644 --- a/ReallifeGamemode.Server/Extensions/EnumExtensions.cs +++ b/ReallifeGamemode.Server/Extensions/EnumExtensions.cs @@ -4,57 +4,57 @@ using static ReallifeGamemode.Server.Types.AdminLevel; namespace ReallifeGamemode.Server.Extensions { public static class EnumExtensions + { + /// + /// Gibt den richtigen Namen eines Admin Levels zurück + /// + /// Das Admin Level, dessen Namen man bekommen möchte. + /// + public static string GetName(this AdminLevel level) { - /// - /// Gibt den richtigen Namen eines Admin Levels zurück - /// - /// Das Admin Level, dessen Namen man bekommen möchte. - /// - public static string GetName(this AdminLevel level) - { - switch (level) - { - case MAPPING: - return "Mapper"; + switch (level) + { + case MAPPING: + return "Mapper"; - case ENTWICKLUNG: - return "Entwickler"; + case ENTWICKLUNG: + return "Entwickler"; - case SUPPORTER: - return "Supporter"; + case SUPPORTER: + return "Supporter"; - case ADMIN: - case ADMIN2: - case ADMIN3: - return "Admin"; + case ADMIN: + case ADMIN2: + case ADMIN3: + return "Admin"; - case HEADADMIN: - return "Headadmin"; + case HEADADMIN: + return "Headadmin"; - case PROJEKTLEITUNG: - return "Projektleiter"; + case PROJEKTLEITUNG: + return "Projektleiter"; - default: - return "Spieler"; - } - } - - public static string GetName(this GroupRank rank) - { - switch (rank) - { - case GroupRank.OWNER: - return "Besitzer"; - - case GroupRank.MANAGER: - return "Manager"; - - case GroupRank.MEMBER: - return "Mitglied"; - - default: - return "Keiner"; - } - } + default: + return "Spieler"; + } } + + public static string GetName(this GroupRank rank) + { + switch (rank) + { + case GroupRank.OWNER: + return "Besitzer"; + + case GroupRank.MANAGER: + return "Manager"; + + case GroupRank.MEMBER: + return "Mitglied"; + + default: + return "Keiner"; + } + } + } } diff --git a/ReallifeGamemode.Server/Extensions/IntegerExtension.cs b/ReallifeGamemode.Server/Extensions/IntegerExtension.cs index d7297045..6a62a509 100644 --- a/ReallifeGamemode.Server/Extensions/IntegerExtension.cs +++ b/ReallifeGamemode.Server/Extensions/IntegerExtension.cs @@ -1,15 +1,15 @@ namespace ReallifeGamemode.Server.Extensions { public static class IntegerExtension + { + public static string ToMoneyString(this int? money) { - public static string ToMoneyString(this int? money) - { - return ToMoneyString(money ?? 0); - } - - public static string ToMoneyString(this int money) - { - return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim(); - } + return ToMoneyString(money ?? 0); } + + public static string ToMoneyString(this int money) + { + return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "").Trim(); + } + } } diff --git a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs index 25ae9cde..769f0576 100644 --- a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs +++ b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs @@ -7,66 +7,66 @@ using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Extensions { public static class ServerVehicleExtensions + { + public static JobBase GetJob(this JobVehicle vehicle) { - public static JobBase GetJob(this JobVehicle vehicle) - { - return JobManager.GetJob(vehicle.JobId); - } - - public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh); - - public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null) - { - if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh); - Vector3 position = veh.Position; - uint model = (uint)veh.Model; - float heading = veh.Heading; - int c1 = veh.PrimaryColor; - int c2 = veh.SecondaryColor; - Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false); - veh.Livery = veh.Livery; - VehicleStreaming.SetEngineState(newVeh, false); - VehicleStreaming.SetLockStatus(newVeh, veh.Locked); - VehicleManager.AddVehicle(veh, newVeh); - newVeh.Rotation = new Vector3(0, 0, heading); - - newVeh.SetSharedData("drivenDistance", veh.DistanceDriven); - - string numberplate = $"{veh.Id}"; - - if (veh is FactionVehicle fV) - { - numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate; - } - - if (veh is UserVehicle uV) - { - numberplate = $"U{uV.UserId} " + numberplate; - } - - if (veh is ShopVehicle sV) - { - numberplate = "Shop"; - VehicleStreaming.SetLockStatus(newVeh, false); - TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(), - veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255)); - - newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value); - } - - if (veh is GroupVehicle gV) - { - numberplate = $"G{gV.GroupId} " + numberplate; - } - - if (veh is JobVehicle jV) - { - numberplate = $"J{jV.JobId} " + numberplate; - } - NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate); - veh.NumberPlate = numberplate; - - return newVeh; - } + return JobManager.GetJob(vehicle.JobId); } + + public static Vehicle GetVehicle(this ServerVehicle veh) => VehicleManager.GetVehicleFromServerVehicle(veh); + + public static Vehicle Spawn(this ServerVehicle veh, Vehicle currentVeh = null) + { + if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh); + Vector3 position = veh.Position; + uint model = (uint)veh.Model; + float heading = veh.Heading; + int c1 = veh.PrimaryColor; + int c2 = veh.SecondaryColor; + Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false); + veh.Livery = veh.Livery; + VehicleStreaming.SetEngineState(newVeh, false); + VehicleStreaming.SetLockStatus(newVeh, veh.Locked); + VehicleManager.AddVehicle(veh, newVeh); + newVeh.Rotation = new Vector3(0, 0, heading); + + newVeh.SetSharedData("drivenDistance", veh.DistanceDriven); + + string numberplate = $"{veh.Id}"; + + if (veh is FactionVehicle fV) + { + numberplate = $"F{string.Join(".", fV.GetOwners())} " + numberplate; + } + + if (veh is UserVehicle uV) + { + numberplate = $"U{uV.UserId} " + numberplate; + } + + if (veh is ShopVehicle sV) + { + numberplate = "Shop"; + VehicleStreaming.SetLockStatus(newVeh, false); + TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(), + veh.Position.Add(new Vector3(0, 0, 1.3)), 20.0f, 1f, 1, new Color(255, 255, 255)); + + newVeh.SetSharedData("shopVehicleTextLabel", label.Handle.Value); + } + + if (veh is GroupVehicle gV) + { + numberplate = $"G{gV.GroupId} " + numberplate; + } + + if (veh is JobVehicle jV) + { + numberplate = $"J{jV.JobId} " + numberplate; + } + NAPI.Vehicle.SetVehicleNumberPlate(newVeh, numberplate); + veh.NumberPlate = numberplate; + + return newVeh; + } + } } diff --git a/ReallifeGamemode.Server/Extensions/VehicleExtension.cs b/ReallifeGamemode.Server/Extensions/VehicleExtension.cs index b2e1ed7e..9ec5361e 100644 --- a/ReallifeGamemode.Server/Extensions/VehicleExtension.cs +++ b/ReallifeGamemode.Server/Extensions/VehicleExtension.cs @@ -7,15 +7,15 @@ using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Extensions { public static class VehicleExtension + { + public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null) { - public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null) - { - return VehicleManager.GetServerVehicleFromVehicle(veh, context); - } - - public static Player GetDriver(this Vehicle veh) - { - return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault(); - } + return VehicleManager.GetServerVehicleFromVehicle(veh, context); } + + public static Player GetDriver(this Vehicle veh) + { + return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault(); + } + } } diff --git a/ReallifeGamemode.Server/Factions/Medic/Medic.cs b/ReallifeGamemode.Server/Factions/Medic/Medic.cs index 1469c741..3dd8a1ff 100644 --- a/ReallifeGamemode.Server/Factions/Medic/Medic.cs +++ b/ReallifeGamemode.Server/Factions/Medic/Medic.cs @@ -11,93 +11,93 @@ using Newtonsoft.Json; namespace ReallifeGamemode.Server.Factions.Medic { public class Medic : Script + { + public static List ReviveTasks = new List(); + public static List HealTasks = new List(); + public static List FireTasks = new List(); + + public static void AddTaskToList(MedicTask task) { - public static List ReviveTasks = new List(); - public static List HealTasks = new List(); - public static List FireTasks = new List(); + if (task == null) + { + return; + } - public static void AddTaskToList(MedicTask task) - { - if (task == null) - { - return; - } + switch (task.Type) + { + case MedicTaskType.REVIVE: + ReviveTasks.Add(task); + break; - switch (task.Type) - { - case MedicTaskType.REVIVE: - ReviveTasks.Add(task); - break; + case MedicTaskType.HEAL: + HealTasks.Add(task); + break; - case MedicTaskType.HEAL: - HealTasks.Add(task); - break; - - case MedicTaskType.FIRE: - FireTasks.Add(task); - break; - } - } - - public static void RemoveTaskFromList(MedicTask task) - { - if (task == null) - { - return; - } - - switch (task.Type) - { - case MedicTaskType.REVIVE: - ReviveTasks.Remove(task); - break; - - case MedicTaskType.HEAL: - HealTasks.Remove(task); - break; - - case MedicTaskType.FIRE: - FireTasks.Remove(task); - break; - } - } - - [RemoteEvent("loadMedicTasks")] - public void LoadMedicTasks(Player player, int type) - { - switch (type) - { - case 0: - player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks)); - break; - - case 1: - player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks)); - break; - - case 2: - player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks)); - break; - } - } - - [RemoteEvent("updateMedicTask")] - public void UpdateMedicTasks(Player player, int type, int index, string medicName) - { - switch (type) - { - case 0: - ReviveTasks[index].MedicName = medicName; - break; - - case 1: - HealTasks[index].MedicName = medicName; - break; - - case 2: - FireTasks[index].MedicName = medicName; - break; - } - } + case MedicTaskType.FIRE: + FireTasks.Add(task); + break; + } } + + public static void RemoveTaskFromList(MedicTask task) + { + if (task == null) + { + return; + } + + switch (task.Type) + { + case MedicTaskType.REVIVE: + ReviveTasks.Remove(task); + break; + + case MedicTaskType.HEAL: + HealTasks.Remove(task); + break; + + case MedicTaskType.FIRE: + FireTasks.Remove(task); + break; + } + } + + [RemoteEvent("loadMedicTasks")] + public void LoadMedicTasks(Player player, int type) + { + switch (type) + { + case 0: + player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks)); + break; + + case 1: + player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks)); + break; + + case 2: + player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks)); + break; + } + } + + [RemoteEvent("updateMedicTask")] + public void UpdateMedicTasks(Player player, int type, int index, string medicName) + { + switch (type) + { + case 0: + ReviveTasks[index].MedicName = medicName; + break; + + case 1: + HealTasks[index].MedicName = medicName; + break; + + case 2: + FireTasks[index].MedicName = medicName; + break; + } + } + } } diff --git a/ReallifeGamemode.Server/Factions/Medic/MedicTask.cs b/ReallifeGamemode.Server/Factions/Medic/MedicTask.cs index 0c0beb3f..50c0f2a8 100644 --- a/ReallifeGamemode.Server/Factions/Medic/MedicTask.cs +++ b/ReallifeGamemode.Server/Factions/Medic/MedicTask.cs @@ -10,21 +10,21 @@ using GTANetworkAPI; namespace ReallifeGamemode.Server.Factions.Medic { public class MedicTask - { - public string Victim { get; set; } - public Vector3 Position { get; set; } - public MedicTaskType Type { get; set; } - public string CauseOfDeath { get; set; } - public string Description { get; set; } - public string Caller { get; set; } - public DateTime Time { get; set; } - public string MedicName { get; set; } - } + { + public string Victim { get; set; } + public Vector3 Position { get; set; } + public MedicTaskType Type { get; set; } + public string CauseOfDeath { get; set; } + public string Description { get; set; } + public string Caller { get; set; } + public DateTime Time { get; set; } + public string MedicName { get; set; } + } - public enum MedicTaskType - { - REVIVE, - HEAL, - FIRE - } + public enum MedicTaskType + { + REVIVE, + HEAL, + FIRE + } } diff --git a/ReallifeGamemode.Server/Finance/Economy.cs b/ReallifeGamemode.Server/Finance/Economy.cs index d0fc447f..8789e9ba 100644 --- a/ReallifeGamemode.Server/Finance/Economy.cs +++ b/ReallifeGamemode.Server/Finance/Economy.cs @@ -18,64 +18,64 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Finance { public class Economy + { + public static Dictionary Paychecks { get; set; } = new Dictionary(); + + public static (int, float, float) GetEconomyClass(Player client, int wage) { - public static Dictionary Paychecks { get; set; } = new Dictionary(); + int bankAccount = client.GetUser().BankAccount.Balance; + float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000; + float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1; + if (financialInterest >= 0.7) + financialInterest = 0.7f; - public static (int, float, float) GetEconomyClass(Player client, int wage) + if (financialHelp > 2500) + financialHelp = 2500; + + return (bankAccount, financialHelp, financialInterest); + } + + public static int GetVehicleTaxation(Player client) + { + int vehicleTaxation = 0; + using (var dbContext = new DatabaseContext()) + { + User user = client.GetUser(dbContext); + foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id)) { - int bankAccount = client.GetUser().BankAccount.Balance; - float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000; - float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1; - if (financialInterest >= 0.7) - financialInterest = 0.7f; - - if (financialHelp > 2500) - financialHelp = 2500; - - return (bankAccount, financialHelp, financialInterest); + if (uVeh.Price == null) + { + vehicleTaxation += 400; + continue; + } + vehicleTaxation += (int)(uVeh.Price * 0.005f); } + } + return vehicleTaxation; + } - public static int GetVehicleTaxation(Player client) - { - int vehicleTaxation = 0; - using (var dbContext = new DatabaseContext()) - { - User user = client.GetUser(dbContext); - foreach (UserVehicle uVeh in dbContext.UserVehicles.Where(u => u.UserId == user.Id)) - { - if (uVeh.Price == null) - { - vehicleTaxation += 400; - continue; - } - vehicleTaxation += (int)(uVeh.Price * 0.005f); - } - } - return vehicleTaxation; - } + public static float GetPropertyTaxation(Player client) + { + float propertyTaxation = 0; + User user = client.GetUser(); + if (user.HouseId != null) + { + propertyTaxation += user.House.Price * 0.005f; + } - public static float GetPropertyTaxation(Player client) - { - float propertyTaxation = 0; - User user = client.GetUser(); - if (user.HouseId != null) - { - propertyTaxation += user.House.Price * 0.005f; - } + return propertyTaxation; + } - return propertyTaxation; - } + public static void SetPaycheck(Player client) + { + User user = client.GetUser(); + int wage = user.Wage; + (int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage); + float propertyTax = GetPropertyTaxation(client); + int vehicleTaxation = GetVehicleTaxation(client); + int rentalFees = GetRentalFees(client); - public static void SetPaycheck(Player client) - { - User user = client.GetUser(); - int wage = user.Wage; - (int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage); - float propertyTax = GetPropertyTaxation(client); - int vehicleTaxation = GetVehicleTaxation(client); - int rentalFees = GetRentalFees(client); - - int healthInsurance = (int)(user.BankAccount.Balance * 0.001); + int healthInsurance = (int)(user.BankAccount.Balance * 0.001); int? factionMoney = null; @@ -91,85 +91,85 @@ namespace ReallifeGamemode.Server.Finance ReleasePayDay(client, paycheck); } - private static int GetRentalFees(Player client) - { - using (var dbContext = new DatabaseContext()) - { - User user = client.GetUser(); - return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee); - } - } - - public static void ReleasePayDay(Player client, Paycheck paycheck) - { - NAPI.Util.ConsoleOutput("in release payday"); - if (client == null || paycheck == null) - { - return; - } - - NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}"); - - using (var dbContext = new DatabaseContext()) - { - User u = client.GetUser(dbContext); - NAPI.Util.ConsoleOutput("get user"); - u.BankAccount.Balance += paycheck.Amount; - u.Wage = 0; - - u.PaydayTimer = 60; - - NAPI.Util.ConsoleOutput("set sachen"); - - var rentals = dbContext.HouseRentals - .Include(hR => hR.House) - .ThenInclude(h => h.BankAccount) - .Where(hR => hR.UserId == u.Id); - - NAPI.Util.ConsoleOutput("get rentals"); - - dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1); - - if (rentals.Any()) - { - NAPI.Util.ConsoleOutput("hat rentals"); - foreach (var rental in rentals) - { - if (rental?.House?.BankAccount != null) - { - rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); - } - } - } - - dbContext.SaveChanges(); - } - if (paycheck.Amount > 0) - ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~."); - else - ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~."); - } - - public static void Timer_Elapsed() - { - using var dbContext = new DatabaseContext(); - foreach (var player in NAPI.Pools.GetAllPlayers()) - { - User user = player.GetUser(dbContext); - if (player.IsLoggedIn()) - { - if (user.PaydayTimer <= 0) - { - Economy.SetPaycheck(player); - user.PaydayTimer = 60; - } - else if (user.PaydayTimer > 0) - { - user.PaydayTimer -= 1; - } - } - } - dbContext.SaveChanges(); - } + private static int GetRentalFees(Player client) + { + using (var dbContext = new DatabaseContext()) + { + User user = client.GetUser(); + return dbContext.HouseRentals.Where(h => h.UserId == user.Id).Include(h => h.House).Sum(h => h.House.RentalFee); + } } -} \ No newline at end of file + + public static void ReleasePayDay(Player client, Paycheck paycheck) + { + NAPI.Util.ConsoleOutput("in release payday"); + if (client == null || paycheck == null) + { + return; + } + + NAPI.Util.ConsoleOutput($"client = {client.Name}, paycheck = {JsonConvert.SerializeObject(paycheck)}"); + + using (var dbContext = new DatabaseContext()) + { + User u = client.GetUser(dbContext); + NAPI.Util.ConsoleOutput("get user"); + u.BankAccount.Balance += paycheck.Amount; + u.Wage = 0; + + u.PaydayTimer = 60; + + NAPI.Util.ConsoleOutput("set sachen"); + + var rentals = dbContext.HouseRentals + .Include(hR => hR.House) + .ThenInclude(h => h.BankAccount) + .Where(hR => hR.UserId == u.Id); + + NAPI.Util.ConsoleOutput("get rentals"); + + dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += (int)(paycheck.HealthInsurance * 0.1); + + if (rentals.Any()) + { + NAPI.Util.ConsoleOutput("hat rentals"); + foreach (var rental in rentals) + { + if (rental?.House?.BankAccount != null) + { + rental.House.BankAccount.Balance += (int)(rental.House.RentalFee * 0.7); + } + } + } + + dbContext.SaveChanges(); + } + if (paycheck.Amount > 0) + ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt + $~g~" + paycheck.Amount + "~s~."); + else + ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Dein Stundenumsatz beträgt - $~r~" + paycheck.Amount + "~s~."); + } + + public static void Timer_Elapsed() + { + using var dbContext = new DatabaseContext(); + foreach (var player in NAPI.Pools.GetAllPlayers()) + { + User user = player.GetUser(dbContext); + if (player.IsLoggedIn()) + { + if (user.PaydayTimer <= 0) + { + Economy.SetPaycheck(player); + user.PaydayTimer = 60; + } + else if (user.PaydayTimer > 0) + { + user.PaydayTimer -= 1; + } + } + } + dbContext.SaveChanges(); + } + } +} diff --git a/ReallifeGamemode.Server/Finance/Paycheck.cs b/ReallifeGamemode.Server/Finance/Paycheck.cs index 2de6adfb..3f96b286 100644 --- a/ReallifeGamemode.Server/Finance/Paycheck.cs +++ b/ReallifeGamemode.Server/Finance/Paycheck.cs @@ -3,30 +3,30 @@ namespace ReallifeGamemode.Server.Finance { public class Paycheck - { - [JsonProperty("financialHelp")] - public float FinancialHelp { get; set; } = 0; + { + [JsonProperty("financialHelp")] + public float FinancialHelp { get; set; } = 0; - [JsonProperty("financialInterest")] - public float FinancialInterest { get; set; } = 0; + [JsonProperty("financialInterest")] + public float FinancialInterest { get; set; } = 0; - [JsonProperty("vehicleTaxation")] - public int VehicleTaxation { get; set; } = 0; + [JsonProperty("vehicleTaxation")] + public int VehicleTaxation { get; set; } = 0; - [JsonProperty("propertyTaxation")] - public float PropertyTaxation { get; set; } = 0; + [JsonProperty("propertyTaxation")] + public float PropertyTaxation { get; set; } = 0; - [JsonProperty("wage")] - public int Wage { get; set; } = 0; + [JsonProperty("wage")] + public int Wage { get; set; } = 0; - [JsonProperty("amount")] - public int Amount { get; set; } = 0; + [JsonProperty("amount")] + public int Amount { get; set; } = 0; - [JsonProperty("rentalFees")] - public int RentalFees { get; set; } = 0; + [JsonProperty("rentalFees")] + public int RentalFees { get; set; } = 0; - [JsonProperty("healthInsurance")] - public int HealthInsurance { get; set; } = 0; + [JsonProperty("healthInsurance")] + public int HealthInsurance { get; set; } = 0; [JsonProperty("factionMoney")] public int? FactionMoney { get; set; } = 0; @@ -44,4 +44,4 @@ namespace ReallifeGamemode.Server.Finance this.FactionMoney = FactionMoney; } } -} \ No newline at end of file +} diff --git a/ReallifeGamemode.Server/Gangwar/Gangwar.cs b/ReallifeGamemode.Server/Gangwar/Gangwar.cs index aa18b371..08115ea8 100644 --- a/ReallifeGamemode.Server/Gangwar/Gangwar.cs +++ b/ReallifeGamemode.Server/Gangwar/Gangwar.cs @@ -10,217 +10,217 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Gangwar { public class Gangwar : Script + { + public static Turf[] _loadedTurfs; + private static List turfs; + + public static void loadTurfs() { - public static Turf[] _loadedTurfs; - private static List turfs; - - public static void loadTurfs() + _loadedTurfs = null; + using (var context = new DatabaseContext()) + { + turfs = context.Turfs.Select(t => t).ToList(); + List turfing = new List(); + foreach (var t in turfs) { - _loadedTurfs = null; - using (var context = new DatabaseContext()) - { - turfs = context.Turfs.Select(t => t).ToList(); - List turfing = new List(); - foreach (var t in turfs) - { - Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus); - turfing.Add(newTurf); - } - _loadedTurfs = turfing.ToArray(); - } - } - - public static void loadPlayer(Player client) - { - client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); - } - - public static void loadTurfs_ToAllPlayers() - { - NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); - foreach (var l in NAPI.Pools.GetAllPlayers()) - { - if (!l.IsLoggedIn() && !l.GetUser().FactionLeader) - return; - - l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); - } - } - - public static void GangwarKill(Player killer, Player victim) - { - if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf")) - { - foreach (var turf in getTurfs()) - { - if (turf.getId() == victim.GetData("inGangWar")) - { - turf.setKill(victim.GetUser().Faction.Name); - return; - } - } - } - } - - public static Turf[] getTurfs() - { - return _loadedTurfs; - } - - [RemoteEvent("Gangarea:Enter")] - public void RmtEvent_TurfEnter(Player client, string jsonId) - { - int id = JsonConvert.DeserializeObject(jsonId); - - foreach (var turf in getTurfs()) - { - if (turf.getId() == id) - { - turf.enter(client); - return; - } - } - } - - [RemoteEvent("Gangarea:Leave")] - public void RmtEvent_TurfLeave(Player client, string jsonId) - { - int id = JsonConvert.DeserializeObject(jsonId); - - foreach (var turf in getTurfs()) - { - if (turf.getId() == id) - { - turf.leave(client); - return; - } - } - } - - [RemoteEvent("SERVER:SetTurf")] - public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name) - { - float pX = JsonConvert.DeserializeObject(jsonX); - float pY = (float)JsonConvert.DeserializeObject(jsonY); - float Rot = (float)JsonConvert.DeserializeObject(jsonRot); - float Range = (float)JsonConvert.DeserializeObject(jsonRange); - - var newTurf = new Turfs - { - Name = Name, - X = pX, - Y = pY, - Rotation = Rot, - Range = Range, - Owner = "Neutral", - Color = 0, - Vector = null - }; - using (var dbContext = new DatabaseContext()) - { - dbContext.Turfs.Add(newTurf); - dbContext.SaveChanges(); - } - loadTurfs(); - loadTurfs_ToAllPlayers(); - } - - [RemoteEvent("SERVER:DeleteTurf")] - public void RmtEvent_DeleteTurf(Player client, string jsonId) - { - int id = JsonConvert.DeserializeObject(jsonId); - if (id == -1) - { - ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!"); - return; - } - using (var dbContext = new DatabaseContext()) - { - Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault(); - if (dturf != null) - { - dbContext.Turfs.Remove(dturf); - dbContext.SaveChanges(); - loadTurfs(); - loadTurfs_ToAllPlayers(); - } - } - } - - [RemoteEvent("SERVER:Turf_SetNewLeaderPoint")] - public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId) - { - int id = JsonConvert.DeserializeObject(jsonId); - if (id == -1) - { - ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet"); - return; - } - using (var dbContext = new DatabaseContext()) - { - Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault(); - if (dturf != null) - { - dturf.Vector = vector; - dbContext.SaveChanges(); - loadTurfs(); - loadTurfs_ToAllPlayers(); - } - } - } - - [RemoteEvent("SERVER:StartGangwar")] - public void RmtEvent_StartGangwar(Player client) - { - if (!client.GetUser().FactionLeader) - return; - - foreach (var turf in getTurfs()) - { - if (turf.status == "attack") - { - ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten"); - return; - } - } - if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove") - { - foreach (var turf in getTurfs()) - { - foreach (var u in turf.playerInside) - { - if (u == client) - { - if (turf.Owner != client.GetUser().Faction.Name) - turf.attack(client.GetUser().Faction.Name); - } - } - } - } - } - - public static void Value_TimerElapsed() - { - List values = new List(); - using (var dbContext = new DatabaseContext()) - { - foreach (var turf in getTurfs()) - { - if ((turf.getValue() + 5) >= turf.getMaxValue()) - { - turf.setValue(turf.getMaxValue()); - } - else - { - turf.addValue(5); - } - values.Add(turf.getValue()); - Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault(); - _turf.Value = turf.getValue(); - } - dbContext.SaveChanges(); - } - NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray())); + Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus); + turfing.Add(newTurf); } + _loadedTurfs = turfing.ToArray(); + } } + + public static void loadPlayer(Player client) + { + client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); + } + + public static void loadTurfs_ToAllPlayers() + { + NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray())); + foreach (var l in NAPI.Pools.GetAllPlayers()) + { + if (!l.IsLoggedIn() && !l.GetUser().FactionLeader) + return; + + l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip"); + } + } + + public static void GangwarKill(Player killer, Player victim) + { + if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf")) + { + foreach (var turf in getTurfs()) + { + if (turf.getId() == victim.GetData("inGangWar")) + { + turf.setKill(victim.GetUser().Faction.Name); + return; + } + } + } + } + + public static Turf[] getTurfs() + { + return _loadedTurfs; + } + + [RemoteEvent("Gangarea:Enter")] + public void RmtEvent_TurfEnter(Player client, string jsonId) + { + int id = JsonConvert.DeserializeObject(jsonId); + + foreach (var turf in getTurfs()) + { + if (turf.getId() == id) + { + turf.enter(client); + return; + } + } + } + + [RemoteEvent("Gangarea:Leave")] + public void RmtEvent_TurfLeave(Player client, string jsonId) + { + int id = JsonConvert.DeserializeObject(jsonId); + + foreach (var turf in getTurfs()) + { + if (turf.getId() == id) + { + turf.leave(client); + return; + } + } + } + + [RemoteEvent("SERVER:SetTurf")] + public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name) + { + float pX = JsonConvert.DeserializeObject(jsonX); + float pY = (float)JsonConvert.DeserializeObject(jsonY); + float Rot = (float)JsonConvert.DeserializeObject(jsonRot); + float Range = (float)JsonConvert.DeserializeObject(jsonRange); + + var newTurf = new Turfs + { + Name = Name, + X = pX, + Y = pY, + Rotation = Rot, + Range = Range, + Owner = "Neutral", + Color = 0, + Vector = null + }; + using (var dbContext = new DatabaseContext()) + { + dbContext.Turfs.Add(newTurf); + dbContext.SaveChanges(); + } + loadTurfs(); + loadTurfs_ToAllPlayers(); + } + + [RemoteEvent("SERVER:DeleteTurf")] + public void RmtEvent_DeleteTurf(Player client, string jsonId) + { + int id = JsonConvert.DeserializeObject(jsonId); + if (id == -1) + { + ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!"); + return; + } + using (var dbContext = new DatabaseContext()) + { + Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault(); + if (dturf != null) + { + dbContext.Turfs.Remove(dturf); + dbContext.SaveChanges(); + loadTurfs(); + loadTurfs_ToAllPlayers(); + } + } + } + + [RemoteEvent("SERVER:Turf_SetNewLeaderPoint")] + public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId) + { + int id = JsonConvert.DeserializeObject(jsonId); + if (id == -1) + { + ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet"); + return; + } + using (var dbContext = new DatabaseContext()) + { + Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault(); + if (dturf != null) + { + dturf.Vector = vector; + dbContext.SaveChanges(); + loadTurfs(); + loadTurfs_ToAllPlayers(); + } + } + } + + [RemoteEvent("SERVER:StartGangwar")] + public void RmtEvent_StartGangwar(Player client) + { + if (!client.GetUser().FactionLeader) + return; + + foreach (var turf in getTurfs()) + { + if (turf.status == "attack") + { + ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten"); + return; + } + } + if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove") + { + foreach (var turf in getTurfs()) + { + foreach (var u in turf.playerInside) + { + if (u == client) + { + if (turf.Owner != client.GetUser().Faction.Name) + turf.attack(client.GetUser().Faction.Name); + } + } + } + } + } + + public static void Value_TimerElapsed() + { + List values = new List(); + using (var dbContext = new DatabaseContext()) + { + foreach (var turf in getTurfs()) + { + if ((turf.getValue() + 5) >= turf.getMaxValue()) + { + turf.setValue(turf.getMaxValue()); + } + else + { + turf.addValue(5); + } + values.Add(turf.getValue()); + Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault(); + _turf.Value = turf.getValue(); + } + dbContext.SaveChanges(); + } + NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray())); + } + } } diff --git a/ReallifeGamemode.Server/Gangwar/Turf.cs b/ReallifeGamemode.Server/Gangwar/Turf.cs index 7d053d48..8828a401 100644 --- a/ReallifeGamemode.Server/Gangwar/Turf.cs +++ b/ReallifeGamemode.Server/Gangwar/Turf.cs @@ -13,340 +13,340 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Gangwar { public class Turf + { + public int TurfID { get; set; } + public string TurfName { get; set; } + public int Color { get; set; } + public string Owner { get; set; } + public string Attacker { get; set; } + public int Att_Score { get; set; } + public int Def_Score { get; set; } + public string status { get; set; } + public int value { get; set; } + public int maxValue { get; set; } + public bool surplus { get; set; } + public List playerInside { get; set; } + public Timer timer { get; set; } + public Player[] playerInGangwar { get; set; } + public int timerCount; + + public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus) { - public int TurfID { get; set; } - public string TurfName { get; set; } - public int Color { get; set; } - public string Owner { get; set; } - public string Attacker { get; set; } - public int Att_Score { get; set; } - public int Def_Score { get; set; } - public string status { get; set; } - public int value { get; set; } - public int maxValue { get; set; } - public bool surplus { get; set; } - public List playerInside { get; set; } - public Timer timer { get; set; } - public Player[] playerInGangwar { get; set; } - public int timerCount; - - public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus) - { - this.TurfID = TurfID; - this.TurfName = TurfName; - this.Color = color; - this.Owner = Owner; - this.value = value; - this.maxValue = maxValue; - this.surplus = surplus; - this.Attacker = null; - this.Att_Score = 50; - this.Def_Score = 50; - this.status = "normal"; - this.timer = null; - this.playerInside = new List(); - this.timerCount = 0; - } - - public int getId() - { - return this.TurfID; - } - - public int getValue() - { - return this.value; - } - - public void setValue(int value) - { - this.value = value; - } - - public void addValue(int addedValue) - { - this.value += addedValue; - } - - public int getMaxValue() - { - return maxValue; - } - - public bool getSurplus() - { - return surplus; - } - - public void setSurplus(bool surplus) - { - this.surplus = surplus; - } - - public string getName() - { - return this.TurfName; - } - - public int getColor() - { - return this.Color; - } - - public string getOwner() - { - return this.Owner; - } - - public string getAttacker() - { - return this.Attacker; - } - - private void TurfTick() - { - this.timer = new System.Timers.Timer(1000); - - this.timer.Elapsed += Tick; - this.timer.AutoReset = true; - this.timer.Enabled = true; - this.timerCount = 0; - } - - private void Tick(object sender, System.Timers.ElapsedEventArgs e) - { - if (this.status == "attack") - { - update(); - } - } - - private void update() - { - #region Ticket system - - /* - try - { - Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray(); - Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray(); - }catch(NullReferenceException ex) - { - int i = 0; - foreach(var c in playerInGangwar) - { - if (!NAPI.Entity.DoesEntityExist(c.Handle)) - { - this.playerInside = this.playerInside.Where(gp => gp != c).ToArray(); - } - i++; - } - } - if (owners.Length > attackers.Length) - this.Att_Score -= owners.Length - attackers.Length; - if(owners.Length < attackers.Length) - this.Def_Score -= attackers.Length - owners.Length; - */ - - #endregion Ticket system - - foreach (Player gangwarPlayer in this.playerInGangwar) - { - gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score); - } - if (this.Def_Score <= 0) - { - this.takeOver(this.Attacker); - } - else if (this.Att_Score <= 0) - { - this.takeOver(this.Owner); - } - timerCount += 1; - if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like - { - if (this.Def_Score > this.Att_Score) - { - foreach (Player gangwarPlayer in this.playerInGangwar) - { - gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); - } - this.takeOver(this.Owner); - this.Att_Score = 0; - } - else if (this.Def_Score < this.Att_Score) - { - foreach (Player gangwarPlayer in this.playerInGangwar) - { - gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); - } - this.takeOver(this.Attacker); - this.Def_Score = 0; - return; - } - else if (this.Def_Score == this.Att_Score) - { - foreach (Player gangwarPlayer in this.playerInGangwar) - { - gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); - } - this.takeOver(this.Attacker); - this.Def_Score = 0; - - return; - } - } - } - - public void enter(Player client) - { - if (this.status == "attack") - { - if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker()) - return; - Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault(); - if (gPlayer == null) - { - using (var dbContext = new DatabaseContext()) - { - ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault()); - } - return; - } - } - - if (playerInside.Find(c => c == client) == null) - { - playerInside.Add(client); - client.SetData("GotInsideOfTurf", true); - } - } - - public void leave(Player client) - { - if (playerInside.Find(c => c == client) != null) - { - this.playerInside = this.playerInside.Where(c => c != client).ToList(); - if (this.status != "attack") - client.ResetData("GotInsideOfTurf"); - } - } - - public void takeOver(string FactionName) - { - this.timer.Stop(); - this.timer = null; - using (var dbContext = new DatabaseContext()) - { - if (getOwner() == FactionName) - { - Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); - Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); - foreach (var o in owners) - { - o.TriggerEvent("CLIENT:win"); - } - foreach (var a in attackers) - { - a.TriggerEvent("CLIENT:loose"); - } - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault()); - } - else if (getOwner() != FactionName) - { - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); - Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); - foreach (var o in owners) - { - o.TriggerEvent("CLIENT:loose"); - } - foreach (var a in attackers) - { - a.TriggerEvent("CLIENT:win"); - } - this.Owner = FactionName; - ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); - Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); - turf.Owner = this.Owner; - turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id; - dbContext.SaveChanges(); - } - } - this.Attacker = null; - foreach (var c in playerInGangwar) - { - c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID); - c.ResetData("inGangWar"); - c.ResetData("GotInsideOfTurf"); - } - this.playerInGangwar = null; - Gangwar.loadTurfs(); - Gangwar.loadTurfs_ToAllPlayers(); - } - - public void attack(string attacker) - { - Player[] usersInGangwar; - using (var context = new DatabaseContext()) - { - var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name); - - List ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList(); - List attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList(); - - if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1) - { - List leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList(); - foreach (var l in leaders) - { - ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen."); - } - - return; - } - List inGangwar = new List(ownersInGangwar.Concat(attackersInGangwar)); - - usersInGangwar = inGangwar.ToArray(); - } - if (this.status == "normal") - { - if (this.timer != null) - { - this.timer.Stop(); - this.timer = null; - } - this.Attacker = attacker; - this.status = "attack"; - - List clientsInGangwar = new List(); - - foreach (var u in usersInGangwar) - { - u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID); - u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score); - u.SetData("inGangWar", getId()); - ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen."); - clientsInGangwar.Add(u); - } - playerInGangwar = clientsInGangwar.ToArray(); - NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker)); - this.TurfTick(); - } - } - - public void setKill(string FactionName) - { - if (getOwner() == FactionName) - { - Def_Score -= 1; - } - else if (getAttacker() == FactionName) - { - Att_Score -= 1; - } - } + this.TurfID = TurfID; + this.TurfName = TurfName; + this.Color = color; + this.Owner = Owner; + this.value = value; + this.maxValue = maxValue; + this.surplus = surplus; + this.Attacker = null; + this.Att_Score = 50; + this.Def_Score = 50; + this.status = "normal"; + this.timer = null; + this.playerInside = new List(); + this.timerCount = 0; } + + public int getId() + { + return this.TurfID; + } + + public int getValue() + { + return this.value; + } + + public void setValue(int value) + { + this.value = value; + } + + public void addValue(int addedValue) + { + this.value += addedValue; + } + + public int getMaxValue() + { + return maxValue; + } + + public bool getSurplus() + { + return surplus; + } + + public void setSurplus(bool surplus) + { + this.surplus = surplus; + } + + public string getName() + { + return this.TurfName; + } + + public int getColor() + { + return this.Color; + } + + public string getOwner() + { + return this.Owner; + } + + public string getAttacker() + { + return this.Attacker; + } + + private void TurfTick() + { + this.timer = new System.Timers.Timer(1000); + + this.timer.Elapsed += Tick; + this.timer.AutoReset = true; + this.timer.Enabled = true; + this.timerCount = 0; + } + + private void Tick(object sender, System.Timers.ElapsedEventArgs e) + { + if (this.status == "attack") + { + update(); + } + } + + private void update() + { + #region Ticket system + + /* + try + { + Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray(); + Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray(); + }catch(NullReferenceException ex) + { + int i = 0; + foreach(var c in playerInGangwar) + { + if (!NAPI.Entity.DoesEntityExist(c.Handle)) + { + this.playerInside = this.playerInside.Where(gp => gp != c).ToArray(); + } + i++; + } + } + if (owners.Length > attackers.Length) + this.Att_Score -= owners.Length - attackers.Length; + if(owners.Length < attackers.Length) + this.Def_Score -= attackers.Length - owners.Length; + */ + + #endregion Ticket system + + foreach (Player gangwarPlayer in this.playerInGangwar) + { + gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score); + } + if (this.Def_Score <= 0) + { + this.takeOver(this.Attacker); + } + else if (this.Att_Score <= 0) + { + this.takeOver(this.Owner); + } + timerCount += 1; + if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like + { + if (this.Def_Score > this.Att_Score) + { + foreach (Player gangwarPlayer in this.playerInGangwar) + { + gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); + } + this.takeOver(this.Owner); + this.Att_Score = 0; + } + else if (this.Def_Score < this.Att_Score) + { + foreach (Player gangwarPlayer in this.playerInGangwar) + { + gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); + } + this.takeOver(this.Attacker); + this.Def_Score = 0; + return; + } + else if (this.Def_Score == this.Att_Score) + { + foreach (Player gangwarPlayer in this.playerInGangwar) + { + gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0); + } + this.takeOver(this.Attacker); + this.Def_Score = 0; + + return; + } + } + } + + public void enter(Player client) + { + if (this.status == "attack") + { + if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker()) + return; + Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault(); + if (gPlayer == null) + { + using (var dbContext = new DatabaseContext()) + { + ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); + ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault()); + } + return; + } + } + + if (playerInside.Find(c => c == client) == null) + { + playerInside.Add(client); + client.SetData("GotInsideOfTurf", true); + } + } + + public void leave(Player client) + { + if (playerInside.Find(c => c == client) != null) + { + this.playerInside = this.playerInside.Where(c => c != client).ToList(); + if (this.status != "attack") + client.ResetData("GotInsideOfTurf"); + } + } + + public void takeOver(string FactionName) + { + this.timer.Stop(); + this.timer = null; + using (var dbContext = new DatabaseContext()) + { + if (getOwner() == FactionName) + { + Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); + Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); + foreach (var o in owners) + { + o.TriggerEvent("CLIENT:win"); + } + foreach (var a in attackers) + { + a.TriggerEvent("CLIENT:loose"); + } + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault()); + } + else if (getOwner() != FactionName) + { + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); + Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray(); + Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray(); + foreach (var o in owners) + { + o.TriggerEvent("CLIENT:loose"); + } + foreach (var a in attackers) + { + a.TriggerEvent("CLIENT:win"); + } + this.Owner = FactionName; + ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault()); + Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault(); + turf.Owner = this.Owner; + turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id; + dbContext.SaveChanges(); + } + } + this.Attacker = null; + foreach (var c in playerInGangwar) + { + c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID); + c.ResetData("inGangWar"); + c.ResetData("GotInsideOfTurf"); + } + this.playerInGangwar = null; + Gangwar.loadTurfs(); + Gangwar.loadTurfs_ToAllPlayers(); + } + + public void attack(string attacker) + { + Player[] usersInGangwar; + using (var context = new DatabaseContext()) + { + var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name); + + List ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList(); + List attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList(); + + if (ownersInGangwar.Count < 1 && attackersInGangwar.Count < 1) + { + List leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList(); + foreach (var l in leaders) + { + ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen."); + } + + return; + } + List inGangwar = new List(ownersInGangwar.Concat(attackersInGangwar)); + + usersInGangwar = inGangwar.ToArray(); + } + if (this.status == "normal") + { + if (this.timer != null) + { + this.timer.Stop(); + this.timer = null; + } + this.Attacker = attacker; + this.status = "attack"; + + List clientsInGangwar = new List(); + + foreach (var u in usersInGangwar) + { + u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID); + u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score); + u.SetData("inGangWar", getId()); + ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen."); + clientsInGangwar.Add(u); + } + playerInGangwar = clientsInGangwar.ToArray(); + NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker)); + this.TurfTick(); + } + } + + public void setKill(string FactionName) + { + if (getOwner() == FactionName) + { + Def_Score -= 1; + } + else if (getAttacker() == FactionName) + { + Att_Score -= 1; + } + } + } } diff --git a/ReallifeGamemode.Server/Inventory/Interfaces/IDroppableItem.cs b/ReallifeGamemode.Server/Inventory/Interfaces/IDroppableItem.cs index b327b78d..bab77667 100644 --- a/ReallifeGamemode.Server/Inventory/Interfaces/IDroppableItem.cs +++ b/ReallifeGamemode.Server/Inventory/Interfaces/IDroppableItem.cs @@ -7,7 +7,7 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces { public interface IDroppableItem : IItem - { - uint Object { get; } - } + { + uint Object { get; } + } } diff --git a/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs b/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs index 9264a3c2..dd364314 100644 --- a/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs +++ b/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs @@ -7,12 +7,12 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces { public interface IItem - { - int Id { get; } - string Name { get; } - string Description { get; } - int Gewicht { get; } - string Einheit { get; } - int Price { get; } - } + { + int Id { get; } + string Name { get; } + string Description { get; } + int Gewicht { get; } + string Einheit { get; } + int Price { get; } + } } diff --git a/ReallifeGamemode.Server/Inventory/Interfaces/IUsableItem.cs b/ReallifeGamemode.Server/Inventory/Interfaces/IUsableItem.cs index 28ea7b2c..24383bee 100644 --- a/ReallifeGamemode.Server/Inventory/Interfaces/IUsableItem.cs +++ b/ReallifeGamemode.Server/Inventory/Interfaces/IUsableItem.cs @@ -9,7 +9,7 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces { public interface IUsableItem : IItem, IDroppableItem - { - void Use(UserItem uItem); - } + { + void Use(UserItem uItem); + } } diff --git a/ReallifeGamemode.Server/Inventory/Interfaces/IWeaponDealItem.cs b/ReallifeGamemode.Server/Inventory/Interfaces/IWeaponDealItem.cs index da45b53d..e40c5d5f 100644 --- a/ReallifeGamemode.Server/Inventory/Interfaces/IWeaponDealItem.cs +++ b/ReallifeGamemode.Server/Inventory/Interfaces/IWeaponDealItem.cs @@ -4,7 +4,7 @@ using ReallifeGamemode.Database.Entities; namespace ReallifeGamemode.Server.Inventory.Interfaces { public interface IWeaponDealItem : IItem, IDroppableItem - { - bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh); - } + { + bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh); + } } diff --git a/ReallifeGamemode.Server/Inventory/Items/DropItem.cs b/ReallifeGamemode.Server/Inventory/Items/DropItem.cs index efeae4bd..f00121a0 100644 --- a/ReallifeGamemode.Server/Inventory/Items/DropItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/DropItem.cs @@ -7,20 +7,20 @@ using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Inventory.Items { public abstract class DropItem : IDroppableItem - { - public abstract int HpAmount { get; } - public abstract int Id { get; } - public abstract string Name { get; } - public abstract string Description { get; } - public abstract int Gewicht { get; } - public abstract string Einheit { get; } - public abstract uint Object { get; } - public abstract int Price { get; } + { + public abstract int HpAmount { get; } + public abstract int Id { get; } + public abstract string Name { get; } + public abstract string Description { get; } + public abstract int Gewicht { get; } + public abstract string Einheit { get; } + public abstract uint Object { get; } + public abstract int Price { get; } - public void Drop(UserItem uItem, Player player, int amount) - { - player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false); - InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount); - } + public void Drop(UserItem uItem, Player player, int amount) + { + player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false); + InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount); } + } } diff --git a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs index 93371992..77f76cd4 100644 --- a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs @@ -7,29 +7,29 @@ using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Inventory.Items { public abstract class FoodItem : IUsableItem + { + public abstract int HpAmount { get; } + public abstract int Id { get; } + public abstract string Name { get; } + public abstract string Description { get; } + public abstract int Gewicht { get; } + public abstract string Einheit { get; } + public abstract uint Object { get; } + public abstract int Price { get; } + + public void Use(UserItem uItem) { - public abstract int HpAmount { get; } - public abstract int Id { get; } - public abstract string Name { get; } - public abstract string Description { get; } - public abstract int Gewicht { get; } - public abstract string Einheit { get; } - public abstract uint Object { get; } - public abstract int Price { get; } + Player player = uItem.GetUser().Player; - public void Use(UserItem uItem) - { - Player player = uItem.GetUser().Player; + int amountToAdd = HpAmount; + if (player.Health + amountToAdd > 100) + { + amountToAdd = 100 - player.Health; + } - int amountToAdd = HpAmount; - if (player.Health + amountToAdd > 100) - { - amountToAdd = 100 - player.Health; - } - - player.Health += amountToAdd; - player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false); - InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1); - } + player.Health += amountToAdd; + player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false); + InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1); } + } } diff --git a/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs b/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs index ee91765c..fdaff5cd 100644 --- a/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs @@ -6,23 +6,23 @@ using ReallifeGamemode.Server.Inventory.Interfaces; namespace ReallifeGamemode.Server.Inventory.Items { public abstract class WeaponDealItem : IWeaponDealItem + { + public abstract int Id { get; } + public abstract string Name { get; } + public abstract string Description { get; } + public abstract int Gewicht { get; } + public abstract string Einheit { get; } + public abstract uint Object { get; } + public abstract int Price { get; } + + public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh) { - public abstract int Id { get; } - public abstract string Name { get; } - public abstract string Description { get; } - public abstract int Gewicht { get; } - public abstract string Einheit { get; } - public abstract uint Object { get; } - public abstract int Price { get; } + if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0)) + return false; + if (fVeh.Model != VehicleHash.Burrito3) + return false; - public bool noTransfer(Player client, UserItem uItem, FactionVehicle fVeh) - { - if (!fVeh.GetOwners().Contains(client.GetUser().FactionId ?? 0)) - return false; - if (fVeh.Model != VehicleHash.Burrito3) - return false; - - return true; - } + return true; } + } } diff --git a/ReallifeGamemode.Server/Job/JobBase.cs b/ReallifeGamemode.Server/Job/JobBase.cs index fe23b679..56a4faee 100644 --- a/ReallifeGamemode.Server/Job/JobBase.cs +++ b/ReallifeGamemode.Server/Job/JobBase.cs @@ -8,59 +8,59 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Job { public abstract class JobBase : Script + { + public delegate void JobStartHandler(Player player); + + public delegate void JobStopHandler(Player player); + + public event JobStartHandler JobStart; + + public event JobStopHandler JobStop; + + private readonly List _inJob = new List(); + private static readonly List jobPlayer = new List(); + + public abstract int Id { get; } + + public abstract string Name { get; } + + public abstract bool NeedVehicleToStart { get; } + + public void StartJob(Player player) { - public delegate void JobStartHandler(Player player); + if (_inJob.Contains(player)) return; + _inJob.Add(player); + jobPlayer.Add(player); - public delegate void JobStopHandler(Player player); + ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet."); - public event JobStartHandler JobStart; - - public event JobStopHandler JobStop; - - private readonly List _inJob = new List(); - private static readonly List jobPlayer = new List(); - - public abstract int Id { get; } - - public abstract string Name { get; } - - public abstract bool NeedVehicleToStart { get; } - - public void StartJob(Player player) - { - if (_inJob.Contains(player)) return; - _inJob.Add(player); - jobPlayer.Add(player); - - ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet."); - - JobStart?.Invoke(player); - } - - public void StopJob(Player player, bool quit = false) - { - if (!_inJob.Contains(player)) return; - _inJob.Remove(player); - jobPlayer.Remove(player); - - if (quit) - { - ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet."); - } - - JobStop?.Invoke(player); - } - - public List GetJobVehicles() - { - using (var dbContext = new DatabaseContext()) - { - return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList(); - } - } - - public static List GetPlayerInJob() => jobPlayer; - - public List GetUsersInJob() => _inJob; + JobStart?.Invoke(player); } + + public void StopJob(Player player, bool quit = false) + { + if (!_inJob.Contains(player)) return; + _inJob.Remove(player); + jobPlayer.Remove(player); + + if (quit) + { + ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet."); + } + + JobStop?.Invoke(player); + } + + public List GetJobVehicles() + { + using (var dbContext = new DatabaseContext()) + { + return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList(); + } + } + + public static List GetPlayerInJob() => jobPlayer; + + public List GetUsersInJob() => _inJob; + } } diff --git a/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs b/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs index da3ee506..fc8aaba8 100644 --- a/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs +++ b/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs @@ -8,33 +8,33 @@ using ReallifeGamemode.Server.Services; namespace ReallifeGamemode.Server.Job { public class RefuseCollectorJob : JobBase + { + public override int Id => 2; + + public override string Name => "Müllmann"; + + public override bool NeedVehicleToStart => false; + + public RefuseCollectorJob() { - public override int Id => 2; + JobStart += RefuseCollectorJobJobStart; + JobStop += RefuseCollectorJobJobStop; + } - public override string Name => "Müllmann"; + private void RefuseCollectorJobJobStart(Player player) + { + //setClothes + } - public override bool NeedVehicleToStart => false; + private void RefuseCollectorJobJobStop(Player player) + { + //removeClothes and replace with old + MuellmannJobBeenden(player); + } - public RefuseCollectorJob() - { - JobStart += RefuseCollectorJobJobStart; - JobStop += RefuseCollectorJobJobStop; - } + public static List muellmanData = new List(); - private void RefuseCollectorJobJobStart(Player player) - { - //setClothes - } - - private void RefuseCollectorJobJobStop(Player player) - { - //removeClothes and replace with old - MuellmannJobBeenden(player); - } - - public static List muellmanData = new List(); - - private readonly IReadOnlyCollection vector3s = new List + private readonly IReadOnlyCollection vector3s = new List { new Vector3(332.9839782714844, -1741.807373046875, 29.73055076599121), new Vector3(321.3463439941406, -1759.986572265625, 29.644014358520508), @@ -153,298 +153,298 @@ namespace ReallifeGamemode.Server.Job }.AsReadOnly(); - [RemoteEvent("CLIENT:MuellmannJobStarten")] - public void MuellmannJobStarten(Player player, Vehicle vehicle) + [RemoteEvent("CLIENT:MuellmannJobStarten")] + public void MuellmannJobStarten(Player player, Vehicle vehicle) + { + if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2) + { + Vehicle veh; + foreach (var data in muellmanData) { - if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2) - { - Vehicle veh; - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - veh = data.vehicle; - ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!"); - player.TriggerEvent("SERVER:MuellmannStatusTrue"); - player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh); - return; - } - } + if (data.getDataFromClient(player) == null) continue; + veh = data.vehicle; + ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job gestartet!"); + player.TriggerEvent("SERVER:MuellmannStatusTrue"); + player.TriggerEvent("SERVER:MuellmannBCSErstellen", JsonConvert.SerializeObject(vector3s.ToArray()), veh); + return; } - - public void MuellmannJobBeenden(Player player) - { - ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!"); - player.TriggerEvent("SERVER:MuellmannStatusFalse"); - player.TriggerEvent("SERVER:MuellmannBCSEntfernen"); - - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - - if (data.hasFreePlace()) - { - muellmanData.Remove(data); - //müllwagen respawnen - return; - } - - data.removeClientFromData(player); - return; - } - } - - [RemoteEvent("CLIENT:MuellmannImShape")] - public void MuellmannImShape(Player player, int colshapeIndex) - { - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - Player target = data.getPartnerClient(player); - if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex); - ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten."); - player.AddAttachment("binbag", false); - return; - } - } - - [RemoteEvent("CLIENT:MuellmannAddSack")] - public void MuellmannAddSack(Player player) - { - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - - data.setTrashCount(data.getTrashCount() + 1); - - Player target = data.getPartnerClient(player); - player.AddAttachment("binbag", true); - if (data.getTrashCount() >= 20) - { - ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base."); - if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); } - player.TriggerEvent("SERVER:MuellmannZuBase"); - } - //bonus pro sack - return; - } - } - - [RemoteEvent("CLIENT:MuellmannBaseSack")] - public void MuellmannBaseSack(Player player) - { - if (player.VehicleSeat != 0) return; - - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - - Player target = data.getPartnerClient(player); - if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}"); - ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}"); - //bonus pro sack - - data.setTrashCount(0); - Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}"); - return; - } - } - - #region zweiSpeieler - - public void MuellmannOnPlayerDc(Player player) - { - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - - if (data.hasFreePlace()) - { - muellmanData.Remove(data); - //müllwagen respawnen - return; - } - - data.removeClientFromData(player); - return; - } - } - - public void MuellmannOnPlayerDeath(Player player) - { - foreach (var data in muellmanData) - { - if (data.getDataFromClient(player) == null) continue; - - if (data.hasFreePlace()) - { - muellmanData.Remove(data); - //müllwagen respawnen - return; - } - - data.removeClientFromData(player); - return; - } - } - - [ServerEvent(Event.VehicleDeath)] - private void MuellmannOnVehicle(Vehicle veh) - { - if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return; - foreach (var data in muellmanData) - { - if (data.vehicle == veh) - { - //müllfahrzeug respawnen - - List clients = data.getClientsFromData(); - foreach (var c in clients) { RefuseCollectorJobJobStop(c); } - - muellmanData.Remove(data); - return; - } - } - } - - public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat) - { - Player target; - if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2) - { - foreach (var data in muellmanData) - { - if (data.vehicle == vehicle) - { - if (data.getDataFromClient(player) != null) - return; - - if (!data.hasFreePlace()) - { - player.StopAnimation(); - return; - } - CheckDataForDuplicatePlayer(player, data); - data.setClientToData(player); - //destroy veh - MuellmannJobStarten(player, vehicle); - - target = data.getPartnerClient(player); - if (target == null) - return; - - ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !"); - ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !"); - return; - } - } - - MuellmannData newData = new MuellmannData(vehicle); - muellmanData.Add(newData); - CheckDataForDuplicatePlayer(player, newData); - newData.setClientToData(player); - - MuellmannJobStarten(player, vehicle); - - target = newData.getPartnerClient(player); - if (target == null) - return; - - ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !"); - ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !"); - } - } - - public void CheckDataForDuplicatePlayer(Player player, MuellmannData data) - { - foreach (var d in muellmanData) - { - if (d == data) continue; - - MuellmannData temp = d.getDataFromClient(player); - if (temp == null) continue; - - temp.removeClientFromData(player); - } - } - - #endregion zweiSpeieler - - #region Data - - public class MuellmannData - { - private Player client1; - private Player client2; - public Vehicle vehicle; - private static int trashCount = 0; - - public MuellmannData(Vehicle vehicle) - { - this.vehicle = vehicle; - } - - public void setClientToData(Player player) - { - if (client1 == player || client2 == player) - { - Console.WriteLine("Spieler schon gespeichert"); - return; - } - - if (client1 == null) { client1 = player; return; } - else if (client2 == null) { client2 = player; return; } - else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); } - } - - public void removeClientFromData(Player player) - { - if (client1 == player) { client1 = null; } - if (client2 == player) { client2 = null; } - } - - public int getTrashCount() - { - return trashCount; - } - - public void setTrashCount(int i) - { - trashCount = i; - } - - public List getClientsFromData() - { - List tempList = new List(); - if (client1 != null) { tempList.Add(client1); } - if (client2 != null) { tempList.Add(client2); } - return tempList; - } - - public MuellmannData getDataFromClient(Player player) - { - if (client1 != player && client2 != player) - return null; - return this; - } - - public bool hasFreePlace() - { - if (client1 != null && client2 != null) - return false; - return true; - } - - public Player getPartnerClient(Player player) - { - if (client1 != player && client2 != player) - return null; - - if (client1 == player) { return client2; } - if (client2 == player) { return client1; } - return null; - } - } - - #endregion Data + } } + + public void MuellmannJobBeenden(Player player) + { + ChatService.SendMessage((Player)player, "~g~Du hast den Müllmann-Job beendet!"); + player.TriggerEvent("SERVER:MuellmannStatusFalse"); + player.TriggerEvent("SERVER:MuellmannBCSEntfernen"); + + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + + if (data.hasFreePlace()) + { + muellmanData.Remove(data); + //müllwagen respawnen + return; + } + + data.removeClientFromData(player); + return; + } + } + + [RemoteEvent("CLIENT:MuellmannImShape")] + public void MuellmannImShape(Player player, int colshapeIndex) + { + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + Player target = data.getPartnerClient(player); + if (target != null) target.TriggerEvent("MuellmannUpdateColshape", colshapeIndex); + ChatService.SendMessage((Player)player, "Du hast den Müllsack in der Hand. Bringe ihm zum Müllwagen hinten."); + player.AddAttachment("binbag", false); + return; + } + } + + [RemoteEvent("CLIENT:MuellmannAddSack")] + public void MuellmannAddSack(Player player) + { + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + + data.setTrashCount(data.getTrashCount() + 1); + + Player target = data.getPartnerClient(player); + player.AddAttachment("binbag", true); + if (data.getTrashCount() >= 20) + { + ChatService.SendMessage((Player)player, "Auto ist voll fahre nun zu Base."); + if (target != null) { ChatService.SendMessage((Player)target, "Auto ist voll fahre nun zu Base."); target.TriggerEvent("SERVER:MuellmannZuBase"); } + player.TriggerEvent("SERVER:MuellmannZuBase"); + } + //bonus pro sack + return; + } + } + + [RemoteEvent("CLIENT:MuellmannBaseSack")] + public void MuellmannBaseSack(Player player) + { + if (player.VehicleSeat != 0) return; + + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + + Player target = data.getPartnerClient(player); + if (target != null) ChatService.SendMessage((Player)target, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}"); + ChatService.SendMessage((Player)player, $"Fahrzeug wurde entleert. Säcke: {data.getTrashCount()}"); + //bonus pro sack + + data.setTrashCount(0); + Console.WriteLine($"[DATA DEBUG] vehicle: {data.vehicle.DisplayName} | Players: {data.getClientsFromData().Count} | Säcke: {data.getTrashCount()}"); + return; + } + } + + #region zweiSpeieler + + public void MuellmannOnPlayerDc(Player player) + { + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + + if (data.hasFreePlace()) + { + muellmanData.Remove(data); + //müllwagen respawnen + return; + } + + data.removeClientFromData(player); + return; + } + } + + public void MuellmannOnPlayerDeath(Player player) + { + foreach (var data in muellmanData) + { + if (data.getDataFromClient(player) == null) continue; + + if (data.hasFreePlace()) + { + muellmanData.Remove(data); + //müllwagen respawnen + return; + } + + data.removeClientFromData(player); + return; + } + } + + [ServerEvent(Event.VehicleDeath)] + private void MuellmannOnVehicle(Vehicle veh) + { + if (veh.Model != (uint)Types.VehicleModel.Trash && veh.Model != (uint)Types.VehicleModel.Trash2) return; + foreach (var data in muellmanData) + { + if (data.vehicle == veh) + { + //müllfahrzeug respawnen + + List clients = data.getClientsFromData(); + foreach (var c in clients) { RefuseCollectorJobJobStop(c); } + + muellmanData.Remove(data); + return; + } + } + } + + public void MuellmannOnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seat) + { + Player target; + if (vehicle.Model == (uint)Types.VehicleModel.Trash || vehicle.Model == (uint)Types.VehicleModel.Trash2) + { + foreach (var data in muellmanData) + { + if (data.vehicle == vehicle) + { + if (data.getDataFromClient(player) != null) + return; + + if (!data.hasFreePlace()) + { + player.StopAnimation(); + return; + } + CheckDataForDuplicatePlayer(player, data); + data.setClientToData(player); + //destroy veh + MuellmannJobStarten(player, vehicle); + + target = data.getPartnerClient(player); + if (target == null) + return; + + ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !"); + ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !"); + return; + } + } + + MuellmannData newData = new MuellmannData(vehicle); + muellmanData.Add(newData); + CheckDataForDuplicatePlayer(player, newData); + newData.setClientToData(player); + + MuellmannJobStarten(player, vehicle); + + target = newData.getPartnerClient(player); + if (target == null) + return; + + ChatService.SendMessage((Player)player, $"Dein Partner ist {target.Name} !"); + ChatService.SendMessage((Player)target, $"Dein Partner ist {player.Name} !"); + } + } + + public void CheckDataForDuplicatePlayer(Player player, MuellmannData data) + { + foreach (var d in muellmanData) + { + if (d == data) continue; + + MuellmannData temp = d.getDataFromClient(player); + if (temp == null) continue; + + temp.removeClientFromData(player); + } + } + + #endregion zweiSpeieler + + #region Data + + public class MuellmannData + { + private Player client1; + private Player client2; + public Vehicle vehicle; + private static int trashCount = 0; + + public MuellmannData(Vehicle vehicle) + { + this.vehicle = vehicle; + } + + public void setClientToData(Player player) + { + if (client1 == player || client2 == player) + { + Console.WriteLine("Spieler schon gespeichert"); + return; + } + + if (client1 == null) { client1 = player; return; } + else if (client2 == null) { client2 = player; return; } + else if (client1 != null && client2 != null) { Console.WriteLine("kein Platz"); } + } + + public void removeClientFromData(Player player) + { + if (client1 == player) { client1 = null; } + if (client2 == player) { client2 = null; } + } + + public int getTrashCount() + { + return trashCount; + } + + public void setTrashCount(int i) + { + trashCount = i; + } + + public List getClientsFromData() + { + List tempList = new List(); + if (client1 != null) { tempList.Add(client1); } + if (client2 != null) { tempList.Add(client2); } + return tempList; + } + + public MuellmannData getDataFromClient(Player player) + { + if (client1 != player && client2 != player) + return null; + return this; + } + + public bool hasFreePlace() + { + if (client1 != null && client2 != null) + return false; + return true; + } + + public Player getPartnerClient(Player player) + { + if (client1 != player && client2 != player) + return null; + + if (client1 == player) { return client2; } + if (client2 == player) { return client1; } + return null; + } + } + + #endregion Data + } } diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index dc220ac5..c2a3aeef 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -25,93 +25,93 @@ using ReallifeGamemode.Services; namespace ReallifeGamemode.Server { public class Main : Script + { + public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829); + public static readonly float DEFAULT_SPAWN_HEADING = 340.8f; + + public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); + + private EventHandler eventHandler; + + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() { - public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829); - public static readonly float DEFAULT_SPAWN_HEADING = 340.8f; + var methods = Assembly.GetExecutingAssembly() + .GetTypes() + .SelectMany(t => t.GetMethods()) + .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) + .ToArray(); - public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE"); + var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); - private EventHandler eventHandler; + var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); + cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => + { + registeredCommands.AddRange(a.Alias.Split(',')); + }); - [ServerEvent(Event.ResourceStart)] - public void OnResourceStart() + IAPI apiInstance = new RageAPI(); + eventHandler = new EventHandler(apiInstance); + + new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); + + NAPI.Server.SetGlobalServerChat(false); + + NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht."); + NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); + NAPI.Server.SetAutoSpawnOnConnect(false); + NAPI.Server.SetAutoRespawnAfterDeath(false); + NAPI.Data.SetWorldData("playerCreatorDimension", 0); + + JsonConvert.DefaultSettings = () => + { + return new JsonSerializerSettings() { - var methods = Assembly.GetExecutingAssembly() - .GetTypes() - .SelectMany(t => t.GetMethods()) - .Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0) - .ToArray(); + NullValueHandling = NullValueHandling.Ignore + }; + }; - var cmdAttributes = methods.Select(c => c.GetCustomAttribute()).ToList(); + InventoryManager.LoadItems(); + ShopManager.LoadClotheShops(); + ShopManager.LoadItemShops(); + TuningManager.LoadTuningGarages(); - var registeredCommands = cmdAttributes.Select(c => c.CommandString).ToList(); - cmdAttributes.Where(c => c.Alias?.Any() ?? false).ToList().ForEach(a => - { - registeredCommands.AddRange(a.Alias.Split(',')); - }); + TimeManager.StartTimeManager(); + VehicleManager.CheckEnabledMods(); - IAPI apiInstance = new RageAPI(); - eventHandler = new EventHandler(apiInstance); + DatabaseHelper.InitDatabaseFirstTime(); - new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray()); + FactionHelper.CheckFactionBankAccounts(); + BusinessManager.LoadBusinesses(); + //InteriorManager.LoadInteriors(); + DoorManager.LoadDoors(); + ATMManager.InitATMs(); + CityHallManager.LoadCityHall(); + JobManager.LoadJobs(); + //TaxiDriverJob.StartTaxiTimer(); Obselete + //HouseManager.LoadHouses(); + DrivingSchool.DrivingSchool.Setup(); + PlaneSchool.Setup(); + Gangwar.Gangwar.loadTurfs(); - NAPI.Server.SetGlobalServerChat(false); + TempBlip tempBlip = new TempBlip() + { + Color = 1, + Name = "", + Transparency = 0, + ShortRange = true, + Sprite = 1, + Scale = 1, + }; - NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht."); - NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING); - NAPI.Server.SetAutoSpawnOnConnect(false); - NAPI.Server.SetAutoRespawnAfterDeath(false); - NAPI.Data.SetWorldData("playerCreatorDimension", 0); + NAPI.Data.SetWorldData("blipTemplate", tempBlip); - JsonConvert.DefaultSettings = () => - { - return new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }; - }; + //WantedEscapeTimer.WantedTimer(); Obselete + //Jail.JailTimer(); Obselete + //Economy.PaydayTimer(); Obselete + // WeaponDealManager.WeaponDealTimer(); Obselete - InventoryManager.LoadItems(); - ShopManager.LoadClotheShops(); - ShopManager.LoadItemShops(); - TuningManager.LoadTuningGarages(); - - TimeManager.StartTimeManager(); - VehicleManager.CheckEnabledMods(); - - DatabaseHelper.InitDatabaseFirstTime(); - - FactionHelper.CheckFactionBankAccounts(); - BusinessManager.LoadBusinesses(); - //InteriorManager.LoadInteriors(); - DoorManager.LoadDoors(); - ATMManager.InitATMs(); - CityHallManager.LoadCityHall(); - JobManager.LoadJobs(); - //TaxiDriverJob.StartTaxiTimer(); Obselete - //HouseManager.LoadHouses(); - DrivingSchool.DrivingSchool.Setup(); - PlaneSchool.Setup(); - Gangwar.Gangwar.loadTurfs(); - - TempBlip tempBlip = new TempBlip() - { - Color = 1, - Name = "", - Transparency = 0, - ShortRange = true, - Sprite = 1, - Scale = 1, - }; - - NAPI.Data.SetWorldData("blipTemplate", tempBlip); - - //WantedEscapeTimer.WantedTimer(); Obselete - //Jail.JailTimer(); Obselete - //Economy.PaydayTimer(); Obselete - // WeaponDealManager.WeaponDealTimer(); Obselete - - ThreadTimers.StartAllTimers(); + ThreadTimers.StartAllTimers(); UserBankAccount.BalanceChanged += (account) => { @@ -129,11 +129,11 @@ namespace ReallifeGamemode.Server }; } - [RemoteEvent("CLIENT:Event")] - public void OnClientEvent(Player player, string dataStr) - { - var data = dataStr.DeserializeJson>(); - eventHandler.HandleEvent(new RagePlayer(player), data); - } + [RemoteEvent("CLIENT:Event")] + public void OnClientEvent(Player player, string dataStr) + { + var data = dataStr.DeserializeJson>(); + eventHandler.HandleEvent(new RagePlayer(player), data); } -} \ No newline at end of file + } +} diff --git a/ReallifeGamemode.Server/Managers/ATMManager.cs b/ReallifeGamemode.Server/Managers/ATMManager.cs index 4671862e..6d65e87e 100644 --- a/ReallifeGamemode.Server/Managers/ATMManager.cs +++ b/ReallifeGamemode.Server/Managers/ATMManager.cs @@ -14,140 +14,140 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Managers { public class ATMManager : Script + { + public static List ATMColShapes = new List(); + + public static void InitATMs() { - public static List ATMColShapes = new List(); - - public static void InitATMs() + var addedATMs = 0; + using (var dbContext = new DatabaseContext()) + { + foreach (var currentATM in dbContext.Blips) { - var addedATMs = 0; - using (var dbContext = new DatabaseContext()) + if (currentATM.Sprite == 500) + { + if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null) { - foreach (var currentATM in dbContext.Blips) - { - if (currentATM.Sprite == 500) - { - 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 - { - continue; - } - } - } - if (addedATMs > 0) - { - NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt"); - } - else - { - NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt"); - } - - dbContext.SaveChanges(); - LoadATMs(); + var dataSet = new ATM + { + Id = currentATM.Id, + X = currentATM.PositionX, + Y = currentATM.PositionY, + Z = currentATM.PositionZ + }; + dbContext.Add(dataSet); + addedATMs++; } - } - - public static void LoadATMs() - { - using (var dbContext = new DatabaseContext()) + else { - foreach (var currentATM in dbContext.ATMs) - { - var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0); - currentColShape.OnEntityEnterColShape += EnterATMRange; - currentColShape.OnEntityExitColShape += ExitATMRange; - ATMColShapes.Add(currentColShape); - currentColShape.SetData("id", currentATM.Id); - } + continue; } + } } - - public static void EnterATMRange(ColShape colShape, Player client) + if (addedATMs > 0) { - client.SetData("nearATM", colShape.GetData("id")); + NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt"); } - - public static void ExitATMRange(ColShape colShape, Player client) + else { - client.ResetData("nearATM"); + NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt"); } - public static void ShowAtmUi(Player player, int atmId) - { - player.TriggerEvent("SERVER:ShowAtmUi", atmId); - } - - [RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")] - public void AtmAction(Player client, int site, int inputField1, int inputField2) - { - using (var dbContext = new DatabaseContext()) - { - var user = client.GetUser(dbContext); - int nearATM = client.GetData("nearATM"); - //SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen - switch (site) - { - //GELD EINZAHLEN in1 - case 0: - - if (user.Handmoney < inputField1) - { - //TODO im CEFBrowser anzeigen - //client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance); - client.SendNotification("~r~Nicht genügend Geld auf der Hand!"); - } - else - { - var updateBankMoneyIn = user.BankAccount; - var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); - user.Handmoney -= inputField1; - updateBankMoneyIn.Balance += inputField1; - updateATMBalanceIn.Balance += inputField1; - client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); - } - break; - - //GELD AUSZAHLEN in1 - case 1: - var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); - - if (user.BankAccount.Balance < inputField1) - { - client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen - } - else if (checkATM.Balance < inputField1) - { - client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer - } - else - { - var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id); - var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); - updateHandMoneyOut.Handmoney += inputField1; - user.BankAccount.Balance -= inputField1; - updateATMBalanceOut.Balance -= inputField1; - client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney); - } - break; - - //GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag - case 2: - - break; - } - dbContext.SaveChanges(); - } - } + dbContext.SaveChanges(); + LoadATMs(); + } } + + public static void LoadATMs() + { + using (var dbContext = new DatabaseContext()) + { + foreach (var currentATM in dbContext.ATMs) + { + var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0); + currentColShape.OnEntityEnterColShape += EnterATMRange; + currentColShape.OnEntityExitColShape += ExitATMRange; + ATMColShapes.Add(currentColShape); + currentColShape.SetData("id", currentATM.Id); + } + } + } + + public static void EnterATMRange(ColShape colShape, Player client) + { + client.SetData("nearATM", colShape.GetData("id")); + } + + public static void ExitATMRange(ColShape colShape, Player client) + { + client.ResetData("nearATM"); + } + + public static void ShowAtmUi(Player player, int atmId) + { + player.TriggerEvent("SERVER:ShowAtmUi", atmId); + } + + [RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")] + public void AtmAction(Player client, int site, int inputField1, int inputField2) + { + using (var dbContext = new DatabaseContext()) + { + var user = client.GetUser(dbContext); + int nearATM = client.GetData("nearATM"); + //SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen + switch (site) + { + //GELD EINZAHLEN in1 + case 0: + + if (user.Handmoney < inputField1) + { + //TODO im CEFBrowser anzeigen + //client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance); + client.SendNotification("~r~Nicht genügend Geld auf der Hand!"); + } + else + { + var updateBankMoneyIn = user.BankAccount; + var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); + user.Handmoney -= inputField1; + updateBankMoneyIn.Balance += inputField1; + updateATMBalanceIn.Balance += inputField1; + client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + } + break; + + //GELD AUSZAHLEN in1 + case 1: + var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); + + if (user.BankAccount.Balance < inputField1) + { + client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen + } + else if (checkATM.Balance < inputField1) + { + client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer + } + else + { + var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id); + var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM); + updateHandMoneyOut.Handmoney += inputField1; + user.BankAccount.Balance -= inputField1; + updateATMBalanceOut.Balance -= inputField1; + client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney); + } + break; + + //GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag + case 2: + + break; + } + dbContext.SaveChanges(); + } + } + } } diff --git a/ReallifeGamemode.Server/Managers/BankManager.cs b/ReallifeGamemode.Server/Managers/BankManager.cs index 1a1d12dd..60e29d0c 100644 --- a/ReallifeGamemode.Server/Managers/BankManager.cs +++ b/ReallifeGamemode.Server/Managers/BankManager.cs @@ -15,98 +15,98 @@ using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Managers { public class BankManager + { + public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt") { - public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt") + using (var transferMoney = new DatabaseContext()) + { + if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT; + + IBankAccount account = owner.GetBankAccount(transferMoney); + + if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT; + + var transactionLog = new BankAccountTransactionHistory { - using (var transferMoney = new DatabaseContext()) - { - if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT; + Sender = "ADMIN: " + admin.Name, + SenderBalance = 0, + Receiver = owner.Name, + ReceiverBalance = amount, + NewReceiverBalance = amount, + NewSenderBalance = 0, + MoneySent = amount, + Fee = 0, + Origin = reason + }; - IBankAccount account = owner.GetBankAccount(transferMoney); + // add log + transferMoney.BankAccountTransactionLogs.Add(transactionLog); - if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT; + account.Balance = amount; - var transactionLog = new BankAccountTransactionHistory - { - Sender = "ADMIN: " + admin.Name, - SenderBalance = 0, - Receiver = owner.Name, - ReceiverBalance = amount, - NewReceiverBalance = amount, - NewSenderBalance = 0, - MoneySent = amount, - Fee = 0, - Origin = reason - }; + transferMoney.SaveChanges(); - // add log - transferMoney.BankAccountTransactionLogs.Add(transactionLog); - - account.Balance = amount; - - transferMoney.SaveChanges(); - - return TransactionResult.SUCCESS; - } - } - - public static TransactionResult TransferMoney( - BankAccountHolder sender, - BankAccountHolder receiver, - int amount, - string origin, - DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new() - { - if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT; - - IBankAccount senderAccount; - IBankAccount receiverAccount; - - if (sender is BankAccountHolder businessSender) - { - senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First(); - } - else - { - senderAccount = sender.BankAccount; - } - - if (receiver is BankAccountHolder businessReceiver) - { - receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First(); - } - else - { - receiverAccount = receiver.BankAccount; - } - - 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 BankAccountTransactionHistory - { - Sender = sender.BankAccountName, - SenderBalance = senderAccount.Balance, - Receiver = receiver.BankAccountName, - ReceiverBalance = receiverAccount.Balance, - NewReceiverBalance = receiverAccount.Balance + amount, - NewSenderBalance = senderAccount.Balance - amount, - MoneySent = amount, - Fee = 0, - Origin = origin - }; - - // add log - dbContext.BankAccountTransactionLogs.Add(transactionLog); - - senderAccount.Balance -= amount; - receiverAccount.Balance += amount; - - dbContext.SaveChanges(); - - return TransactionResult.SUCCESS; - } + return TransactionResult.SUCCESS; + } } + + public static TransactionResult TransferMoney( + BankAccountHolder sender, + BankAccountHolder receiver, + int amount, + string origin, + DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new() + { + if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT; + + IBankAccount senderAccount; + IBankAccount receiverAccount; + + if (sender is BankAccountHolder businessSender) + { + senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First(); + } + else + { + senderAccount = sender.BankAccount; + } + + if (receiver is BankAccountHolder businessReceiver) + { + receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First(); + } + else + { + receiverAccount = receiver.BankAccount; + } + + 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 BankAccountTransactionHistory + { + Sender = sender.BankAccountName, + SenderBalance = senderAccount.Balance, + Receiver = receiver.BankAccountName, + ReceiverBalance = receiverAccount.Balance, + NewReceiverBalance = receiverAccount.Balance + amount, + NewSenderBalance = senderAccount.Balance - amount, + MoneySent = amount, + Fee = 0, + Origin = origin + }; + + // add log + dbContext.BankAccountTransactionLogs.Add(transactionLog); + + senderAccount.Balance -= amount; + receiverAccount.Balance += amount; + + dbContext.SaveChanges(); + + return TransactionResult.SUCCESS; + } + } } diff --git a/ReallifeGamemode.Server/Managers/CharacterCreator.cs b/ReallifeGamemode.Server/Managers/CharacterCreator.cs index 034886d9..871c35f7 100644 --- a/ReallifeGamemode.Server/Managers/CharacterCreator.cs +++ b/ReallifeGamemode.Server/Managers/CharacterCreator.cs @@ -7,326 +7,326 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Managers { public class CharacterCreator : Script + { + [RemoteEvent("creator_GenderChange")] + public void changeGender(Player player, int gender) { - [RemoteEvent("creator_GenderChange")] - public void changeGender(Player player, int gender) + if (gender == 0) player.SetSkin(PedHash.FreemodeMale01); + else player.SetSkin(PedHash.FreemodeFemale01); + } + + [RemoteEvent("creatorSave")] + public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData) + { + var jParentData = JObject.Parse(parentData); + var jFeatureData = JArray.Parse(featureData); + var jAppearanceData = JArray.Parse(appearanceData); + var jHairAndColorData = JArray.Parse(hairAndColorData); + + byte father = jParentData.Value("Father"); + byte mother = jParentData.Value("Mother"); + float similarity = jParentData.Value("Similarity"); + float skinSimilarity = jParentData.Value("SkinSimilarity"); + + float noseWidth = jFeatureData.Value(0); + float noseBottomHeight = jFeatureData.Value(1); + float noseTipLength = jFeatureData.Value(2); + float noseBridgeDepth = jFeatureData.Value(3); + float noseTipHeight = jFeatureData.Value(4); + float noseBroken = jFeatureData.Value(5); + float browHeight = jFeatureData.Value(6); + float browDepth = jFeatureData.Value(7); + float cheekboneHeight = jFeatureData.Value(8); + float cheekboneWidth = jFeatureData.Value(9); + float cheekDepth = jFeatureData.Value(10); + float eyeSize = jFeatureData.Value(11); + float lipThickness = jFeatureData.Value(12); + float jawWidth = jFeatureData.Value(13); + float jawShape = jFeatureData.Value(14); + float chinHeight = jFeatureData.Value(15); + float chinDepth = jFeatureData.Value(16); + float chinWidth = jFeatureData.Value(17); + float chinIndent = jFeatureData.Value(18); + float neckWidth = jFeatureData.Value(19); + + byte blemishes = jAppearanceData[0].Value("Value"); + float blemishesOpacity = jAppearanceData[0].Value("Opacity"); + byte facialHair = jAppearanceData[1].Value("Value"); + float facialHairOpacity = jAppearanceData[1].Value("Opacity"); + byte eyebrows = jAppearanceData[2].Value("Value"); + float eyebrowsOpacity = jAppearanceData[2].Value("Opacity"); + byte ageing = jAppearanceData[3].Value("Value"); + float ageingOpacity = jAppearanceData[3].Value("Opacity"); + byte makeup = jAppearanceData[4].Value("Value"); + float makeupOpacity = jAppearanceData[4].Value("Opacity"); + byte blush = jAppearanceData[5].Value("Value"); + float blushOpacity = jAppearanceData[5].Value("Opacity"); + byte complexion = jAppearanceData[6].Value("Value"); + float complexionOpacity = jAppearanceData[6].Value("Opacity"); + byte sunDamage = jAppearanceData[7].Value("Value"); + float sunDamageOpacity = jAppearanceData[7].Value("Opacity"); + byte lipstick = jAppearanceData[8].Value("Value"); + float lipstickOpacity = jAppearanceData[8].Value("Opacity"); + byte freckles = jAppearanceData[9].Value("Value"); + float frecklesOpacity = jAppearanceData[9].Value("Opacity"); + byte chestHair = jAppearanceData[10].Value("Value"); + float chestHairOpacity = jAppearanceData[10].Value("Opacity"); + + byte hair = jHairAndColorData.Value(0); + byte hairColor = jHairAndColorData.Value(1); + byte hairHighlightColor = jHairAndColorData.Value(2); + byte eyebrowColor = jHairAndColorData.Value(3); + byte beardColor = jHairAndColorData.Value(4); + byte eyeColor = jHairAndColorData.Value(5); + byte blushColor = jHairAndColorData.Value(6); + byte lipstickColor = jHairAndColorData.Value(7); + byte chestHairColor = jHairAndColorData.Value(8); + + using (var saveCharacter = new DatabaseContext()) + { + var character = new Database.Entities.Character { - if (gender == 0) player.SetSkin(PedHash.FreemodeMale01); - else player.SetSkin(PedHash.FreemodeFemale01); + UserId = player.GetUser().Id, + Gender = gender, + Father = father, + Mother = mother, + Similarity = similarity, + SkinSimilarity = skinSimilarity, + + NoseWidth = noseWidth, + NoseBottomHeight = noseBottomHeight, + NoseTipLength = noseTipLength, + NoseBridgeDepth = noseBridgeDepth, + NoseTipHeight = noseTipHeight, + NoseBroken = noseBroken, + BrowHeight = browHeight, + BrowDepth = browDepth, + CheekboneHeight = cheekboneHeight, + CheekboneWidth = cheekboneWidth, + CheekDepth = cheekDepth, + EyeSize = eyeSize, + LipThickness = lipThickness, + JawWidth = jawWidth, + JawShape = jawShape, + ChinHeight = chinHeight, + ChinDepth = chinDepth, + ChinWidth = chinWidth, + ChinIndent = chinIndent, + NeckWidth = neckWidth, + + Blemishes = blemishes, + BlemishesOpacity = blemishesOpacity, + FacialHair = facialHair, + FacialHairOpacity = facialHairOpacity, + Eyebrows = eyebrows, + EyebrowsOpacity = eyebrowsOpacity, + Ageing = ageing, + AgeingOpacity = ageingOpacity, + Makeup = makeup, + MakeupOpacity = makeupOpacity, + Blush = blush, + BlushOpacity = blushOpacity, + Complexion = complexion, + ComplexionOpacity = complexionOpacity, + SunDamage = sunDamage, + SunDamageOpacity = sunDamageOpacity, + Lipstick = lipstick, + LipstickOpacity = lipstickOpacity, + Freckles = freckles, + FrecklesOpacity = frecklesOpacity, + ChestHair = chestHair, + ChestHairOpacity = chestHairOpacity, + + Hair = hair, + HairColor = hairColor, + HairHighlightColor = hairHighlightColor, + EyebrowColor = eyebrowColor, + BeardColor = beardColor, + EyeColor = eyeColor, + BlushColor = blushColor, + LipstickColor = lipstickColor, + ChestHairColor = chestHairColor + }; + + saveCharacter.Characters.Add(character); + saveCharacter.SaveChanges(); + + var userId = player.GetUser().Id; + var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId); + + user.CharacterId = character.Id; + saveCharacter.SaveChanges(); + } + //HeadOverlay makeupHo = new HeadOverlay() + //{ + // Index = 0, + // Opacity = 0.0f, + // Color = 0, + // SecondaryColor = 0 + //}; + //HeadOverlay blushHo = new HeadOverlay() + //{ + // Index = 0, + // Opacity = 0.0f, + // Color = 0, + // SecondaryColor = 0 + //}; + //player.SetHeadOverlay(4, makeupHo); + //player.SetHeadOverlay(5, blushHo); + NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING); + player.TriggerEvent("draw", player.Name, player.Handle.Value); + player.Dimension = 0; + } + + /// + /// Wendet den Character eines Spielers auf diesen an + /// + /// Der Player, dessen Aussehen man setzen will + public static void ApplyCharacter(Player player) + { + var user = player.GetUser(); + using (var loadCharacter = new DatabaseContext()) + { + var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId); + + if (character == null) return; + + //Männlich / Weiblich + if (character.Gender == false) + { + player.SetSkin(PedHash.FreemodeMale01); + } + else + { + player.SetSkin(PedHash.FreemodeFemale01); } - [RemoteEvent("creatorSave")] - public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData) - { - var jParentData = JObject.Parse(parentData); - var jFeatureData = JArray.Parse(featureData); - var jAppearanceData = JArray.Parse(appearanceData); - var jHairAndColorData = JArray.Parse(hairAndColorData); - - byte father = jParentData.Value("Father"); - byte mother = jParentData.Value("Mother"); - float similarity = jParentData.Value("Similarity"); - float skinSimilarity = jParentData.Value("SkinSimilarity"); - - float noseWidth = jFeatureData.Value(0); - float noseBottomHeight = jFeatureData.Value(1); - float noseTipLength = jFeatureData.Value(2); - float noseBridgeDepth = jFeatureData.Value(3); - float noseTipHeight = jFeatureData.Value(4); - float noseBroken = jFeatureData.Value(5); - float browHeight = jFeatureData.Value(6); - float browDepth = jFeatureData.Value(7); - float cheekboneHeight = jFeatureData.Value(8); - float cheekboneWidth = jFeatureData.Value(9); - float cheekDepth = jFeatureData.Value(10); - float eyeSize = jFeatureData.Value(11); - float lipThickness = jFeatureData.Value(12); - float jawWidth = jFeatureData.Value(13); - float jawShape = jFeatureData.Value(14); - float chinHeight = jFeatureData.Value(15); - float chinDepth = jFeatureData.Value(16); - float chinWidth = jFeatureData.Value(17); - float chinIndent = jFeatureData.Value(18); - float neckWidth = jFeatureData.Value(19); - - byte blemishes = jAppearanceData[0].Value("Value"); - float blemishesOpacity = jAppearanceData[0].Value("Opacity"); - byte facialHair = jAppearanceData[1].Value("Value"); - float facialHairOpacity = jAppearanceData[1].Value("Opacity"); - byte eyebrows = jAppearanceData[2].Value("Value"); - float eyebrowsOpacity = jAppearanceData[2].Value("Opacity"); - byte ageing = jAppearanceData[3].Value("Value"); - float ageingOpacity = jAppearanceData[3].Value("Opacity"); - byte makeup = jAppearanceData[4].Value("Value"); - float makeupOpacity = jAppearanceData[4].Value("Opacity"); - byte blush = jAppearanceData[5].Value("Value"); - float blushOpacity = jAppearanceData[5].Value("Opacity"); - byte complexion = jAppearanceData[6].Value("Value"); - float complexionOpacity = jAppearanceData[6].Value("Opacity"); - byte sunDamage = jAppearanceData[7].Value("Value"); - float sunDamageOpacity = jAppearanceData[7].Value("Opacity"); - byte lipstick = jAppearanceData[8].Value("Value"); - float lipstickOpacity = jAppearanceData[8].Value("Opacity"); - byte freckles = jAppearanceData[9].Value("Value"); - float frecklesOpacity = jAppearanceData[9].Value("Opacity"); - byte chestHair = jAppearanceData[10].Value("Value"); - float chestHairOpacity = jAppearanceData[10].Value("Opacity"); - - byte hair = jHairAndColorData.Value(0); - byte hairColor = jHairAndColorData.Value(1); - byte hairHighlightColor = jHairAndColorData.Value(2); - byte eyebrowColor = jHairAndColorData.Value(3); - byte beardColor = jHairAndColorData.Value(4); - byte eyeColor = jHairAndColorData.Value(5); - byte blushColor = jHairAndColorData.Value(6); - byte lipstickColor = jHairAndColorData.Value(7); - byte chestHairColor = jHairAndColorData.Value(8); - - using (var saveCharacter = new DatabaseContext()) - { - var character = new Database.Entities.Character - { - UserId = player.GetUser().Id, - Gender = gender, - Father = father, - Mother = mother, - Similarity = similarity, - SkinSimilarity = skinSimilarity, - - NoseWidth = noseWidth, - NoseBottomHeight = noseBottomHeight, - NoseTipLength = noseTipLength, - NoseBridgeDepth = noseBridgeDepth, - NoseTipHeight = noseTipHeight, - NoseBroken = noseBroken, - BrowHeight = browHeight, - BrowDepth = browDepth, - CheekboneHeight = cheekboneHeight, - CheekboneWidth = cheekboneWidth, - CheekDepth = cheekDepth, - EyeSize = eyeSize, - LipThickness = lipThickness, - JawWidth = jawWidth, - JawShape = jawShape, - ChinHeight = chinHeight, - ChinDepth = chinDepth, - ChinWidth = chinWidth, - ChinIndent = chinIndent, - NeckWidth = neckWidth, - - Blemishes = blemishes, - BlemishesOpacity = blemishesOpacity, - FacialHair = facialHair, - FacialHairOpacity = facialHairOpacity, - Eyebrows = eyebrows, - EyebrowsOpacity = eyebrowsOpacity, - Ageing = ageing, - AgeingOpacity = ageingOpacity, - Makeup = makeup, - MakeupOpacity = makeupOpacity, - Blush = blush, - BlushOpacity = blushOpacity, - Complexion = complexion, - ComplexionOpacity = complexionOpacity, - SunDamage = sunDamage, - SunDamageOpacity = sunDamageOpacity, - Lipstick = lipstick, - LipstickOpacity = lipstickOpacity, - Freckles = freckles, - FrecklesOpacity = frecklesOpacity, - ChestHair = chestHair, - ChestHairOpacity = chestHairOpacity, - - Hair = hair, - HairColor = hairColor, - HairHighlightColor = hairHighlightColor, - EyebrowColor = eyebrowColor, - BeardColor = beardColor, - EyeColor = eyeColor, - BlushColor = blushColor, - LipstickColor = lipstickColor, - ChestHairColor = chestHairColor - }; - - saveCharacter.Characters.Add(character); - saveCharacter.SaveChanges(); - - var userId = player.GetUser().Id; - var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId); - - user.CharacterId = character.Id; - saveCharacter.SaveChanges(); - } - //HeadOverlay makeupHo = new HeadOverlay() - //{ - // Index = 0, - // Opacity = 0.0f, - // Color = 0, - // SecondaryColor = 0 - //}; - //HeadOverlay blushHo = new HeadOverlay() - //{ - // Index = 0, - // Opacity = 0.0f, - // Color = 0, - // SecondaryColor = 0 - //}; - //player.SetHeadOverlay(4, makeupHo); - //player.SetHeadOverlay(5, blushHo); - NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING); - player.TriggerEvent("draw", player.Name, player.Handle.Value); - player.Dimension = 0; - } - - /// - /// Wendet den Character eines Spielers auf diesen an - /// - /// Der Player, dessen Aussehen man setzen will - public static void ApplyCharacter(Player player) - { - var user = player.GetUser(); - using (var loadCharacter = new DatabaseContext()) - { - var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId); - - if (character == null) return; - - //Männlich / Weiblich - if (character.Gender == false) - { - player.SetSkin(PedHash.FreemodeMale01); - } - else - { - player.SetSkin(PedHash.FreemodeFemale01); - } - - //Gesichtszüge - float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight, + //Gesichtszüge + float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight, character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth, character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth, character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth }; - for (var i = 0; i < faceFeatures.Length; i++) - { - player.SetFaceFeature(i, faceFeatures[i]); - } - - //Gesichtsmerkmale - HeadOverlay blemishes = new HeadOverlay() - { - Index = character.Blemishes, - Opacity = character.BlemishesOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay facialHair = new HeadOverlay() - { - Index = character.FacialHair, - Opacity = character.FacialHairOpacity, - Color = character.BeardColor, - SecondaryColor = 255 - }; - HeadOverlay eyebrows = new HeadOverlay() - { - Index = character.Eyebrows, - Opacity = character.EyebrowsOpacity, - Color = character.EyebrowColor, - SecondaryColor = 255 - }; - HeadOverlay ageing = new HeadOverlay() - { - Index = character.Ageing, - Opacity = character.AgeingOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay makeup = new HeadOverlay() - { - Index = character.Makeup, - Opacity = character.MakeupOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay blush = new HeadOverlay() - { - Index = character.Blush, - Opacity = character.BlushOpacity, - Color = character.BlushColor, - SecondaryColor = 255 - }; - HeadOverlay complexion = new HeadOverlay() - { - Index = character.Complexion, - Opacity = character.ComplexionOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay sunDamage = new HeadOverlay() - { - Index = character.SunDamage, - Opacity = character.SunDamageOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay lipstick = new HeadOverlay() - { - Index = character.Lipstick, - Opacity = character.LipstickOpacity, - Color = character.LipstickColor, - SecondaryColor = 255 - }; - HeadOverlay freckles = new HeadOverlay() - { - Index = character.Freckles, - Opacity = character.FrecklesOpacity, - Color = 255, - SecondaryColor = 255 - }; - HeadOverlay chestHair = new HeadOverlay() - { - Index = character.ChestHair, - Opacity = character.ChestHairOpacity, - Color = character.ChestHairColor, - SecondaryColor = 255 - }; - - player.SetHeadOverlay(0, blemishes); - player.SetHeadOverlay(1, facialHair); - player.SetHeadOverlay(2, eyebrows); - player.SetHeadOverlay(3, ageing); - player.SetHeadOverlay(4, makeup); - player.SetHeadOverlay(5, blush); - player.SetHeadOverlay(6, complexion); - player.SetHeadOverlay(7, sunDamage); - player.SetHeadOverlay(8, lipstick); - player.SetHeadOverlay(9, freckles); - player.SetHeadOverlay(10, chestHair); - player.SetHeadOverlay(11, blemishes); - player.SetHeadOverlay(12, blemishes); - - //Gesicht (Vererbung durch Mutter / Vater) - HeadBlend headBlend = new HeadBlend() - { - ShapeFirst = character.Mother, - ShapeSecond = character.Father, - ShapeThird = 0, - SkinFirst = character.Mother, - SkinSecond = character.Father, - SkinThird = 0, - ShapeMix = character.Similarity, - SkinMix = character.SkinSimilarity, - ThirdMix = 0.0f - }; - NAPI.Player.SetPlayerHeadBlend(player, headBlend); - - //Haare und Haarfarbe - player.SetClothes(2, character.Hair, 0); - NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor); - - //Augenfarbe - NAPI.Player.SetPlayerEyeColor(player, character.EyeColor); - } + for (var i = 0; i < faceFeatures.Length; i++) + { + player.SetFaceFeature(i, faceFeatures[i]); } + + //Gesichtsmerkmale + HeadOverlay blemishes = new HeadOverlay() + { + Index = character.Blemishes, + Opacity = character.BlemishesOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay facialHair = new HeadOverlay() + { + Index = character.FacialHair, + Opacity = character.FacialHairOpacity, + Color = character.BeardColor, + SecondaryColor = 255 + }; + HeadOverlay eyebrows = new HeadOverlay() + { + Index = character.Eyebrows, + Opacity = character.EyebrowsOpacity, + Color = character.EyebrowColor, + SecondaryColor = 255 + }; + HeadOverlay ageing = new HeadOverlay() + { + Index = character.Ageing, + Opacity = character.AgeingOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay makeup = new HeadOverlay() + { + Index = character.Makeup, + Opacity = character.MakeupOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay blush = new HeadOverlay() + { + Index = character.Blush, + Opacity = character.BlushOpacity, + Color = character.BlushColor, + SecondaryColor = 255 + }; + HeadOverlay complexion = new HeadOverlay() + { + Index = character.Complexion, + Opacity = character.ComplexionOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay sunDamage = new HeadOverlay() + { + Index = character.SunDamage, + Opacity = character.SunDamageOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay lipstick = new HeadOverlay() + { + Index = character.Lipstick, + Opacity = character.LipstickOpacity, + Color = character.LipstickColor, + SecondaryColor = 255 + }; + HeadOverlay freckles = new HeadOverlay() + { + Index = character.Freckles, + Opacity = character.FrecklesOpacity, + Color = 255, + SecondaryColor = 255 + }; + HeadOverlay chestHair = new HeadOverlay() + { + Index = character.ChestHair, + Opacity = character.ChestHairOpacity, + Color = character.ChestHairColor, + SecondaryColor = 255 + }; + + player.SetHeadOverlay(0, blemishes); + player.SetHeadOverlay(1, facialHair); + player.SetHeadOverlay(2, eyebrows); + player.SetHeadOverlay(3, ageing); + player.SetHeadOverlay(4, makeup); + player.SetHeadOverlay(5, blush); + player.SetHeadOverlay(6, complexion); + player.SetHeadOverlay(7, sunDamage); + player.SetHeadOverlay(8, lipstick); + player.SetHeadOverlay(9, freckles); + player.SetHeadOverlay(10, chestHair); + player.SetHeadOverlay(11, blemishes); + player.SetHeadOverlay(12, blemishes); + + //Gesicht (Vererbung durch Mutter / Vater) + HeadBlend headBlend = new HeadBlend() + { + ShapeFirst = character.Mother, + ShapeSecond = character.Father, + ShapeThird = 0, + SkinFirst = character.Mother, + SkinSecond = character.Father, + SkinThird = 0, + ShapeMix = character.Similarity, + SkinMix = character.SkinSimilarity, + ThirdMix = 0.0f + }; + NAPI.Player.SetPlayerHeadBlend(player, headBlend); + + //Haare und Haarfarbe + player.SetClothes(2, character.Hair, 0); + NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor); + + //Augenfarbe + NAPI.Player.SetPlayerEyeColor(player, character.EyeColor); + } } + } } diff --git a/ReallifeGamemode.Server/Managers/DoorManager.cs b/ReallifeGamemode.Server/Managers/DoorManager.cs index 35e44bb7..45c661a5 100644 --- a/ReallifeGamemode.Server/Managers/DoorManager.cs +++ b/ReallifeGamemode.Server/Managers/DoorManager.cs @@ -15,71 +15,71 @@ using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Managers { public class DoorManager : Script + { + private static Dictionary _doorColShapes = new Dictionary(); + + public static void LoadDoors() { - private static Dictionary _doorColShapes = new Dictionary(); - - public static void LoadDoors() + using (var dbContext = new DatabaseContext()) + { + foreach (Door door in dbContext.Doors) { - using (var dbContext = new DatabaseContext()) - { - foreach (Door door in dbContext.Doors) - { - _doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f); - } - } - } - - public static void ReloadDoors() - { - foreach (var doorPair in _doorColShapes) - { - doorPair.Value.Entity().Delete(); - } - _doorColShapes.Clear(); - LoadDoors(); - } - - public static void ChangeDoorState(Player player) - { - var user = player.GetUser(); - - using (var dbContext = new DatabaseContext()) - { - IQueryable NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius); - foreach (Door d in NearDoors) - { - 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; - } - - d.Locked = !d.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, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f)); - } - dbContext.SaveChanges(); - } - } - - [ServerEvent(Event.PlayerEnterColshape)] - public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player) - { - if (_doorColShapes.ContainsValue(colShape.Handle)) - { - int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key; - - using (var dbContext = new DatabaseContext()) - { - Door door = dbContext.Doors.Where(d => d.Id == doorId).First(); - player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f); - } - } + _doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f); } + } } + + public static void ReloadDoors() + { + foreach (var doorPair in _doorColShapes) + { + doorPair.Value.Entity().Delete(); + } + _doorColShapes.Clear(); + LoadDoors(); + } + + public static void ChangeDoorState(Player player) + { + var user = player.GetUser(); + + using (var dbContext = new DatabaseContext()) + { + IQueryable NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius); + foreach (Door d in NearDoors) + { + 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; + } + + d.Locked = !d.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, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f)); + } + dbContext.SaveChanges(); + } + } + + [ServerEvent(Event.PlayerEnterColshape)] + public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player) + { + if (_doorColShapes.ContainsValue(colShape.Handle)) + { + int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key; + + using (var dbContext = new DatabaseContext()) + { + Door door = dbContext.Doors.Where(d => d.Id == doorId).First(); + player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f); + } + } + } + } } diff --git a/ReallifeGamemode.Server/Managers/JobManager.cs b/ReallifeGamemode.Server/Managers/JobManager.cs index 487bd9f1..6a32d06f 100644 --- a/ReallifeGamemode.Server/Managers/JobManager.cs +++ b/ReallifeGamemode.Server/Managers/JobManager.cs @@ -15,320 +15,320 @@ using ReallifeGamemode.Services; namespace ReallifeGamemode.Server.Managers { public class JobManager : Script + { + private static List _jobs = new List(); + + public static void LoadJobs() { - private static List _jobs = new List(); + IEnumerable jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract); - public static void LoadJobs() + foreach (var type in jobTypes) + { + var instance = Activator.CreateInstance(type) as JobBase; + if (GetJob(instance.Id) != null) { - IEnumerable jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract); - - foreach (var type in jobTypes) - { - var instance = Activator.CreateInstance(type) as JobBase; - if (GetJob(instance.Id) != null) - { - throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}"); - } - _jobs.Add(instance); - NAPI.Util.ConsoleOutput($"Loading job {instance.Name}"); - } - NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs"); - } - - public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault(); - - public static T GetJob() where T : JobBase - { - return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T; - } - - public static List GetJobs() => _jobs.OrderBy(j => j.Id).ToList(); - - [RemoteEvent("CLIENT:JobCenter_CancelJob")] - public void CancelJobEvent(Player player) - { - using (var dbContext = new DatabaseContext()) - { - User u = player.GetUser(dbContext); - - if (u == null) return; - - if (u.JobId == null) - { - ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest."); - return; - } - - u.JobId = null; - - ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt."); - - dbContext.SaveChanges(); - } - } - - [RemoteEvent("CLIENT:JobCenter_AcceptJob")] - public void AcceptJobEvent(Player player, int jobId) - { - using (var dbContext = new DatabaseContext()) - { - User u = player.GetUser(dbContext); - - if (u == null) return; - - if (u.JobId != null) - { - ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst"); - return; - } - - JobBase job = JobManager.GetJob(jobId); - - if (job == null) - { - ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden"); - return; - } - - ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen."); - - u.JobId = jobId; - - dbContext.SaveChanges(); - } - } - - [RemoteEvent("CLIENT:JobManager_ShowJobMenu")] - public void ShowJobMenuEvent(Player player) - { - User u = player.GetUser(); - - if (u.JobId == null) return; - - JobBase job = GetJob(u.JobId.Value); - - dynamic data = null; - - if (job.Id == 1 && job.GetUsersInJob().Contains(player)) - { - var taxiCalls = JobManager.GetJob().TaxiContracts; - if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt - { - data = new - { - job.Id, - Status = 0, - JobData = new - { - TaxiCalls = taxiCalls - .Where(t => t.Driver == null) - .Select(t => new - { - t.Name, - Distance = Math.Round(t.Position.DistanceTo(player.Position), 0) - }) - .OrderBy(t => t.Distance) - } - }; - } - else // Spieler in aktiver Fahrt - { - data = new - { - job.Id, - Status = 1, - JobData = new - { - taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name - } - }; - } - } - JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2); - if (nearJobPoint == null && u.JobId == 2) return; - - var json = JsonConvert.SerializeObject(data); - - player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json); - } - - [RemoteEvent("CLIENT:Job_StartJob")] - public void StartJobEvent(Player player) - { - User u = player.GetUser(); - - if (u.JobId == null) return; - - JobBase job = GetJob(u.JobId.Value); - - if (job.GetUsersInJob().Contains(player)) - { - ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv"); - return; - } - - if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value)) - { - ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein"); - return; - } - - job.StartJob(player); - } - - [RemoteEvent("CLIENT:Job_StopJob")] - public void StopJob(Player player) - { - User u = player.GetUser(); - - if (u.JobId == null) return; - - JobBase job = GetJob(u.JobId.Value); - - if (!job.GetUsersInJob().Contains(player)) - { - ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus"); - return; - } - - if (job.NeedVehicleToStart && player.Vehicle != null) - { - VehicleStreaming.SetEngineState(player.Vehicle, false); - } - - job.StopJob(player); - } - - [ServerEvent(Event.PlayerExitVehicle)] - public void JobManagerPlayerExitVehicle(Player player, Vehicle veh) - { - User u = player.GetUser(); - - if (u.JobId == null) return; - - JobBase job = GetJob(u.JobId.Value); - - if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart) - { - job.StopJob(player); - return; - } - } - - [ServerEvent(Event.PlayerEnterVehicle)] - public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat) - { - if (seat == 0) return; - ServerVehicle sVeh = veh.GetServerVehicle(); - if (sVeh == null) return; - if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein - { - var taxiJob = JobManager.GetJob(); - - Player driver = veh.GetDriver(); - if (!driver.HasData("DriverPrice")) return; - int taxiPrice = driver.GetData("DriverPrice"); - float km = 0; - if (!driver.HasData("FareKm")) { driver.SetData("FareKm", km); } - km = driver.GetData("FareKm"); - if (driver.HasData("Passager")) return; - driver.SetData("Passager", player.GetUser().Id); - driver.SetData("hasPassager", true); - using (var dbContext = new DatabaseContext()) - { - User contractUser = player.GetUser(dbContext); - contractUser.Handmoney -= (int)Math.Round(km * taxiPrice); - dbContext.SaveChanges(); - contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney); - } - player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km); - - var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name); - if (taxiContracts.Count() == 0) return; - - var contract = taxiContracts.First(); - taxiJob.TaxiContracts.Remove(contract); - - if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle) - { - ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet."); - ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet."); - } - } - } - - [ServerEvent(Event.PlayerEnterVehicleAttempt)] - private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat) - { - if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); } - } - - [ServerEvent(Event.PlayerDeath)] - private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason) - { - if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerDeath(player); } - } - - [ServerEvent(Event.PlayerDisconnected)] - private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason) - { - if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerDc(player); } - } - - [ServerEvent(Event.PlayerExitVehicle)] - public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh) - { - ServerVehicle sVeh = veh.GetServerVehicle(); - if (sVeh == null) return; - if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus - { - var taxiJob = JobManager.GetJob(); - if (veh.Occupants.Count == 0) return; - Player driver = veh.GetDriver(); - if (driver == null) return; - if (player.GetUser().Id != driver.GetData("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; } - player.TriggerEvent("CLIENT:cancelFareCustomer"); - driver.TriggerEvent("CLIENT:resetFareClock"); - driver.ResetData("Passager"); - driver.ResetData("hasPassager"); - driver.SetData("FareKm", 0); - foreach (Player occupant in veh.Occupants) - { - if (occupant == driver) continue; - occupant.WarpOutOfVehicle(); - } - } - } - - [RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")] - public void TaxiJobAcceptCall(Player player, string name) - { - var taxiJob = JobManager.GetJob(); - - if (!taxiJob.TaxiContracts.Any(t => t.Name == name)) - { - ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell"); - return; - } - - var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First(); - - var target = PlayerService.GetPlayerByNameOrId(name); - if (target == null) - { - taxiJob.TaxiContracts.Remove(job); - ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online"); - return; - } - - job.Driver = player; - - player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y); - player.SetData("hasPassager", true); - - ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position."); - ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf."); - ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab."); + throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}"); } + _jobs.Add(instance); + NAPI.Util.ConsoleOutput($"Loading job {instance.Name}"); + } + NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs"); } + + public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault(); + + public static T GetJob() where T : JobBase + { + return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T; + } + + public static List GetJobs() => _jobs.OrderBy(j => j.Id).ToList(); + + [RemoteEvent("CLIENT:JobCenter_CancelJob")] + public void CancelJobEvent(Player player) + { + using (var dbContext = new DatabaseContext()) + { + User u = player.GetUser(dbContext); + + if (u == null) return; + + if (u.JobId == null) + { + ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest."); + return; + } + + u.JobId = null; + + ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt."); + + dbContext.SaveChanges(); + } + } + + [RemoteEvent("CLIENT:JobCenter_AcceptJob")] + public void AcceptJobEvent(Player player, int jobId) + { + using (var dbContext = new DatabaseContext()) + { + User u = player.GetUser(dbContext); + + if (u == null) return; + + if (u.JobId != null) + { + ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst"); + return; + } + + JobBase job = JobManager.GetJob(jobId); + + if (job == null) + { + ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden"); + return; + } + + ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen."); + + u.JobId = jobId; + + dbContext.SaveChanges(); + } + } + + [RemoteEvent("CLIENT:JobManager_ShowJobMenu")] + public void ShowJobMenuEvent(Player player) + { + User u = player.GetUser(); + + if (u.JobId == null) return; + + JobBase job = GetJob(u.JobId.Value); + + dynamic data = null; + + if (job.Id == 1 && job.GetUsersInJob().Contains(player)) + { + var taxiCalls = JobManager.GetJob().TaxiContracts; + if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt + { + data = new + { + job.Id, + Status = 0, + JobData = new + { + TaxiCalls = taxiCalls + .Where(t => t.Driver == null) + .Select(t => new + { + t.Name, + Distance = Math.Round(t.Position.DistanceTo(player.Position), 0) + }) + .OrderBy(t => t.Distance) + } + }; + } + else // Spieler in aktiver Fahrt + { + data = new + { + job.Id, + Status = 1, + JobData = new + { + taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name + } + }; + } + } + JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2); + if (nearJobPoint == null && u.JobId == 2) return; + + var json = JsonConvert.SerializeObject(data); + + player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json); + } + + [RemoteEvent("CLIENT:Job_StartJob")] + public void StartJobEvent(Player player) + { + User u = player.GetUser(); + + if (u.JobId == null) return; + + JobBase job = GetJob(u.JobId.Value); + + if (job.GetUsersInJob().Contains(player)) + { + ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv"); + return; + } + + if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value)) + { + ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein"); + return; + } + + job.StartJob(player); + } + + [RemoteEvent("CLIENT:Job_StopJob")] + public void StopJob(Player player) + { + User u = player.GetUser(); + + if (u.JobId == null) return; + + JobBase job = GetJob(u.JobId.Value); + + if (!job.GetUsersInJob().Contains(player)) + { + ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus"); + return; + } + + if (job.NeedVehicleToStart && player.Vehicle != null) + { + VehicleStreaming.SetEngineState(player.Vehicle, false); + } + + job.StopJob(player); + } + + [ServerEvent(Event.PlayerExitVehicle)] + public void JobManagerPlayerExitVehicle(Player player, Vehicle veh) + { + User u = player.GetUser(); + + if (u.JobId == null) return; + + JobBase job = GetJob(u.JobId.Value); + + if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart) + { + job.StopJob(player); + return; + } + } + + [ServerEvent(Event.PlayerEnterVehicle)] + public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat) + { + if (seat == 0) return; + ServerVehicle sVeh = veh.GetServerVehicle(); + if (sVeh == null) return; + if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein + { + var taxiJob = JobManager.GetJob(); + + Player driver = veh.GetDriver(); + if (!driver.HasData("DriverPrice")) return; + int taxiPrice = driver.GetData("DriverPrice"); + float km = 0; + if (!driver.HasData("FareKm")) { driver.SetData("FareKm", km); } + km = driver.GetData("FareKm"); + if (driver.HasData("Passager")) return; + driver.SetData("Passager", player.GetUser().Id); + driver.SetData("hasPassager", true); + using (var dbContext = new DatabaseContext()) + { + User contractUser = player.GetUser(dbContext); + contractUser.Handmoney -= (int)Math.Round(km * taxiPrice); + dbContext.SaveChanges(); + contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney); + } + player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km); + + var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name); + if (taxiContracts.Count() == 0) return; + + var contract = taxiContracts.First(); + taxiJob.TaxiContracts.Remove(contract); + + if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle) + { + ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet."); + ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet."); + } + } + } + + [ServerEvent(Event.PlayerEnterVehicleAttempt)] + private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat) + { + if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); } + } + + [ServerEvent(Event.PlayerDeath)] + private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason) + { + if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerDeath(player); } + } + + [ServerEvent(Event.PlayerDisconnected)] + private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason) + { + if (JobManager.GetJob().GetUsersInJob().Contains(player)) { JobManager.GetJob().MuellmannOnPlayerDc(player); } + } + + [ServerEvent(Event.PlayerExitVehicle)] + public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh) + { + ServerVehicle sVeh = veh.GetServerVehicle(); + if (sVeh == null) return; + if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus + { + var taxiJob = JobManager.GetJob(); + if (veh.Occupants.Count == 0) return; + Player driver = veh.GetDriver(); + if (driver == null) return; + if (player.GetUser().Id != driver.GetData("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; } + player.TriggerEvent("CLIENT:cancelFareCustomer"); + driver.TriggerEvent("CLIENT:resetFareClock"); + driver.ResetData("Passager"); + driver.ResetData("hasPassager"); + driver.SetData("FareKm", 0); + foreach (Player occupant in veh.Occupants) + { + if (occupant == driver) continue; + occupant.WarpOutOfVehicle(); + } + } + } + + [RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")] + public void TaxiJobAcceptCall(Player player, string name) + { + var taxiJob = JobManager.GetJob(); + + if (!taxiJob.TaxiContracts.Any(t => t.Name == name)) + { + ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell"); + return; + } + + var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First(); + + var target = PlayerService.GetPlayerByNameOrId(name); + if (target == null) + { + taxiJob.TaxiContracts.Remove(job); + ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online"); + return; + } + + job.Driver = player; + + player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y); + player.SetData("hasPassager", true); + + ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position."); + ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf."); + ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab."); + } + } } diff --git a/ReallifeGamemode.Server/Managers/LoadManager.cs b/ReallifeGamemode.Server/Managers/LoadManager.cs index cc4aaddd..cd389753 100644 --- a/ReallifeGamemode.Server/Managers/LoadManager.cs +++ b/ReallifeGamemode.Server/Managers/LoadManager.cs @@ -13,29 +13,29 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Managers { public class LoadManager : Script + { + [ServerEvent(Event.ResourceStart)] + public void OnResourceStart() { - [ServerEvent(Event.ResourceStart)] - public void OnResourceStart() + using (var dbContext = new DatabaseContext()) + { + foreach (SavedBlip b in dbContext.Blips) { - using (var dbContext = new DatabaseContext()) - { - foreach (SavedBlip b in dbContext.Blips) - { - if (b.Active == true) - { - NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale, - b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension); - } - } - - foreach (ServerVehicle veh in dbContext.ServerVehicles) - { - if (!veh.Active) continue; - - Vehicle current = veh.Spawn(); - TuningManager.ApplyTuningToServerVehicle(veh); - } - } + if (b.Active == true) + { + NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale, + b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension); + } } + + foreach (ServerVehicle veh in dbContext.ServerVehicles) + { + if (!veh.Active) continue; + + Vehicle current = veh.Spawn(); + TuningManager.ApplyTuningToServerVehicle(veh); + } + } } + } } diff --git a/ReallifeGamemode.Server/Managers/PedManager.cs b/ReallifeGamemode.Server/Managers/PedManager.cs index d6ba37da..0a176366 100644 --- a/ReallifeGamemode.Server/Managers/PedManager.cs +++ b/ReallifeGamemode.Server/Managers/PedManager.cs @@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Managers { public class PedManager : Script { - private List pedDatas = new List(); + private List pedDatas = new List(); public static List serverPeds = new List(); private static Dictionary> dataDict = new Dictionary>(); private void GetPedsFromDatabase() @@ -42,7 +42,7 @@ namespace ReallifeGamemode.Server.Managers if (!s.Active) continue; Vector3 vector3 = new Vector3(s.PositionX, s.PositionY, s.PositionZ); pedDatas.Add(new PedData(player, (DataType)s.Type, vector3, s.Heading, s.HashModel)); - + vector3s.Add(vector3); headings.Add(s.Heading); hashes.Add(s.HashModel); diff --git a/ReallifeGamemode.Server/Managers/SaveManager.cs b/ReallifeGamemode.Server/Managers/SaveManager.cs index 9fe32326..429e6a2f 100644 --- a/ReallifeGamemode.Server/Managers/SaveManager.cs +++ b/ReallifeGamemode.Server/Managers/SaveManager.cs @@ -10,195 +10,195 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Managers { public class SaveManager : Script + { + [RemoteEvent("OnSaveBlipData")] + public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor, + string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension) { - [RemoteEvent("OnSaveBlipData")] - public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor, - string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension) + float x = player.Position.X; + float y = player.Position.Y; + float z = player.Position.Z; + short sprite = short.Parse(blipSprite); + string name = blipName; + float scale = float.Parse(blipScale); + byte color = Convert.ToByte(blipColor); + byte alpha = Convert.ToByte(blipAlpha); + float drawDistance = float.Parse(blipDrawDistance); + bool shortRange = bool.Parse(blipShortRange); + float rotation = float.Parse(blipRotation); + byte dimension = Convert.ToByte(blipDimension); + + NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension); + + using (var saveData = new DatabaseContext()) + { + var dataSet = new SavedBlip { - float x = player.Position.X; - float y = player.Position.Y; - float z = player.Position.Z; - short sprite = short.Parse(blipSprite); - string name = blipName; - float scale = float.Parse(blipScale); - byte color = Convert.ToByte(blipColor); - byte alpha = Convert.ToByte(blipAlpha); - float drawDistance = float.Parse(blipDrawDistance); - bool shortRange = bool.Parse(blipShortRange); - float rotation = float.Parse(blipRotation); - byte dimension = Convert.ToByte(blipDimension); + Sprite = sprite, + PositionX = x, + PositionY = y, + PositionZ = z, + Name = blipName, + Scale = scale, + Color = color, + Alpha = alpha, + DrawDistance = drawDistance, + ShortRange = shortRange, + Rotation = rotation, + Dimension = dimension, + Active = true + }; + saveData.Blips.Add(dataSet); + saveData.SaveChanges(); + } + } - NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension); - - using (var saveData = new DatabaseContext()) - { - var dataSet = new SavedBlip - { - Sprite = sprite, - PositionX = x, - PositionY = y, - PositionZ = z, - Name = blipName, - Scale = scale, - Color = color, - Alpha = alpha, - DrawDistance = drawDistance, - ShortRange = shortRange, - Rotation = rotation, - Dimension = dimension, - Active = true - }; - saveData.Blips.Add(dataSet); - saveData.SaveChanges(); - } - } - - public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, - string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked) + public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, + string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new SavedVehicle { - using (var saveData = new DatabaseContext()) - { - var dataSet = new SavedVehicle - { - Model = vehicleModel, - PositionX = vehiclePosition.X, - PositionY = vehiclePosition.Y, - PositionZ = vehiclePosition.Z, - Heading = vehicleHeading, - NumberPlate = vehicleNumberPlate, - PrimaryColor = vehiclePrimaryColor, - SecondaryColor = vehicleSecondaryColor, - Locked = vehicleLocked, - Active = true - }; - saveData.Vehicles.Add(dataSet); - saveData.SaveChanges(); + Model = vehicleModel, + PositionX = vehiclePosition.X, + PositionY = vehiclePosition.Y, + PositionZ = vehiclePosition.Z, + Heading = vehicleHeading, + NumberPlate = vehicleNumberPlate, + PrimaryColor = vehiclePrimaryColor, + SecondaryColor = vehicleSecondaryColor, + Locked = vehicleLocked, + Active = true + }; + saveData.Vehicles.Add(dataSet); + saveData.SaveChanges(); - return dataSet.Spawn(veh); - } - } + return dataSet.Spawn(veh); + } + } - public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, - string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId) + public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, + string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new JobVehicle { - using (var saveData = new DatabaseContext()) - { - var dataSet = new JobVehicle - { - Model = vehicleModel, - JobId = jobId, - PositionX = vehiclePosition.X, - PositionY = vehiclePosition.Y, - PositionZ = vehiclePosition.Z, - Heading = vehicleHeading, - NumberPlate = vehicleNumberPlate, - PrimaryColor = vehiclePrimaryColor, - SecondaryColor = vehicleSecondaryColor, - Locked = vehicleLocked, - Active = true - }; - saveData.JobVehicles.Add(dataSet); - saveData.SaveChanges(); + Model = vehicleModel, + JobId = jobId, + PositionX = vehiclePosition.X, + PositionY = vehiclePosition.Y, + PositionZ = vehiclePosition.Z, + Heading = vehicleHeading, + NumberPlate = vehicleNumberPlate, + PrimaryColor = vehiclePrimaryColor, + SecondaryColor = vehicleSecondaryColor, + Locked = vehicleLocked, + Active = true + }; + saveData.JobVehicles.Add(dataSet); + saveData.SaveChanges(); - return dataSet.Spawn(veh); - } - } + return dataSet.Spawn(veh); + } + } - public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, - string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId) + public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, + string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new SchoolVehicle { - using (var saveData = new DatabaseContext()) - { - var dataSet = new SchoolVehicle - { - Model = vehicleModel, - SchoolId = schoolId, - PositionX = vehiclePosition.X, - PositionY = vehiclePosition.Y, - PositionZ = vehiclePosition.Z, - Heading = vehicleHeading, - NumberPlate = vehicleNumberPlate, - PrimaryColor = vehiclePrimaryColor, - SecondaryColor = vehicleSecondaryColor, - Locked = vehicleLocked, - Active = true - }; - saveData.SchoolVehicles.Add(dataSet); - saveData.SaveChanges(); + Model = vehicleModel, + SchoolId = schoolId, + PositionX = vehiclePosition.X, + PositionY = vehiclePosition.Y, + PositionZ = vehiclePosition.Z, + Heading = vehicleHeading, + NumberPlate = vehicleNumberPlate, + PrimaryColor = vehiclePrimaryColor, + SecondaryColor = vehicleSecondaryColor, + Locked = vehicleLocked, + Active = true + }; + saveData.SchoolVehicles.Add(dataSet); + saveData.SaveChanges(); - return dataSet.Spawn(veh); - } - } + return dataSet.Spawn(veh); + } + } - public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, - string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery) + public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading, + string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new FactionVehicle { - using (var saveData = new DatabaseContext()) - { - var dataSet = new FactionVehicle - { - Model = vehicleModel, - Owners = JsonConvert.SerializeObject(factionId), - PositionX = vehiclePosition.X, - PositionY = vehiclePosition.Y, - PositionZ = vehiclePosition.Z, - Heading = vehicleHeading, - NumberPlate = vehicleNumberPlate, - PrimaryColor = vehiclePrimaryColor, - SecondaryColor = vehicleSecondaryColor, - Locked = vehicleLocked, - Active = true, - Livery = livery - }; - saveData.FactionVehicles.Add(dataSet); - saveData.SaveChanges(); + Model = vehicleModel, + Owners = JsonConvert.SerializeObject(factionId), + PositionX = vehiclePosition.X, + PositionY = vehiclePosition.Y, + PositionZ = vehiclePosition.Z, + Heading = vehicleHeading, + NumberPlate = vehicleNumberPlate, + PrimaryColor = vehiclePrimaryColor, + SecondaryColor = vehicleSecondaryColor, + Locked = vehicleLocked, + Active = true, + Livery = livery + }; + saveData.FactionVehicles.Add(dataSet); + saveData.SaveChanges(); - return dataSet.Spawn(veh); - } - } + return dataSet.Spawn(veh); + } + } - public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading, - string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price) + public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading, + string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new ShopVehicle { - using (var saveData = new DatabaseContext()) - { - var dataSet = new ShopVehicle - { - Model = vehicleModel, - PositionX = vehiclePosition.X, - PositionY = vehiclePosition.Y, - PositionZ = vehiclePosition.Z, - Heading = vehicleHeading, - NumberPlate = vehicleNumberPlate, - PrimaryColor = vehiclePrimaryColor, - SecondaryColor = vehicleSecondaryColor, - Active = true, - BusinessId = business.Id, - Price = price - }; - saveData.ShopVehicles.Add(dataSet); - saveData.SaveChanges(); + Model = vehicleModel, + PositionX = vehiclePosition.X, + PositionY = vehiclePosition.Y, + PositionZ = vehiclePosition.Z, + Heading = vehicleHeading, + NumberPlate = vehicleNumberPlate, + PrimaryColor = vehiclePrimaryColor, + SecondaryColor = vehicleSecondaryColor, + Active = true, + BusinessId = business.Id, + Price = price + }; + saveData.ShopVehicles.Add(dataSet); + saveData.SaveChanges(); - return dataSet.Spawn(veh); - } - } + return dataSet.Spawn(veh); + } + } - public static void SaveGotoPoint(Player player, string description) + public static void SaveGotoPoint(Player player, string description) + { + using (var saveData = new DatabaseContext()) + { + var dataSet = new GotoPoint { - using (var saveData = new DatabaseContext()) - { - var dataSet = new GotoPoint - { - Description = description, - X = player.Position.X, - Y = player.Position.Y, - Z = player.Position.Z, - Active = true - }; - saveData.GotoPoints.Add(dataSet); - saveData.SaveChanges(); - } - } + Description = description, + X = player.Position.X, + Y = player.Position.Y, + Z = player.Position.Z, + Active = true + }; + saveData.GotoPoints.Add(dataSet); + saveData.SaveChanges(); + } + } public static void SaveAllOnSave() { @@ -219,8 +219,8 @@ namespace ReallifeGamemode.Server.Managers user.PositionZ = pos.Z; } - saveAll.SaveChanges(); - } - } + saveAll.SaveChanges(); + } } -} \ No newline at end of file + } +} diff --git a/ReallifeGamemode.Server/Managers/ShopManager.cs b/ReallifeGamemode.Server/Managers/ShopManager.cs index 89989a2a..2ff820c6 100644 --- a/ReallifeGamemode.Server/Managers/ShopManager.cs +++ b/ReallifeGamemode.Server/Managers/ShopManager.cs @@ -9,57 +9,57 @@ using ReallifeGamemode.Server.Shop.SevenEleven; namespace ReallifeGamemode.Server.Managers { public class ShopManager + { + public static List clotheStores = new List(); + public static List itemShops = new List(); + + public static void LoadClotheShops() { - public static List clotheStores = new List(); - public static List itemShops = new List(); + using (var dbContext = new DatabaseContext()) + { + List discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store"); + List midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban"); + List luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys"); - public static void LoadClotheShops() + foreach (var store in discount) { - using (var dbContext = new DatabaseContext()) - { - List discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store"); - List midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban"); - List luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys"); - - foreach (var store in discount) - { - Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); - ClotheShop newShop = new ClotheShop(1, pos); - clotheStores.Add(newShop); - NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); - } - foreach (var store in midclass) - { - Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); - ClotheShop newShop = new ClotheShop(2, pos); - clotheStores.Add(newShop); - NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); - } - foreach (var store in luxury) - { - Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); - ClotheShop newShop = new ClotheShop(3, pos); - clotheStores.Add(newShop); - NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); - } - } + Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); + ClotheShop newShop = new ClotheShop(1, pos); + clotheStores.Add(newShop); + NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); } - - public static void LoadItemShops() + foreach (var store in midclass) { - using (var dbContext = new DatabaseContext()) - { - int id = 0; - List shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7"); - foreach (var store in shops) - { - Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); - ItemShop newShop = new ItemShop(pos, id); - itemShops.Add(newShop); - id++; - } - NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7"); - } + Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); + ClotheShop newShop = new ClotheShop(2, pos); + clotheStores.Add(newShop); + NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); } + foreach (var store in luxury) + { + Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); + ClotheShop newShop = new ClotheShop(3, pos); + clotheStores.Add(newShop); + NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); + } + } } + + public static void LoadItemShops() + { + using (var dbContext = new DatabaseContext()) + { + int id = 0; + List shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7"); + foreach (var store in shops) + { + Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ); + ItemShop newShop = new ItemShop(pos, id); + itemShops.Add(newShop); + id++; + } + NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7"); + } + } + } } diff --git a/ReallifeGamemode.Server/Managers/TimeManager.cs b/ReallifeGamemode.Server/Managers/TimeManager.cs index 05153cf5..97fc3d19 100644 --- a/ReallifeGamemode.Server/Managers/TimeManager.cs +++ b/ReallifeGamemode.Server/Managers/TimeManager.cs @@ -5,29 +5,29 @@ using GTANetworkAPI; namespace ReallifeGamemode.Server.Managers { public class TimeManager + { + private static Timer realTimeTimer; + + public static void StartTimeManager() { - private static Timer realTimeTimer; + if (realTimeTimer == null) + { + realTimeTimer = new Timer(1000); + realTimeTimer.Elapsed += SetTime; + } - public static void StartTimeManager() - { - if (realTimeTimer == null) - { - realTimeTimer = new Timer(1000); - realTimeTimer.Elapsed += SetTime; - } - - realTimeTimer.Start(); - } - - public static void PauseTimeManager() - { - realTimeTimer.Stop(); - } - - private static void SetTime(object sender, ElapsedEventArgs args) - { - DateTime now = DateTime.Now; - NAPI.World.SetTime(now.Hour, now.Minute, now.Second); - } + realTimeTimer.Start(); } + + public static void PauseTimeManager() + { + realTimeTimer.Stop(); + } + + private static void SetTime(object sender, ElapsedEventArgs args) + { + DateTime now = DateTime.Now; + NAPI.World.SetTime(now.Hour, now.Minute, now.Second); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190226185806_Initial.cs b/ReallifeGamemode.Server/Migrations/20190226185806_Initial.cs index bdd0b5cf..7d0c512d 100644 --- a/ReallifeGamemode.Server/Migrations/20190226185806_Initial.cs +++ b/ReallifeGamemode.Server/Migrations/20190226185806_Initial.cs @@ -5,877 +5,877 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "BankAccountTransactionLogs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Sender = table.Column(maxLength: 32, nullable: true), - SenderBalance = table.Column(nullable: false), - MoneySent = table.Column(nullable: false), - Receiver = table.Column(maxLength: 32, nullable: true), - ReceiverBalance = table.Column(nullable: false), - NewSenderBalance = table.Column(nullable: false), - NewReceiverBalance = table.Column(nullable: false), - Fee = table.Column(nullable: false), - Origin = table.Column(maxLength: 32, nullable: true), - Timestamp = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - }, - constraints: table => - { - table.PrimaryKey("PK_BankAccountTransactionLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Blips", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Sprite = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Name = table.Column(nullable: true), - Scale = table.Column(nullable: false), - Color = table.Column(nullable: false), - Alpha = table.Column(nullable: false), - DrawDistance = table.Column(nullable: false), - ShortRange = table.Column(nullable: false), - Rotation = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Blips", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BusinessBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Balance = table.Column(nullable: false), - BusinessId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ClothCombinations", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Gender = table.Column(nullable: false), - Top = table.Column(nullable: false), - Torso = table.Column(nullable: false), - Undershirt = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ClothCombinations", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Factions", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 32, nullable: true), - StateOwned = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Factions", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "GotoPoints", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(maxLength: 32, nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GotoPoints", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Interiors", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), - EnterPosition = table.Column(nullable: true), - ExitPosition = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Interiors", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Markers", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Scale = table.Column(nullable: false), - DirectionX = table.Column(nullable: false), - DirectionY = table.Column(nullable: false), - DirectionZ = table.Column(nullable: false), - RotationX = table.Column(nullable: false), - RotationY = table.Column(nullable: false), - RotationZ = table.Column(nullable: false), - ColorR = table.Column(nullable: false), - ColorG = table.Column(nullable: false), - ColorB = table.Column(nullable: false), - ColorA = table.Column(nullable: false), - Visible = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Markers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Peds", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - HashModel = table.Column(nullable: true), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Heading = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Peds", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Pickups", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - PositionX = table.Column(maxLength: 128, nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - RotationX = table.Column(nullable: false), - RotationY = table.Column(nullable: false), - RotationZ = table.Column(nullable: false), - Vehicle = table.Column(nullable: false), - RespawnTime = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Pickups", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TextLabels", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Text = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - LOS = table.Column(nullable: false), - Font = table.Column(nullable: false), - DrawDistance = table.Column(nullable: false), - ColorR = table.Column(nullable: false), - ColorG = table.Column(nullable: false), - ColorB = table.Column(nullable: false), - ColorA = table.Column(nullable: false), - Dimension = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TextLabels", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "WhitelistEntries", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - SocialClubName = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_WhitelistEntries", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Doors", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Category = table.Column(nullable: true), - Name = table.Column(nullable: true), - Locked = table.Column(nullable: false), - Model = table.Column(nullable: false), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Radius = table.Column(nullable: false), - FactionId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Doors", x => x.Id); - table.ForeignKey( - name: "FK_Doors_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "DutyClothes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: false), - Gender = table.Column(nullable: false), - SlotType = table.Column(nullable: false), - SlotId = table.Column(nullable: false), - ClothId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DutyClothes", x => x.Id); - table.ForeignKey( - name: "FK_DutyClothes_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FactionBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: false), - Bic = table.Column(maxLength: 12, nullable: true), - Iban = table.Column(maxLength: 32, nullable: true), - Balance = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_FactionBankAccounts_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "FactionRanks", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RankName = table.Column(nullable: true), - Order = table.Column(nullable: false), - FactionId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionRanks", x => x.Id); - table.ForeignKey( - name: "FK_FactionRanks_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(maxLength: 32, nullable: true), - SocialClubName = table.Column(maxLength: 32, nullable: true), - Password = table.Column(maxLength: 64, nullable: true), - LogUserId = table.Column(nullable: false), - RegistrationDate = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Email = table.Column(maxLength: 64, nullable: true), - AdminLevel = table.Column(nullable: false), - Dead = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - CharacterId = table.Column(nullable: true), - BanId = table.Column(nullable: true), - FactionId = table.Column(nullable: true), - FactionLeader = table.Column(nullable: false), - FactionRankId = table.Column(nullable: true), - BusinessId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - table.ForeignKey( - name: "FK_Users_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Users_FactionRanks_FactionRankId", - column: x => x.FactionRankId, - principalTable: "FactionRanks", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Bans", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Reason = table.Column(nullable: true), - BannedBy = table.Column(nullable: true), - Applied = table.Column(nullable: false), - UntilDateTime = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Bans", x => x.Id); - table.ForeignKey( - name: "FK_Bans_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "CharacterClothes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Duty = table.Column(nullable: false), - SlotType = table.Column(nullable: false), - SlotId = table.Column(nullable: false), - ClothId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CharacterClothes", x => x.Id); - table.ForeignKey( - name: "FK_CharacterClothes_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Characters", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Gender = table.Column(nullable: false), - Father = table.Column(nullable: false), - Mother = table.Column(nullable: false), - Similarity = table.Column(nullable: false), - SkinSimilarity = table.Column(nullable: false), - NoseWidth = table.Column(nullable: false), - NoseBottomHeight = table.Column(nullable: false), - NoseTipLength = table.Column(nullable: false), - NoseBridgeDepth = table.Column(nullable: false), - NoseTipHeight = table.Column(nullable: false), - NoseBroken = table.Column(nullable: false), - BrowHeight = table.Column(nullable: false), - BrowDepth = table.Column(nullable: false), - CheekboneHeight = table.Column(nullable: false), - CheekboneWidth = table.Column(nullable: false), - CheekDepth = table.Column(nullable: false), - EyeSize = table.Column(nullable: false), - LipThickness = table.Column(nullable: false), - JawWidth = table.Column(nullable: false), - JawShape = table.Column(nullable: false), - ChinHeight = table.Column(nullable: false), - ChinDepth = table.Column(nullable: false), - ChinWidth = table.Column(nullable: false), - ChinIndent = table.Column(nullable: false), - NeckWidth = table.Column(nullable: false), - Blemishes = table.Column(nullable: false), - BlemishesOpacity = table.Column(nullable: false), - FacialHair = table.Column(nullable: false), - FacialHairOpacity = table.Column(nullable: false), - Eyebrows = table.Column(nullable: false), - EyebrowsOpacity = table.Column(nullable: false), - Ageing = table.Column(nullable: false), - AgeingOpacity = table.Column(nullable: false), - Makeup = table.Column(nullable: false), - MakeupOpacity = table.Column(nullable: false), - Blush = table.Column(nullable: false), - BlushOpacity = table.Column(nullable: false), - Complexion = table.Column(nullable: false), - ComplexionOpacity = table.Column(nullable: false), - SunDamage = table.Column(nullable: false), - SunDamageOpacity = table.Column(nullable: false), - Lipstick = table.Column(nullable: false), - LipstickOpacity = table.Column(nullable: false), - Freckles = table.Column(nullable: false), - FrecklesOpacity = table.Column(nullable: false), - ChestHair = table.Column(nullable: false), - ChestHairOpacity = table.Column(nullable: false), - Hair = table.Column(nullable: false), - HairColor = table.Column(nullable: false), - HairHighlightColor = table.Column(nullable: false), - EyebrowColor = table.Column(nullable: false), - BeardColor = table.Column(nullable: false), - EyeColor = table.Column(nullable: false), - BlushColor = table.Column(nullable: false), - LipstickColor = table.Column(nullable: false), - ChestHairColor = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Characters", x => x.Id); - table.ForeignKey( - name: "FK_Characters_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "DeathLogs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - VictimId = table.Column(nullable: false), - KillerId = table.Column(nullable: true), - VictimPositionX = table.Column(nullable: false), - VictimPositionY = table.Column(nullable: false), - VictimPositionZ = table.Column(nullable: false), - VictimHeading = table.Column(nullable: false), - KillerPositionX = table.Column(nullable: false), - KillerPositionY = table.Column(nullable: false), - KillerPositionZ = table.Column(nullable: false), - KillerHeading = table.Column(nullable: false), - CauseOfDeath = table.Column(maxLength: 64, nullable: true), - Timestamp = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) - }, - constraints: table => - { - table.PrimaryKey("PK_DeathLogs", x => x.Id); - table.ForeignKey( - name: "FK_DeathLogs_Users_KillerId", - column: x => x.KillerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_DeathLogs_Users_VictimId", - column: x => x.VictimId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "News", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: true), - Caption = table.Column(nullable: true), - Content = table.Column(nullable: true), - Active = table.Column(nullable: false), - Timestamp = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_News", x => x.Id); - table.ForeignKey( - name: "FK_News_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "ServerVehicles", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Model = table.Column(nullable: false), - PositionX = table.Column(nullable: false), - PositionY = table.Column(nullable: false), - PositionZ = table.Column(nullable: false), - Heading = table.Column(nullable: false), - NumberPlate = table.Column(maxLength: 8, nullable: true), - PrimaryColor = table.Column(nullable: false), - SecondaryColor = table.Column(nullable: false), - Locked = table.Column(nullable: false), - Active = table.Column(nullable: false, defaultValue: true), - Discriminator = table.Column(nullable: false), - FactionId = table.Column(nullable: true), - ShopId = table.Column(nullable: true), - BusinessId = table.Column(nullable: true), - Price = table.Column(nullable: true), - UserId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerVehicles", x => x.Id); - table.ForeignKey( - name: "FK_ServerVehicles_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_ServerVehicles_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(nullable: false), - Bic = table.Column(maxLength: 12, nullable: true), - Iban = table.Column(maxLength: 32, nullable: true), - Balance = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_UserBankAccounts_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UserItems", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ItemId = table.Column(nullable: false), - UserId = table.Column(nullable: false), - Amount = table.Column(nullable: false), - Slot = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_UserItems", x => x.Id); - table.ForeignKey( - name: "FK_UserItems_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "VehicleMods", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ServerVehicleId = table.Column(nullable: false), - Slot = table.Column(nullable: false), - ModId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VehicleMods", x => x.Id); - table.ForeignKey( - name: "FK_VehicleMods_ServerVehicles_ServerVehicleId", - column: x => x.ServerVehicleId, - principalTable: "ServerVehicles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Bans_UserId", - table: "Bans", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_BusinessBankAccounts_BusinessId", - table: "BusinessBankAccounts", - column: "BusinessId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_CharacterClothes_UserId", - table: "CharacterClothes", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Characters_UserId", - table: "Characters", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_DeathLogs_KillerId", - table: "DeathLogs", - column: "KillerId"); - - migrationBuilder.CreateIndex( - name: "IX_DeathLogs_VictimId", - table: "DeathLogs", - column: "VictimId"); - - migrationBuilder.CreateIndex( - name: "IX_Doors_FactionId", - table: "Doors", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_DutyClothes_FactionId", - table: "DutyClothes", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_FactionBankAccounts_FactionId", - table: "FactionBankAccounts", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_FactionRanks_FactionId", - table: "FactionRanks", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_News_UserId", - table: "News", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_FactionId", - table: "ServerVehicles", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_UserId", - table: "ServerVehicles", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_UserBankAccounts_UserId", - table: "UserBankAccounts", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_UserItems_UserId", - table: "UserItems", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_BanId", - table: "Users", - column: "BanId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_BusinessId", - table: "Users", - column: "BusinessId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Users_CharacterId", - table: "Users", - column: "CharacterId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_FactionId", - table: "Users", - column: "FactionId"); - - migrationBuilder.CreateIndex( - name: "IX_Users_FactionRankId", - table: "Users", - column: "FactionRankId"); - - migrationBuilder.CreateIndex( - name: "IX_VehicleMods_ServerVehicleId_Slot", - table: "VehicleMods", - columns: new[] { "ServerVehicleId", "Slot" }, - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Bans_BanId", - table: "Users", - column: "BanId", - principalTable: "Bans", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Characters_CharacterId", - table: "Users", - column: "CharacterId", - principalTable: "Characters", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Bans_Users_UserId", - table: "Bans"); - - migrationBuilder.DropForeignKey( - name: "FK_Characters_Users_UserId", - table: "Characters"); - - migrationBuilder.DropTable( - name: "BankAccountTransactionLogs"); - - migrationBuilder.DropTable( - name: "Blips"); - - migrationBuilder.DropTable( - name: "BusinessBankAccounts"); - - migrationBuilder.DropTable( - name: "CharacterClothes"); - - migrationBuilder.DropTable( - name: "ClothCombinations"); - - migrationBuilder.DropTable( - name: "DeathLogs"); - - migrationBuilder.DropTable( - name: "Doors"); - - migrationBuilder.DropTable( - name: "DutyClothes"); - - migrationBuilder.DropTable( - name: "FactionBankAccounts"); - - migrationBuilder.DropTable( - name: "GotoPoints"); - - migrationBuilder.DropTable( - name: "Interiors"); - - migrationBuilder.DropTable( - name: "Markers"); - - migrationBuilder.DropTable( - name: "News"); - - migrationBuilder.DropTable( - name: "Peds"); - - migrationBuilder.DropTable( - name: "Pickups"); - - migrationBuilder.DropTable( - name: "TextLabels"); - - migrationBuilder.DropTable( - name: "UserBankAccounts"); - - migrationBuilder.DropTable( - name: "UserItems"); - - migrationBuilder.DropTable( - name: "VehicleMods"); - - migrationBuilder.DropTable( - name: "WhitelistEntries"); - - migrationBuilder.DropTable( - name: "ServerVehicles"); - - migrationBuilder.DropTable( - name: "Users"); - - migrationBuilder.DropTable( - name: "Bans"); - - migrationBuilder.DropTable( - name: "Characters"); - - migrationBuilder.DropTable( - name: "FactionRanks"); - - migrationBuilder.DropTable( - name: "Factions"); - } + migrationBuilder.CreateTable( + name: "BankAccountTransactionLogs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Sender = table.Column(maxLength: 32, nullable: true), + SenderBalance = table.Column(nullable: false), + MoneySent = table.Column(nullable: false), + Receiver = table.Column(maxLength: 32, nullable: true), + ReceiverBalance = table.Column(nullable: false), + NewSenderBalance = table.Column(nullable: false), + NewReceiverBalance = table.Column(nullable: false), + Fee = table.Column(nullable: false), + Origin = table.Column(maxLength: 32, nullable: true), + Timestamp = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) + }, + constraints: table => + { + table.PrimaryKey("PK_BankAccountTransactionLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Blips", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Sprite = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Name = table.Column(nullable: true), + Scale = table.Column(nullable: false), + Color = table.Column(nullable: false), + Alpha = table.Column(nullable: false), + DrawDistance = table.Column(nullable: false), + ShortRange = table.Column(nullable: false), + Rotation = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Blips", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BusinessBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + BusinessId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ClothCombinations", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Gender = table.Column(nullable: false), + Top = table.Column(nullable: false), + Torso = table.Column(nullable: false), + Undershirt = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ClothCombinations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Factions", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(maxLength: 32, nullable: true), + StateOwned = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Factions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GotoPoints", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(maxLength: 32, nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GotoPoints", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Interiors", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true), + EnterPosition = table.Column(nullable: true), + ExitPosition = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Interiors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Markers", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Type = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Scale = table.Column(nullable: false), + DirectionX = table.Column(nullable: false), + DirectionY = table.Column(nullable: false), + DirectionZ = table.Column(nullable: false), + RotationX = table.Column(nullable: false), + RotationY = table.Column(nullable: false), + RotationZ = table.Column(nullable: false), + ColorR = table.Column(nullable: false), + ColorG = table.Column(nullable: false), + ColorB = table.Column(nullable: false), + ColorA = table.Column(nullable: false), + Visible = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Markers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Peds", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + HashModel = table.Column(nullable: true), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Heading = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Peds", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Pickups", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + PositionX = table.Column(maxLength: 128, nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + RotationX = table.Column(nullable: false), + RotationY = table.Column(nullable: false), + RotationZ = table.Column(nullable: false), + Vehicle = table.Column(nullable: false), + RespawnTime = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Pickups", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TextLabels", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Text = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + LOS = table.Column(nullable: false), + Font = table.Column(nullable: false), + DrawDistance = table.Column(nullable: false), + ColorR = table.Column(nullable: false), + ColorG = table.Column(nullable: false), + ColorB = table.Column(nullable: false), + ColorA = table.Column(nullable: false), + Dimension = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TextLabels", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WhitelistEntries", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + SocialClubName = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WhitelistEntries", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Doors", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Category = table.Column(nullable: true), + Name = table.Column(nullable: true), + Locked = table.Column(nullable: false), + Model = table.Column(nullable: false), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Radius = table.Column(nullable: false), + FactionId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Doors", x => x.Id); + table.ForeignKey( + name: "FK_Doors_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "DutyClothes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: false), + Gender = table.Column(nullable: false), + SlotType = table.Column(nullable: false), + SlotId = table.Column(nullable: false), + ClothId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DutyClothes", x => x.Id); + table.ForeignKey( + name: "FK_DutyClothes_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FactionBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: false), + Bic = table.Column(maxLength: 12, nullable: true), + Iban = table.Column(maxLength: 32, nullable: true), + Balance = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_FactionBankAccounts_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FactionRanks", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + RankName = table.Column(nullable: true), + Order = table.Column(nullable: false), + FactionId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionRanks", x => x.Id); + table.ForeignKey( + name: "FK_FactionRanks_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(maxLength: 32, nullable: true), + SocialClubName = table.Column(maxLength: 32, nullable: true), + Password = table.Column(maxLength: 64, nullable: true), + LogUserId = table.Column(nullable: false), + RegistrationDate = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Email = table.Column(maxLength: 64, nullable: true), + AdminLevel = table.Column(nullable: false), + Dead = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + CharacterId = table.Column(nullable: true), + BanId = table.Column(nullable: true), + FactionId = table.Column(nullable: true), + FactionLeader = table.Column(nullable: false), + FactionRankId = table.Column(nullable: true), + BusinessId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + table.ForeignKey( + name: "FK_Users_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Users_FactionRanks_FactionRankId", + column: x => x.FactionRankId, + principalTable: "FactionRanks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Bans", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Reason = table.Column(nullable: true), + BannedBy = table.Column(nullable: true), + Applied = table.Column(nullable: false), + UntilDateTime = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Bans", x => x.Id); + table.ForeignKey( + name: "FK_Bans_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CharacterClothes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Duty = table.Column(nullable: false), + SlotType = table.Column(nullable: false), + SlotId = table.Column(nullable: false), + ClothId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CharacterClothes", x => x.Id); + table.ForeignKey( + name: "FK_CharacterClothes_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Characters", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Gender = table.Column(nullable: false), + Father = table.Column(nullable: false), + Mother = table.Column(nullable: false), + Similarity = table.Column(nullable: false), + SkinSimilarity = table.Column(nullable: false), + NoseWidth = table.Column(nullable: false), + NoseBottomHeight = table.Column(nullable: false), + NoseTipLength = table.Column(nullable: false), + NoseBridgeDepth = table.Column(nullable: false), + NoseTipHeight = table.Column(nullable: false), + NoseBroken = table.Column(nullable: false), + BrowHeight = table.Column(nullable: false), + BrowDepth = table.Column(nullable: false), + CheekboneHeight = table.Column(nullable: false), + CheekboneWidth = table.Column(nullable: false), + CheekDepth = table.Column(nullable: false), + EyeSize = table.Column(nullable: false), + LipThickness = table.Column(nullable: false), + JawWidth = table.Column(nullable: false), + JawShape = table.Column(nullable: false), + ChinHeight = table.Column(nullable: false), + ChinDepth = table.Column(nullable: false), + ChinWidth = table.Column(nullable: false), + ChinIndent = table.Column(nullable: false), + NeckWidth = table.Column(nullable: false), + Blemishes = table.Column(nullable: false), + BlemishesOpacity = table.Column(nullable: false), + FacialHair = table.Column(nullable: false), + FacialHairOpacity = table.Column(nullable: false), + Eyebrows = table.Column(nullable: false), + EyebrowsOpacity = table.Column(nullable: false), + Ageing = table.Column(nullable: false), + AgeingOpacity = table.Column(nullable: false), + Makeup = table.Column(nullable: false), + MakeupOpacity = table.Column(nullable: false), + Blush = table.Column(nullable: false), + BlushOpacity = table.Column(nullable: false), + Complexion = table.Column(nullable: false), + ComplexionOpacity = table.Column(nullable: false), + SunDamage = table.Column(nullable: false), + SunDamageOpacity = table.Column(nullable: false), + Lipstick = table.Column(nullable: false), + LipstickOpacity = table.Column(nullable: false), + Freckles = table.Column(nullable: false), + FrecklesOpacity = table.Column(nullable: false), + ChestHair = table.Column(nullable: false), + ChestHairOpacity = table.Column(nullable: false), + Hair = table.Column(nullable: false), + HairColor = table.Column(nullable: false), + HairHighlightColor = table.Column(nullable: false), + EyebrowColor = table.Column(nullable: false), + BeardColor = table.Column(nullable: false), + EyeColor = table.Column(nullable: false), + BlushColor = table.Column(nullable: false), + LipstickColor = table.Column(nullable: false), + ChestHairColor = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Characters", x => x.Id); + table.ForeignKey( + name: "FK_Characters_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "DeathLogs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + VictimId = table.Column(nullable: false), + KillerId = table.Column(nullable: true), + VictimPositionX = table.Column(nullable: false), + VictimPositionY = table.Column(nullable: false), + VictimPositionZ = table.Column(nullable: false), + VictimHeading = table.Column(nullable: false), + KillerPositionX = table.Column(nullable: false), + KillerPositionY = table.Column(nullable: false), + KillerPositionZ = table.Column(nullable: false), + KillerHeading = table.Column(nullable: false), + CauseOfDeath = table.Column(maxLength: 64, nullable: true), + Timestamp = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) + }, + constraints: table => + { + table.PrimaryKey("PK_DeathLogs", x => x.Id); + table.ForeignKey( + name: "FK_DeathLogs_Users_KillerId", + column: x => x.KillerId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_DeathLogs_Users_VictimId", + column: x => x.VictimId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "News", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: true), + Caption = table.Column(nullable: true), + Content = table.Column(nullable: true), + Active = table.Column(nullable: false), + Timestamp = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_News", x => x.Id); + table.ForeignKey( + name: "FK_News_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "ServerVehicles", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Model = table.Column(nullable: false), + PositionX = table.Column(nullable: false), + PositionY = table.Column(nullable: false), + PositionZ = table.Column(nullable: false), + Heading = table.Column(nullable: false), + NumberPlate = table.Column(maxLength: 8, nullable: true), + PrimaryColor = table.Column(nullable: false), + SecondaryColor = table.Column(nullable: false), + Locked = table.Column(nullable: false), + Active = table.Column(nullable: false, defaultValue: true), + Discriminator = table.Column(nullable: false), + FactionId = table.Column(nullable: true), + ShopId = table.Column(nullable: true), + BusinessId = table.Column(nullable: true), + Price = table.Column(nullable: true), + UserId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ServerVehicles", x => x.Id); + table.ForeignKey( + name: "FK_ServerVehicles_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ServerVehicles_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + UserId = table.Column(nullable: false), + Bic = table.Column(maxLength: 12, nullable: true), + Iban = table.Column(maxLength: 32, nullable: true), + Balance = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_UserBankAccounts_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "UserItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ItemId = table.Column(nullable: false), + UserId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + Slot = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserItems", x => x.Id); + table.ForeignKey( + name: "FK_UserItems_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VehicleMods", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ServerVehicleId = table.Column(nullable: false), + Slot = table.Column(nullable: false), + ModId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VehicleMods", x => x.Id); + table.ForeignKey( + name: "FK_VehicleMods_ServerVehicles_ServerVehicleId", + column: x => x.ServerVehicleId, + principalTable: "ServerVehicles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Bans_UserId", + table: "Bans", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_BusinessBankAccounts_BusinessId", + table: "BusinessBankAccounts", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_CharacterClothes_UserId", + table: "CharacterClothes", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Characters_UserId", + table: "Characters", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_DeathLogs_KillerId", + table: "DeathLogs", + column: "KillerId"); + + migrationBuilder.CreateIndex( + name: "IX_DeathLogs_VictimId", + table: "DeathLogs", + column: "VictimId"); + + migrationBuilder.CreateIndex( + name: "IX_Doors_FactionId", + table: "Doors", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_DutyClothes_FactionId", + table: "DutyClothes", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_FactionBankAccounts_FactionId", + table: "FactionBankAccounts", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_FactionRanks_FactionId", + table: "FactionRanks", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_News_UserId", + table: "News", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_FactionId", + table: "ServerVehicles", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_UserId", + table: "ServerVehicles", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserBankAccounts_UserId", + table: "UserBankAccounts", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_UserItems_UserId", + table: "UserItems", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_BanId", + table: "Users", + column: "BanId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_BusinessId", + table: "Users", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Users_CharacterId", + table: "Users", + column: "CharacterId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_FactionId", + table: "Users", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_FactionRankId", + table: "Users", + column: "FactionRankId"); + + migrationBuilder.CreateIndex( + name: "IX_VehicleMods_ServerVehicleId_Slot", + table: "VehicleMods", + columns: new[] { "ServerVehicleId", "Slot" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Bans_BanId", + table: "Users", + column: "BanId", + principalTable: "Bans", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Characters_CharacterId", + table: "Users", + column: "CharacterId", + principalTable: "Characters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Bans_Users_UserId", + table: "Bans"); + + migrationBuilder.DropForeignKey( + name: "FK_Characters_Users_UserId", + table: "Characters"); + + migrationBuilder.DropTable( + name: "BankAccountTransactionLogs"); + + migrationBuilder.DropTable( + name: "Blips"); + + migrationBuilder.DropTable( + name: "BusinessBankAccounts"); + + migrationBuilder.DropTable( + name: "CharacterClothes"); + + migrationBuilder.DropTable( + name: "ClothCombinations"); + + migrationBuilder.DropTable( + name: "DeathLogs"); + + migrationBuilder.DropTable( + name: "Doors"); + + migrationBuilder.DropTable( + name: "DutyClothes"); + + migrationBuilder.DropTable( + name: "FactionBankAccounts"); + + migrationBuilder.DropTable( + name: "GotoPoints"); + + migrationBuilder.DropTable( + name: "Interiors"); + + migrationBuilder.DropTable( + name: "Markers"); + + migrationBuilder.DropTable( + name: "News"); + + migrationBuilder.DropTable( + name: "Peds"); + + migrationBuilder.DropTable( + name: "Pickups"); + + migrationBuilder.DropTable( + name: "TextLabels"); + + migrationBuilder.DropTable( + name: "UserBankAccounts"); + + migrationBuilder.DropTable( + name: "UserItems"); + + migrationBuilder.DropTable( + name: "VehicleMods"); + + migrationBuilder.DropTable( + name: "WhitelistEntries"); + + migrationBuilder.DropTable( + name: "ServerVehicles"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropTable( + name: "Bans"); + + migrationBuilder.DropTable( + name: "Characters"); + + migrationBuilder.DropTable( + name: "FactionRanks"); + + migrationBuilder.DropTable( + name: "Factions"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190306194826_VehicleDistanceDriven.cs b/ReallifeGamemode.Server/Migrations/20190306194826_VehicleDistanceDriven.cs index 5842ed79..56631e5f 100644 --- a/ReallifeGamemode.Server/Migrations/20190306194826_VehicleDistanceDriven.cs +++ b/ReallifeGamemode.Server/Migrations/20190306194826_VehicleDistanceDriven.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class VehicleDistanceDriven : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DistanceDriven", - table: "ServerVehicles", - nullable: false, - defaultValue: 0f); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DistanceDriven", - table: "ServerVehicles"); - } + migrationBuilder.AddColumn( + name: "DistanceDriven", + table: "ServerVehicles", + nullable: false, + defaultValue: 0f); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DistanceDriven", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190307163335_VehicleTank.cs b/ReallifeGamemode.Server/Migrations/20190307163335_VehicleTank.cs index 0efa656e..ef03d08b 100644 --- a/ReallifeGamemode.Server/Migrations/20190307163335_VehicleTank.cs +++ b/ReallifeGamemode.Server/Migrations/20190307163335_VehicleTank.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class VehicleTank : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "TankAmount", - table: "ServerVehicles", - nullable: false, - defaultValue: 0f); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "TankAmount", - table: "ServerVehicles"); - } + migrationBuilder.AddColumn( + name: "TankAmount", + table: "ServerVehicles", + nullable: false, + defaultValue: 0f); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "TankAmount", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190309184251_ATM.cs b/ReallifeGamemode.Server/Migrations/20190309184251_ATM.cs index f435c951..e2d35940 100644 --- a/ReallifeGamemode.Server/Migrations/20190309184251_ATM.cs +++ b/ReallifeGamemode.Server/Migrations/20190309184251_ATM.cs @@ -4,32 +4,32 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class ATM : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ATMs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Balance = table.Column(nullable: false), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - Faulty = table.Column(nullable: false), - Active = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ATMs", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ATMs"); - } + migrationBuilder.CreateTable( + name: "ATMs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + Faulty = table.Column(nullable: false), + Active = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ATMs", x => x.Id); + }); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ATMs"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190408143319_Handmoney.cs b/ReallifeGamemode.Server/Migrations/20190408143319_Handmoney.cs index f9667ffc..753b627d 100644 --- a/ReallifeGamemode.Server/Migrations/20190408143319_Handmoney.cs +++ b/ReallifeGamemode.Server/Migrations/20190408143319_Handmoney.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class Handmoney : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Handmoney", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Handmoney", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "Handmoney", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Handmoney", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190411180607_TuningGarage.cs b/ReallifeGamemode.Server/Migrations/20190411180607_TuningGarage.cs index defe5236..d561d60b 100644 --- a/ReallifeGamemode.Server/Migrations/20190411180607_TuningGarage.cs +++ b/ReallifeGamemode.Server/Migrations/20190411180607_TuningGarage.cs @@ -4,29 +4,29 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class TuningGarage : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "TuningGarages", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TuningGarages", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TuningGarages"); - } + migrationBuilder.CreateTable( + name: "TuningGarages", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TuningGarages", x => x.Id); + }); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TuningGarages"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs b/ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs index b8795d1f..96ab7199 100644 --- a/ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs +++ b/ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs @@ -4,125 +4,125 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class Groups : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "GroupId", - table: "Users", - nullable: true); + migrationBuilder.AddColumn( + name: "GroupId", + table: "Users", + nullable: true); - migrationBuilder.AddColumn( - name: "GroupRank", - table: "Users", - nullable: false, - defaultValue: 0); + migrationBuilder.AddColumn( + name: "GroupRank", + table: "Users", + nullable: false, + defaultValue: 0); - migrationBuilder.AddColumn( - name: "GroupId", - table: "ServerVehicles", - nullable: true); + migrationBuilder.AddColumn( + name: "GroupId", + table: "ServerVehicles", + nullable: true); - migrationBuilder.CreateTable( - name: "Groups", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Groups", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + }); - migrationBuilder.CreateTable( - name: "GroupBankAccounts", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - GroupId = table.Column(nullable: true), - Balance = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); - table.ForeignKey( - name: "FK_GroupBankAccounts_Groups_GroupId", - column: x => x.GroupId, - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); + migrationBuilder.CreateTable( + name: "GroupBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + GroupId = table.Column(nullable: true), + Balance = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_GroupBankAccounts_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); - migrationBuilder.CreateIndex( - name: "IX_Users_GroupId", - table: "Users", - column: "GroupId"); + migrationBuilder.CreateIndex( + name: "IX_Users_GroupId", + table: "Users", + column: "GroupId"); - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_GroupId", - table: "ServerVehicles", - column: "GroupId"); + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_GroupId", + table: "ServerVehicles", + column: "GroupId"); - migrationBuilder.CreateIndex( - name: "IX_GroupBankAccounts_GroupId", - table: "GroupBankAccounts", - column: "GroupId"); + migrationBuilder.CreateIndex( + name: "IX_GroupBankAccounts_GroupId", + table: "GroupBankAccounts", + column: "GroupId"); - migrationBuilder.AddForeignKey( - name: "FK_ServerVehicles_Groups_GroupId", - table: "ServerVehicles", - column: "GroupId", - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_ServerVehicles_Groups_GroupId", + table: "ServerVehicles", + column: "GroupId", + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); - migrationBuilder.AddForeignKey( - name: "FK_Users_Groups_GroupId", - table: "Users", - column: "GroupId", - principalTable: "Groups", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ServerVehicles_Groups_GroupId", - table: "ServerVehicles"); - - migrationBuilder.DropForeignKey( - name: "FK_Users_Groups_GroupId", - table: "Users"); - - migrationBuilder.DropTable( - name: "GroupBankAccounts"); - - migrationBuilder.DropTable( - name: "Groups"); - - migrationBuilder.DropIndex( - name: "IX_Users_GroupId", - table: "Users"); - - migrationBuilder.DropIndex( - name: "IX_ServerVehicles_GroupId", - table: "ServerVehicles"); - - migrationBuilder.DropColumn( - name: "GroupId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "GroupRank", - table: "Users"); - - migrationBuilder.DropColumn( - name: "GroupId", - table: "ServerVehicles"); - } + migrationBuilder.AddForeignKey( + name: "FK_Users_Groups_GroupId", + table: "Users", + column: "GroupId", + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ServerVehicles_Groups_GroupId", + table: "ServerVehicles"); + + migrationBuilder.DropForeignKey( + name: "FK_Users_Groups_GroupId", + table: "Users"); + + migrationBuilder.DropTable( + name: "GroupBankAccounts"); + + migrationBuilder.DropTable( + name: "Groups"); + + migrationBuilder.DropIndex( + name: "IX_Users_GroupId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_ServerVehicles_GroupId", + table: "ServerVehicles"); + + migrationBuilder.DropColumn( + name: "GroupId", + table: "Users"); + + migrationBuilder.DropColumn( + name: "GroupRank", + table: "Users"); + + migrationBuilder.DropColumn( + name: "GroupId", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190513111017_UnusedColumnRemove.cs b/ReallifeGamemode.Server/Migrations/20190513111017_UnusedColumnRemove.cs index eddaa239..65486ab9 100644 --- a/ReallifeGamemode.Server/Migrations/20190513111017_UnusedColumnRemove.cs +++ b/ReallifeGamemode.Server/Migrations/20190513111017_UnusedColumnRemove.cs @@ -3,20 +3,20 @@ namespace ReallifeGamemode.Database.Migrations { public partial class UnusedColumnRemove : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ShopId", - table: "ServerVehicles"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ShopId", - table: "ServerVehicles", - nullable: true); - } + migrationBuilder.DropColumn( + name: "ShopId", + table: "ServerVehicles"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ShopId", + table: "ServerVehicles", + nullable: true); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs b/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs index be0e548d..5bd8c21a 100644 --- a/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs +++ b/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs @@ -4,87 +4,87 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class Jobs : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "JobId", - table: "Users", - nullable: true); + migrationBuilder.AddColumn( + name: "JobId", + table: "Users", + nullable: true); - migrationBuilder.AddColumn( - name: "JobId", - table: "ServerVehicles", - nullable: true); + migrationBuilder.AddColumn( + name: "JobId", + table: "ServerVehicles", + nullable: true); - migrationBuilder.CreateTable( - name: "Jobs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Jobs", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "Jobs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Jobs", x => x.Id); + }); - migrationBuilder.CreateIndex( - name: "IX_Users_JobId", - table: "Users", - column: "JobId"); + migrationBuilder.CreateIndex( + name: "IX_Users_JobId", + table: "Users", + column: "JobId"); - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_JobId", - table: "ServerVehicles", - column: "JobId"); + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles", + column: "JobId"); - migrationBuilder.AddForeignKey( - name: "FK_ServerVehicles_Jobs_JobId", - table: "ServerVehicles", - column: "JobId", - principalTable: "Jobs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + migrationBuilder.AddForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); - migrationBuilder.AddForeignKey( - name: "FK_Users_Jobs_JobId", - table: "Users", - column: "JobId", - principalTable: "Jobs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ServerVehicles_Jobs_JobId", - table: "ServerVehicles"); - - migrationBuilder.DropForeignKey( - name: "FK_Users_Jobs_JobId", - table: "Users"); - - migrationBuilder.DropTable( - name: "Jobs"); - - migrationBuilder.DropIndex( - name: "IX_Users_JobId", - table: "Users"); - - migrationBuilder.DropIndex( - name: "IX_ServerVehicles_JobId", - table: "ServerVehicles"); - - migrationBuilder.DropColumn( - name: "JobId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "JobId", - table: "ServerVehicles"); - } + migrationBuilder.AddForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles"); + + migrationBuilder.DropForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users"); + + migrationBuilder.DropTable( + name: "Jobs"); + + migrationBuilder.DropIndex( + name: "IX_Users_JobId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles"); + + migrationBuilder.DropColumn( + name: "JobId", + table: "Users"); + + migrationBuilder.DropColumn( + name: "JobId", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs index 4197f8b2..f8507827 100644 --- a/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs +++ b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs @@ -4,69 +4,69 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class JobFix : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ServerVehicles_Jobs_JobId", - table: "ServerVehicles"); + migrationBuilder.DropForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles"); - migrationBuilder.DropForeignKey( - name: "FK_Users_Jobs_JobId", - table: "Users"); + migrationBuilder.DropForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users"); - migrationBuilder.DropTable( - name: "Jobs"); + migrationBuilder.DropTable( + name: "Jobs"); - migrationBuilder.DropIndex( - name: "IX_Users_JobId", - table: "Users"); + migrationBuilder.DropIndex( + name: "IX_Users_JobId", + table: "Users"); - migrationBuilder.DropIndex( - name: "IX_ServerVehicles_JobId", - table: "ServerVehicles"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Jobs", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Jobs", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_Users_JobId", - table: "Users", - column: "JobId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVehicles_JobId", - table: "ServerVehicles", - column: "JobId"); - - migrationBuilder.AddForeignKey( - name: "FK_ServerVehicles_Jobs_JobId", - table: "ServerVehicles", - column: "JobId", - principalTable: "Jobs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Jobs_JobId", - table: "Users", - column: "JobId", - principalTable: "Jobs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } + migrationBuilder.DropIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Jobs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Jobs", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Users_JobId", + table: "Users", + column: "JobId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles", + column: "JobId"); + + migrationBuilder.AddForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190624153156_ClothesTexture.cs b/ReallifeGamemode.Server/Migrations/20190624153156_ClothesTexture.cs index aff11e69..3dcaff40 100644 --- a/ReallifeGamemode.Server/Migrations/20190624153156_ClothesTexture.cs +++ b/ReallifeGamemode.Server/Migrations/20190624153156_ClothesTexture.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class ClothesTexture : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Texture", - table: "CharacterClothes", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Texture", - table: "CharacterClothes"); - } + migrationBuilder.AddColumn( + name: "Texture", + table: "CharacterClothes", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Texture", + table: "CharacterClothes"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190625202943_ClientWanteds.cs b/ReallifeGamemode.Server/Migrations/20190625202943_ClientWanteds.cs index 8f7d872c..41c8a46e 100644 --- a/ReallifeGamemode.Server/Migrations/20190625202943_ClientWanteds.cs +++ b/ReallifeGamemode.Server/Migrations/20190625202943_ClientWanteds.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class PlayerWanteds : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Wanteds", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Wanteds", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "Wanteds", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Wanteds", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190626193631_House.cs b/ReallifeGamemode.Server/Migrations/20190626193631_House.cs index 13989a4a..e65acfb1 100644 --- a/ReallifeGamemode.Server/Migrations/20190626193631_House.cs +++ b/ReallifeGamemode.Server/Migrations/20190626193631_House.cs @@ -4,50 +4,50 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class House : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "HouseId", - table: "Users", - nullable: true); + migrationBuilder.AddColumn( + name: "HouseId", + table: "Users", + nullable: true); - migrationBuilder.CreateTable( - name: "Houses", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(nullable: true), - Price = table.Column(nullable: false), - UserId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Houses", x => x.Id); - table.ForeignKey( - name: "FK_Houses_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); + migrationBuilder.CreateTable( + name: "Houses", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Type = table.Column(nullable: true), + Price = table.Column(nullable: false), + UserId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Houses", x => x.Id); + table.ForeignKey( + name: "FK_Houses_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); - migrationBuilder.CreateIndex( - name: "IX_Houses_UserId", - table: "Houses", - column: "UserId", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Houses"); - - migrationBuilder.DropColumn( - name: "HouseId", - table: "Users"); - } + migrationBuilder.CreateIndex( + name: "IX_Houses_UserId", + table: "Houses", + column: "UserId", + unique: true); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Houses"); + + migrationBuilder.DropColumn( + name: "HouseId", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190626202159_HousePosition.cs b/ReallifeGamemode.Server/Migrations/20190626202159_HousePosition.cs index 39c6799c..9a820adc 100644 --- a/ReallifeGamemode.Server/Migrations/20190626202159_HousePosition.cs +++ b/ReallifeGamemode.Server/Migrations/20190626202159_HousePosition.cs @@ -3,41 +3,41 @@ namespace ReallifeGamemode.Database.Migrations { public partial class HousePosition : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "X", - table: "Houses", - nullable: false, - defaultValue: 0f); + migrationBuilder.AddColumn( + name: "X", + table: "Houses", + nullable: false, + defaultValue: 0f); - migrationBuilder.AddColumn( - name: "Y", - table: "Houses", - nullable: false, - defaultValue: 0f); + migrationBuilder.AddColumn( + name: "Y", + table: "Houses", + nullable: false, + defaultValue: 0f); - migrationBuilder.AddColumn( - name: "Z", - table: "Houses", - nullable: false, - defaultValue: 0f); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "X", - table: "Houses"); - - migrationBuilder.DropColumn( - name: "Y", - table: "Houses"); - - migrationBuilder.DropColumn( - name: "Z", - table: "Houses"); - } + migrationBuilder.AddColumn( + name: "Z", + table: "Houses", + nullable: false, + defaultValue: 0f); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "X", + table: "Houses"); + + migrationBuilder.DropColumn( + name: "Y", + table: "Houses"); + + migrationBuilder.DropColumn( + name: "Z", + table: "Houses"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190627162731_UserHouseReference.cs b/ReallifeGamemode.Server/Migrations/20190627162731_UserHouseReference.cs index 8446b65b..4c01230a 100644 --- a/ReallifeGamemode.Server/Migrations/20190627162731_UserHouseReference.cs +++ b/ReallifeGamemode.Server/Migrations/20190627162731_UserHouseReference.cs @@ -3,25 +3,25 @@ namespace ReallifeGamemode.Database.Migrations { public partial class UserHouseReference : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddForeignKey( - name: "FK_Users_Houses_HouseId", - table: "Users", - column: "HouseId", - principalTable: "Houses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateIndex( - name: "IX_Houses_UserId", - table: "Houses", - column: "UserId", - unique: true); - } + migrationBuilder.AddForeignKey( + name: "FK_Users_Houses_HouseId", + table: "Users", + column: "HouseId", + principalTable: "Houses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Houses_UserId", + table: "Houses", + column: "UserId", + unique: true); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190706132925_UserWage.cs b/ReallifeGamemode.Server/Migrations/20190706132925_UserWage.cs index 11a3a362..a0b5b1c2 100644 --- a/ReallifeGamemode.Server/Migrations/20190706132925_UserWage.cs +++ b/ReallifeGamemode.Server/Migrations/20190706132925_UserWage.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class UserWage : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Wage", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Wage", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "Wage", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Wage", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190707184050_BusRoutes.cs b/ReallifeGamemode.Server/Migrations/20190707184050_BusRoutes.cs index 018c6d2d..b529a027 100644 --- a/ReallifeGamemode.Server/Migrations/20190707184050_BusRoutes.cs +++ b/ReallifeGamemode.Server/Migrations/20190707184050_BusRoutes.cs @@ -4,58 +4,58 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class BusRoutes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "BusRoutes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BusRoutes", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "BusRoutes", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BusRoutes", x => x.Id); + }); - migrationBuilder.CreateTable( - name: "BusRoutesPoints", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(nullable: true), - X = table.Column(nullable: false), - Y = table.Column(nullable: false), - Z = table.Column(nullable: false), - BusRouteId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BusRoutesPoints", x => x.Id); - table.ForeignKey( - name: "FK_BusRoutesPoints_BusRoutes_BusRouteId", - column: x => x.BusRouteId, - principalTable: "BusRoutes", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); + migrationBuilder.CreateTable( + name: "BusRoutesPoints", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(nullable: true), + X = table.Column(nullable: false), + Y = table.Column(nullable: false), + Z = table.Column(nullable: false), + BusRouteId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BusRoutesPoints", x => x.Id); + table.ForeignKey( + name: "FK_BusRoutesPoints_BusRoutes_BusRouteId", + column: x => x.BusRouteId, + principalTable: "BusRoutes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); - migrationBuilder.CreateIndex( - name: "IX_BusRoutesPoints_BusRouteId", - table: "BusRoutesPoints", - column: "BusRouteId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "BusRoutesPoints"); - - migrationBuilder.DropTable( - name: "BusRoutes"); - } + migrationBuilder.CreateIndex( + name: "IX_BusRoutesPoints_BusRouteId", + table: "BusRoutesPoints", + column: "BusRouteId"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "BusRoutesPoints"); + + migrationBuilder.DropTable( + name: "BusRoutes"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190708161922_UserHouseReferenceFix.cs b/ReallifeGamemode.Server/Migrations/20190708161922_UserHouseReferenceFix.cs index fed69a47..52252cfb 100644 --- a/ReallifeGamemode.Server/Migrations/20190708161922_UserHouseReferenceFix.cs +++ b/ReallifeGamemode.Server/Migrations/20190708161922_UserHouseReferenceFix.cs @@ -3,41 +3,41 @@ namespace ReallifeGamemode.Database.Migrations { public partial class UserHouseReferenceFix : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "OwnerId", - table: "Houses", - nullable: true); + migrationBuilder.AddColumn( + name: "OwnerId", + table: "Houses", + nullable: true); - migrationBuilder.CreateIndex( - name: "IX_Houses_OwnerId", - table: "Houses", - column: "OwnerId"); + migrationBuilder.CreateIndex( + name: "IX_Houses_OwnerId", + table: "Houses", + column: "OwnerId"); - migrationBuilder.AddForeignKey( - name: "FK_Houses_Users_OwnerId", - table: "Houses", - column: "OwnerId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Houses_Users_OwnerId", - table: "Houses"); - - migrationBuilder.DropIndex( - name: "IX_Houses_OwnerId", - table: "Houses"); - - migrationBuilder.DropColumn( - name: "OwnerId", - table: "Houses"); - } + migrationBuilder.AddForeignKey( + name: "FK_Houses_Users_OwnerId", + table: "Houses", + column: "OwnerId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Houses_Users_OwnerId", + table: "Houses"); + + migrationBuilder.DropIndex( + name: "IX_Houses_OwnerId", + table: "Houses"); + + migrationBuilder.DropColumn( + name: "OwnerId", + table: "Houses"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190715192123_JailTime.cs b/ReallifeGamemode.Server/Migrations/20190715192123_JailTime.cs index 129f19ce..3dd816f0 100644 --- a/ReallifeGamemode.Server/Migrations/20190715192123_JailTime.cs +++ b/ReallifeGamemode.Server/Migrations/20190715192123_JailTime.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class JailTime : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "JailTime", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "JailTime", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "JailTime", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "JailTime", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.cs b/ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.cs index 2769c249..9204a832 100644 --- a/ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.cs +++ b/ReallifeGamemode.Server/Migrations/20190719210722_PaydayTimer.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class PaydayTimer : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PaydayTimer", - table: "Users", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PaydayTimer", - table: "Users"); - } + migrationBuilder.AddColumn( + name: "PaydayTimer", + table: "Users", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PaydayTimer", + table: "Users"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190721144830_FactionWeapons.cs b/ReallifeGamemode.Server/Migrations/20190721144830_FactionWeapons.cs index 94ea6dad..38884914 100644 --- a/ReallifeGamemode.Server/Migrations/20190721144830_FactionWeapons.cs +++ b/ReallifeGamemode.Server/Migrations/20190721144830_FactionWeapons.cs @@ -4,41 +4,41 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class FactionWeapons : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "FactionWeapons", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FactionId = table.Column(nullable: false), - WeaponModel = table.Column(nullable: true), - SlotID = table.Column(nullable: false), - Rank = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FactionWeapons", x => x.Id); - table.ForeignKey( - name: "FK_FactionWeapons_Factions_FactionId", - column: x => x.FactionId, - principalTable: "Factions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "FactionWeapons", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + FactionId = table.Column(nullable: false), + WeaponModel = table.Column(nullable: true), + SlotID = table.Column(nullable: false), + Rank = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionWeapons", x => x.Id); + table.ForeignKey( + name: "FK_FactionWeapons_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_FactionWeapons_FactionId", - table: "FactionWeapons", - column: "FactionId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "FactionWeapons"); - } + migrationBuilder.CreateIndex( + name: "IX_FactionWeapons_FactionId", + table: "FactionWeapons", + column: "FactionId"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "FactionWeapons"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190722201850_VehicleLivery.cs b/ReallifeGamemode.Server/Migrations/20190722201850_VehicleLivery.cs index 904f1556..c5e781bb 100644 --- a/ReallifeGamemode.Server/Migrations/20190722201850_VehicleLivery.cs +++ b/ReallifeGamemode.Server/Migrations/20190722201850_VehicleLivery.cs @@ -3,21 +3,21 @@ namespace ReallifeGamemode.Database.Migrations { public partial class VehicleLivery : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Livery", - table: "ServerVehicles", - nullable: false, - defaultValue: 0); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Livery", - table: "ServerVehicles"); - } + migrationBuilder.AddColumn( + name: "Livery", + table: "ServerVehicles", + nullable: false, + defaultValue: 0); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Livery", + table: "ServerVehicles"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.cs b/ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.cs index e3003c88..4ec553bf 100644 --- a/ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.cs +++ b/ReallifeGamemode.Server/Migrations/20190728142431_HouseEnhancments.cs @@ -4,70 +4,70 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class HouseEnhancments : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CanRentIn", - table: "Houses", - nullable: false, - defaultValue: false); + migrationBuilder.AddColumn( + name: "CanRentIn", + table: "Houses", + nullable: false, + defaultValue: false); - migrationBuilder.AddColumn( - name: "RentalFee", - table: "Houses", - nullable: false, - defaultValue: 0); + migrationBuilder.AddColumn( + name: "RentalFee", + table: "Houses", + nullable: false, + defaultValue: 0); - migrationBuilder.CreateTable( - name: "HouseRentals", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - HouseId = table.Column(nullable: true), - UserId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_HouseRentals", x => x.Id); - table.ForeignKey( - name: "FK_HouseRentals_Houses_HouseId", - column: x => x.HouseId, - principalTable: "Houses", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_HouseRentals_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); + migrationBuilder.CreateTable( + name: "HouseRentals", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + HouseId = table.Column(nullable: true), + UserId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_HouseRentals", x => x.Id); + table.ForeignKey( + name: "FK_HouseRentals_Houses_HouseId", + column: x => x.HouseId, + principalTable: "Houses", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_HouseRentals_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); - migrationBuilder.CreateIndex( - name: "IX_HouseRentals_HouseId", - table: "HouseRentals", - column: "HouseId"); + migrationBuilder.CreateIndex( + name: "IX_HouseRentals_HouseId", + table: "HouseRentals", + column: "HouseId"); - migrationBuilder.CreateIndex( - name: "IX_HouseRentals_UserId", - table: "HouseRentals", - column: "UserId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "HouseRentals"); - - migrationBuilder.DropColumn( - name: "CanRentIn", - table: "Houses"); - - migrationBuilder.DropColumn( - name: "RentalFee", - table: "Houses"); - } + migrationBuilder.CreateIndex( + name: "IX_HouseRentals_UserId", + table: "HouseRentals", + column: "UserId"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "HouseRentals"); + + migrationBuilder.DropColumn( + name: "CanRentIn", + table: "Houses"); + + migrationBuilder.DropColumn( + name: "RentalFee", + table: "Houses"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190805184145_VehicleItems.cs b/ReallifeGamemode.Server/Migrations/20190805184145_VehicleItems.cs index 3e410929..f253bca3 100644 --- a/ReallifeGamemode.Server/Migrations/20190805184145_VehicleItems.cs +++ b/ReallifeGamemode.Server/Migrations/20190805184145_VehicleItems.cs @@ -4,41 +4,41 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class VehicleItems : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "VehicleItems", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ItemId = table.Column(nullable: false), - VehicleId = table.Column(nullable: false), - Amount = table.Column(nullable: false), - Slot = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VehicleItems", x => x.Id); - table.ForeignKey( - name: "FK_VehicleItems_ServerVehicles_VehicleId", - column: x => x.VehicleId, - principalTable: "ServerVehicles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "VehicleItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ItemId = table.Column(nullable: false), + VehicleId = table.Column(nullable: false), + Amount = table.Column(nullable: false), + Slot = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VehicleItems", x => x.Id); + table.ForeignKey( + name: "FK_VehicleItems_ServerVehicles_VehicleId", + column: x => x.VehicleId, + principalTable: "ServerVehicles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_VehicleItems_VehicleId", - table: "VehicleItems", - column: "VehicleId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "VehicleItems"); - } + migrationBuilder.CreateIndex( + name: "IX_VehicleItems_VehicleId", + table: "VehicleItems", + column: "VehicleId"); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "VehicleItems"); + } + } } diff --git a/ReallifeGamemode.Server/Migrations/20190911192912_BusinessData.cs b/ReallifeGamemode.Server/Migrations/20190911192912_BusinessData.cs index 88402a1a..528fa7c9 100644 --- a/ReallifeGamemode.Server/Migrations/20190911192912_BusinessData.cs +++ b/ReallifeGamemode.Server/Migrations/20190911192912_BusinessData.cs @@ -4,28 +4,28 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace ReallifeGamemode.Database.Migrations { public partial class BusinessData : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "BusinessData", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - BusinessId = table.Column(nullable: false), - Price = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BusinessData", x => x.Id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "BusinessData"); - } + migrationBuilder.CreateTable( + name: "BusinessData", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + BusinessId = table.Column(nullable: false), + Price = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BusinessData", x => x.Id); + }); } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "BusinessData"); + } + } } diff --git a/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs b/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs index 04e8103b..09b7ace0 100644 --- a/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs +++ b/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs @@ -10,35 +10,35 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Shop.Clothing { public class ClotheShop + { + public int category { get; set; } + public Vector3 vector { get; set; } + public List clotheList = new List(); + + public ClotheShop(int category, Vector3 vector) { - public int category { get; set; } - public Vector3 vector { get; set; } - public List clotheList = new List(); + this.category = category; + this.vector = vector; + LoadClothes(); + } - public ClotheShop(int category, Vector3 vector) - { - this.category = category; - this.vector = vector; - LoadClothes(); - } + public void LoadClothes() + { + using (var dbContext = new DatabaseContext()) + { + clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category); + } + } - public void LoadClothes() - { - using (var dbContext = new DatabaseContext()) - { - clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category); - } - } + public void LoadShopNUI(Player client) + { + bool gender = client.GetUser().GetCharacter().Gender; + List tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11); + List legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4); + List shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6); + List accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7); - public void LoadShopNUI(Player client) - { - bool gender = client.GetUser().GetCharacter().Gender; - List tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11); - List legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4); - List shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6); - List accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7); - - List clothes = new List + List clothes = new List { tops.ToArray(), legs.ToArray(), @@ -46,7 +46,7 @@ namespace ReallifeGamemode.Server.Shop.Clothing accessoires.ToArray() }; - client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender); - } + client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender); } + } } diff --git a/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs b/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs index 65d9535a..1357c925 100644 --- a/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs +++ b/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs @@ -10,34 +10,34 @@ using ReallifeGamemode.Server.Managers; namespace ReallifeGamemode.Server.Shop.SevenEleven { public class ItemShop + { + public Vector3 vector3; + public int id; + public List shopItems = new List(); + + public ItemShop(Vector3 vector3, int id) { - public Vector3 vector3; - public int id; - public List shopItems = new List(); - - public ItemShop(Vector3 vector3, int id) - { - this.vector3 = vector3; - this.id = id; - } - - public void LoadItems() - { - using (var dbContext = new DatabaseContext()) - { - shopItems = dbContext.ShopItems.ToList().FindAll(i => i.ShopId == id); - } - } - - public void LoadShopNUI(Player client) - { - List itemList = shopItems.ToList().FindAll(s => s.Amount > 0); - List items = new List(); - foreach (var item in itemList) - { - items.Add(InventoryManager.GetItemById(item.ItemId)); - } - client.TriggerEvent("itemMenu:updateData", JsonConvert.SerializeObject(items.ToArray())); - } + this.vector3 = vector3; + this.id = id; } + + public void LoadItems() + { + using (var dbContext = new DatabaseContext()) + { + shopItems = dbContext.ShopItems.ToList().FindAll(i => i.ShopId == id); + } + } + + public void LoadShopNUI(Player client) + { + List itemList = shopItems.ToList().FindAll(s => s.Amount > 0); + List items = new List(); + foreach (var item in itemList) + { + items.Add(InventoryManager.GetItemById(item.ItemId)); + } + client.TriggerEvent("itemMenu:updateData", JsonConvert.SerializeObject(items.ToArray())); + } + } } diff --git a/ReallifeGamemode.Server/Util/CheckPointHandle.cs b/ReallifeGamemode.Server/Util/CheckPointHandle.cs index 98d5f2ff..cdcbd5dd 100644 --- a/ReallifeGamemode.Server/Util/CheckPointHandle.cs +++ b/ReallifeGamemode.Server/Util/CheckPointHandle.cs @@ -5,104 +5,104 @@ using GTANetworkAPI; namespace ReallifeGamemode.Server.Util { public class CheckPointHandle : Script + { + public static List listHandle = new List(); + + public static void DeleteCheckpoints(Player player) { - public static List listHandle = new List(); - - public static void DeleteCheckpoints(Player player) - { - RemovePlayerHandlerFromList(player); - player.TriggerEvent("destroyCP"); - } - - public static void StartCheckPointRoute(Player player, IEnumerable nListCps, int delay, int markerID, int markerSize, string nEvent) - { - RemovePlayerHandlerFromList(player); - CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID, markerSize, nEvent); - playerHandle.DeleteCheckpoints(); - - listHandle.Add(playerHandle); - - playerHandle.StartRoute(); - } - - public static void RemovePlayerHandlerFromList(Player player) - { - CheckPointListForPlayer temp = null; - for (int a = 0; a < listHandle.Count; a++) - { - temp = listHandle[a]; - if (temp.player == player) - { - listHandle.Remove(temp); - } - } - } - - [RemoteEvent("playerInCheckpoint")] - public void PlayerInCheckpoint(Player user) - { - CheckPointListForPlayer temp = null; - for (int a = 0; a < listHandle.Count; a++) - { - temp = listHandle[a]; - if (temp.player == user) - { - break; - } - } - temp.NextCheckpoint(); - } + RemovePlayerHandlerFromList(player); + player.TriggerEvent("destroyCP"); } - public class CheckPointListForPlayer + public static void StartCheckPointRoute(Player player, IEnumerable nListCps, int delay, int markerID, int markerSize, string nEvent) { - public IEnumerable list = new List(); - public Player player; - public int delay = 0; - public int markerID; - public int markerSize; - public string eventInCheckpoint = ""; + RemovePlayerHandlerFromList(player); + CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps, delay, markerID, markerSize, nEvent); + playerHandle.DeleteCheckpoints(); + + listHandle.Add(playerHandle); + + playerHandle.StartRoute(); + } + + public static void RemovePlayerHandlerFromList(Player player) + { + CheckPointListForPlayer temp = null; + for (int a = 0; a < listHandle.Count; a++) + { + temp = listHandle[a]; + if (temp.player == player) + { + listHandle.Remove(temp); + } + } + } + + [RemoteEvent("playerInCheckpoint")] + public void PlayerInCheckpoint(Player user) + { + CheckPointListForPlayer temp = null; + for (int a = 0; a < listHandle.Count; a++) + { + temp = listHandle[a]; + if (temp.player == user) + { + break; + } + } + temp.NextCheckpoint(); + } + } + + public class CheckPointListForPlayer + { + public IEnumerable list = new List(); + public Player player; + public int delay = 0; + public int markerID; + public int markerSize; + public string eventInCheckpoint = ""; private int checkPointsDone = 0; public CheckPointListForPlayer(Player nPlayer, IEnumerable nList, int nDelay, int nMarkerID, int nMarkerSize, string nEvent) - { - this.player = nPlayer; - this.list = nList; - this.delay = nDelay; - this.markerID = nMarkerID; - this.markerSize = nMarkerSize; - this.eventInCheckpoint = nEvent; - this.checkPointsDone = 0; - } - - public void StartRoute() - { - player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.markerSize, this.eventInCheckpoint); - } - - public void NextCheckpoint() - { - this.checkPointsDone++; - if (this.list.Count() > checkPointsDone) - { - Vector3 nextCp = list.ElementAt(checkPointsDone); - this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint); - } - if (this.list.Count() == checkPointsDone) - { - CheckPointHandle.RemovePlayerHandlerFromList(this.player); - - if (this.eventInCheckpoint == "busDriverJob") - { - Job.BusDriverJob.payWage(this.player, 1000); - } - } - } - - public void DeleteCheckpoints() - { - this.player.TriggerEvent("destroyCP"); - } + { + this.player = nPlayer; + this.list = nList; + this.delay = nDelay; + this.markerID = nMarkerID; + this.markerSize = nMarkerSize; + this.eventInCheckpoint = nEvent; + this.checkPointsDone = 0; } + + public void StartRoute() + { + player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player, 0, this.delay, this.markerID, this.markerSize, this.eventInCheckpoint); + } + + public void NextCheckpoint() + { + this.checkPointsDone++; + if (this.list.Count() > checkPointsDone) + { + Vector3 nextCp = list.ElementAt(checkPointsDone); + this.player.TriggerEvent("setCheckPoint", nextCp, player, this.checkPointsDone, delay, this.markerID, this.markerSize, this.eventInCheckpoint); + } + if (this.list.Count() == checkPointsDone) + { + CheckPointHandle.RemovePlayerHandlerFromList(this.player); + + if (this.eventInCheckpoint == "busDriverJob") + { + Job.BusDriverJob.payWage(this.player, 1000); + } + } + } + + public void DeleteCheckpoints() + { + this.player.TriggerEvent("destroyCP"); + } + } } diff --git a/ReallifeGamemode.Server/Util/Converter.cs b/ReallifeGamemode.Server/Util/Converter.cs index 5eccaac1..709ad2e1 100644 --- a/ReallifeGamemode.Server/Util/Converter.cs +++ b/ReallifeGamemode.Server/Util/Converter.cs @@ -4,34 +4,34 @@ using GTANetworkAPI; namespace ReallifeGamemode.Server.Util { public class Converter + { + public static Color HexToColor(string hexColor) { - public static Color HexToColor(string hexColor) - { - //Remove # if present - if (hexColor.IndexOf('#') != -1) - hexColor = hexColor.Replace("#", ""); + //Remove # if present + if (hexColor.IndexOf('#') != -1) + hexColor = hexColor.Replace("#", ""); - int red = 0; - int green = 0; - int blue = 0; + int red = 0; + int green = 0; + int blue = 0; - if (hexColor.Length == 6) - { - //#RRGGBB - red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier); - green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier); - blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier); - } - else if (hexColor.Length == 3) - { - //#RGB - red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier); - green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier); - blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier); - } + if (hexColor.Length == 6) + { + //#RRGGBB + red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier); + green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier); + blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier); + } + else if (hexColor.Length == 3) + { + //#RGB + red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier); + green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier); + blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier); + } - Color returnColor = new Color(red, green, blue); - return returnColor; - } + Color returnColor = new Color(red, green, blue); + return returnColor; } + } } diff --git a/ReallifeGamemode.Server/Util/GlobalHelper.cs b/ReallifeGamemode.Server/Util/GlobalHelper.cs index 9dde7e76..65ff4169 100644 --- a/ReallifeGamemode.Server/Util/GlobalHelper.cs +++ b/ReallifeGamemode.Server/Util/GlobalHelper.cs @@ -4,16 +4,16 @@ using GTANetworkAPI; namespace ReallifeGamemode.Server.Util { public static class GlobalHelper - { - public static List DutyAdmins = new List(); - public static List tsupAdmins = new List(); + { + public static List DutyAdmins = new List(); + public static List tsupAdmins = new List(); - public static Dictionary CustomJoinMessages = new Dictionary + public static Dictionary CustomJoinMessages = new Dictionary { { ".MichaPlays.", "Der Echte Ballas Leader ist online (MichaPlays)" }, { "balboistderbeste", "Hurra! Hurra! Der Balbo ist jetzt da! (balbo)" }, { "Roachkook", "Niemand, nicht einmal deine Mutter möchte so etwas sehen. (Siga)" }, { "Paaqo1337", "Picasso is back! (Paaqo)" } }; - } + } } diff --git a/ReallifeGamemode.Server/Util/IndicatorData.cs b/ReallifeGamemode.Server/Util/IndicatorData.cs index a9dc68ef..7260cd11 100644 --- a/ReallifeGamemode.Server/Util/IndicatorData.cs +++ b/ReallifeGamemode.Server/Util/IndicatorData.cs @@ -1,8 +1,8 @@ namespace ReallifeGamemode.Server.Util { public class IndicatorData - { - public bool Left { get; set; } = false; - public bool Right { get; set; } = false; - } + { + public bool Left { get; set; } = false; + public bool Right { get; set; } = false; + } } diff --git a/ReallifeGamemode.Server/Util/SmoothThrottle.cs b/ReallifeGamemode.Server/Util/SmoothThrottle.cs index 65ec3d65..7b3fcbf0 100644 --- a/ReallifeGamemode.Server/Util/SmoothThrottle.cs +++ b/ReallifeGamemode.Server/Util/SmoothThrottle.cs @@ -3,38 +3,38 @@ namespace ReallifeGamemode.Server.Util { public class SmoothThrottleAntiReverse : Script + { + [ServerEvent(Event.PlayerExitVehicle)] + public void SmoothThrottleExitEvent(Player player, Vehicle veh) { - [ServerEvent(Event.PlayerExitVehicle)] - public void SmoothThrottleExitEvent(Player player, Vehicle veh) - { - NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerExitVehicle", veh); - } - - [ServerEvent(Event.PlayerEnterVehicle)] - public void SmoothThrottleEnterEvent(Player player, Vehicle veh, sbyte seat) - { - NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerEnterVehicle", veh, seat); - } - - //You can call these to change settings on player if you want. - //Note that these are toggles, you only need to call them once. - - //This disables/enables the smooth throttle - public static void SetSmoothThrottle(Player player, bool turnedOn) - { - NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetSmoothThrottle", turnedOn); - } - - //This disables/enables anti reverse - public static void SetAntiReverse(Player player, bool turnedOn) - { - NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetAntiReverse", turnedOn); - } - - //This disables/enables both - public static void SetSmoothThrottleAntiReverse(Player player, bool turnedOn) - { - NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetGlobal", turnedOn); - } + NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerExitVehicle", veh); } + + [ServerEvent(Event.PlayerEnterVehicle)] + public void SmoothThrottleEnterEvent(Player player, Vehicle veh, sbyte seat) + { + NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_PlayerEnterVehicle", veh, seat); + } + + //You can call these to change settings on player if you want. + //Note that these are toggles, you only need to call them once. + + //This disables/enables the smooth throttle + public static void SetSmoothThrottle(Player player, bool turnedOn) + { + NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetSmoothThrottle", turnedOn); + } + + //This disables/enables anti reverse + public static void SetAntiReverse(Player player, bool turnedOn) + { + NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetAntiReverse", turnedOn); + } + + //This disables/enables both + public static void SetSmoothThrottleAntiReverse(Player player, bool turnedOn) + { + NAPI.ClientEvent.TriggerClientEvent(player, "SmoothThrottle_SetGlobal", turnedOn); + } + } } diff --git a/ReallifeGamemode.Server/Util/TaxiContract.cs b/ReallifeGamemode.Server/Util/TaxiContract.cs index b4c1449b..91943f6c 100644 --- a/ReallifeGamemode.Server/Util/TaxiContract.cs +++ b/ReallifeGamemode.Server/Util/TaxiContract.cs @@ -3,11 +3,11 @@ namespace ReallifeGamemode.Server.Util { public class TaxiContract - { - public string Name { get; set; } + { + public string Name { get; set; } - public Vector3 Position { get; set; } + public Vector3 Position { get; set; } - public Player Driver { get; set; } - } + public Player Driver { get; set; } + } } diff --git a/ReallifeGamemode.Server/Util/ThreadTimers.cs b/ReallifeGamemode.Server/Util/ThreadTimers.cs index 09880058..608fca2d 100644 --- a/ReallifeGamemode.Server/Util/ThreadTimers.cs +++ b/ReallifeGamemode.Server/Util/ThreadTimers.cs @@ -8,50 +8,50 @@ using ReallifeGamemode.Server.WeaponDeal; namespace ReallifeGamemode.Server.Util { public class ThreadTimers + { + private static Timer timer500 = new Timer(500); //0.5 seconds timer + private static Timer timer2500 = new Timer(2500); //2.5 seconds timer + private static Timer timer10000 = new Timer(10000); // 10 second timer + private static Timer timer60000 = new Timer(60000); //60 seconds timer + + public static void StartAllTimers() { - private static Timer timer500 = new Timer(500); //0.5 seconds timer - private static Timer timer2500 = new Timer(2500); //2.5 seconds timer - private static Timer timer10000 = new Timer(10000); // 10 second timer - private static Timer timer60000 = new Timer(60000); //60 seconds timer + timer500.Start(); + timer500.Elapsed += Timer500_Elapsed; - public static void StartAllTimers() - { - timer500.Start(); - timer500.Elapsed += Timer500_Elapsed; + timer2500.Start(); + timer2500.Elapsed += Timer2500_Elapsed; - timer2500.Start(); - timer2500.Elapsed += Timer2500_Elapsed; + timer10000.Start(); + timer10000.Elapsed += Timer10000_Elapsed; - timer10000.Start(); - timer10000.Elapsed += Timer10000_Elapsed; - - timer60000.Start(); - timer60000.Elapsed += Timer60000_Elapsed; - } - - private static void Timer500_Elapsed(object sender, ElapsedEventArgs e) - { - TaxiDriverJob.UpdateFare(); - VehicleManager.VehicleTimerTick(); - } - - private static void Timer60000_Elapsed(object sender, ElapsedEventArgs e) - { - Jail.JailOut_Elapsed(); - Economy.Timer_Elapsed(); - WeaponDealManager.Timer_Elapsed(); - } - - private static void Timer10000_Elapsed(object sender, ElapsedEventArgs e) - { - Jail.BrakeOut_Elapsed(); - } - - private static void Timer2500_Elapsed(object sender, ElapsedEventArgs e) - { - WantedEscapeTimer.Timer_Elapsed(); - Jail.JailIn_Elapsed(); - Gangwar.Gangwar.Value_TimerElapsed(); - } + timer60000.Start(); + timer60000.Elapsed += Timer60000_Elapsed; } + + private static void Timer500_Elapsed(object sender, ElapsedEventArgs e) + { + TaxiDriverJob.UpdateFare(); + VehicleManager.VehicleTimerTick(); + } + + private static void Timer60000_Elapsed(object sender, ElapsedEventArgs e) + { + Jail.JailOut_Elapsed(); + Economy.Timer_Elapsed(); + WeaponDealManager.Timer_Elapsed(); + } + + private static void Timer10000_Elapsed(object sender, ElapsedEventArgs e) + { + Jail.BrakeOut_Elapsed(); + } + + private static void Timer2500_Elapsed(object sender, ElapsedEventArgs e) + { + WantedEscapeTimer.Timer_Elapsed(); + Jail.JailIn_Elapsed(); + Gangwar.Gangwar.Value_TimerElapsed(); + } + } } diff --git a/ReallifeGamemode.Server/Util/TransactionResult.cs b/ReallifeGamemode.Server/Util/TransactionResult.cs index c9453987..ed0bc493 100644 --- a/ReallifeGamemode.Server/Util/TransactionResult.cs +++ b/ReallifeGamemode.Server/Util/TransactionResult.cs @@ -1,11 +1,11 @@ namespace ReallifeGamemode.Server.Util { public enum TransactionResult - { - SUCCESS, - SENDER_NO_BANKACCOUNT, - RECEIVER_NO_BANKACCOUNT, - SENDER_NOT_ENOUGH_MONEY, - NEGATIVE_MONEY_SENT - } + { + SUCCESS, + SENDER_NO_BANKACCOUNT, + RECEIVER_NO_BANKACCOUNT, + SENDER_NOT_ENOUGH_MONEY, + NEGATIVE_MONEY_SENT + } } diff --git a/ReallifeGamemode.Server/Util/VehicleSync.cs b/ReallifeGamemode.Server/Util/VehicleSync.cs index b876bcc3..fd8676ff 100644 --- a/ReallifeGamemode.Server/Util/VehicleSync.cs +++ b/ReallifeGamemode.Server/Util/VehicleSync.cs @@ -6,523 +6,523 @@ namespace ReallifeGamemode.Server.Util { //Enums for ease of use public enum WindowID + { + WindowFrontRight, + WindowFrontLeft, + WindowRearRight, + WindowRearLeft + } + + public enum WindowState + { + WindowFixed, + WindowDown, + WindowBroken + } + + public enum DoorID + { + DoorFrontLeft, + DoorFrontRight, + DoorRearLeft, + DoorRearRight, + DoorHood, + DoorTrunk + } + + public enum DoorState + { + DoorClosed, + DoorOpen, + DoorBroken, + } + + public enum WheelID + { + Wheel0, + Wheel1, + Wheel2, + Wheel3, + Wheel4, + Wheel5, + Wheel6, + Wheel7, + Wheel8, + Wheel9 + } + + public enum WheelState + { + WheelFixed, + WheelBurst, + WheelOnRim, + } + + public class VehicleStreaming : Script + { + //This is the data object which will be synced to vehicles + public class VehicleSyncData { - WindowFrontRight, - WindowFrontLeft, - WindowRearRight, - WindowRearLeft + //Used to bypass some streaming bugs + public Vector3 Position { get; set; } = new Vector3(); + + public Vector3 Rotation { get; set; } = new Vector3(); + + //Basics + public float Dirt { get; set; } = 0.0f; + + public bool Locked { get; set; } = true; + public bool Engine { get; set; } = false; + + //(Not synced) + //public float BodyHealth { get; set; } = 1000.0f; + //public float EngineHealth { get; set; } = 1000.0f; + + //Doors 0-7 (0 = closed, 1 = open, 2 = broken) (This uses enums so don't worry about it) + public int[] Door { get; set; } = new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }; + + //Windows (0 = up, 1 = down, 2 = smashed) (This uses enums so don't worry about it) + public int[] Window { get; set; } = new int[4] { 0, 0, 0, 0 }; + + //Wheels 0-7, 45/47 (0 = fixed, 1 = flat, 2 = missing) (This uses enums so don't worry about it) + public int[] Wheel { get; set; } = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; } - public enum WindowState + //API functions for people to use + public static void SetVehicleWindowState(Vehicle veh, WindowID window, WindowState state) { - WindowFixed, - WindowDown, - WindowBroken + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) //If data doesn't exist create a new one. This is the process for all API functions + data = new VehicleSyncData(); + + data.Window[(int)window] = (int)state; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWindowStatus_Single", veh.Handle, (int)window, (int)state); } - public enum DoorID + public static WindowState GetVehicleWindowState(Vehicle veh, WindowID window) { - DoorFrontLeft, - DoorFrontRight, - DoorRearLeft, - DoorRearRight, - DoorHood, - DoorTrunk + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return (WindowState)data.Window[(int)window]; } - public enum DoorState + public static void SetVehicleWheelState(Vehicle veh, WheelID wheel, WheelState state) { - DoorClosed, - DoorOpen, - DoorBroken, + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Wheel[(int)wheel] = (int)state; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWheelStatus_Single", veh.Handle, (int)wheel, (int)state); } - public enum WheelID + public static WheelState GetVehicleWheelState(Vehicle veh, WheelID wheel) { - Wheel0, - Wheel1, - Wheel2, - Wheel3, - Wheel4, - Wheel5, - Wheel6, - Wheel7, - Wheel8, - Wheel9 + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return (WheelState)data.Wheel[(int)wheel]; } - public enum WheelState + public static void SetVehicleDirt(Vehicle veh, float dirt) { - WheelFixed, - WheelBurst, - WheelOnRim, + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Dirt = dirt; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDirtLevel", veh.Handle, dirt); } - public class VehicleStreaming : Script + public static float GetVehicleDirt(Vehicle veh) { - //This is the data object which will be synced to vehicles - public class VehicleSyncData + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return data.Dirt; + } + + public static void SetDoorState(Vehicle veh, DoorID door, DoorState state) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Door[(int)door] = (int)state; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus_Single", veh, (int)door, (int)state); + } + + public static DoorState GetDoorState(Vehicle veh, DoorID door) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return (DoorState)data.Door[(int)door]; + } + + public static void SetEngineState(Vehicle veh, bool status) + { + veh.EngineStatus = status; + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Engine = status; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetEngineStatus", veh, status); + } + + public static bool GetEngineState(Vehicle veh) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return veh.EngineStatus; + } + + public static void SetLockStatus(Vehicle veh, bool status) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Locked = status; + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetLockStatus", veh, status); + NAPI.Pools.GetAllPlayers().ForEach(p => + { + if (p.IsInVehicle && p.Vehicle.Handle == veh.Handle) { - //Used to bypass some streaming bugs - public Vector3 Position { get; set; } = new Vector3(); - - public Vector3 Rotation { get; set; } = new Vector3(); - - //Basics - public float Dirt { get; set; } = 0.0f; - - public bool Locked { get; set; } = true; - public bool Engine { get; set; } = false; - - //(Not synced) - //public float BodyHealth { get; set; } = 1000.0f; - //public float EngineHealth { get; set; } = 1000.0f; - - //Doors 0-7 (0 = closed, 1 = open, 2 = broken) (This uses enums so don't worry about it) - public int[] Door { get; set; } = new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }; - - //Windows (0 = up, 1 = down, 2 = smashed) (This uses enums so don't worry about it) - public int[] Window { get; set; } = new int[4] { 0, 0, 0, 0 }; - - //Wheels 0-7, 45/47 (0 = fixed, 1 = flat, 2 = missing) (This uses enums so don't worry about it) - public int[] Wheel { get; set; } = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + p.TriggerEvent("Vehicle_setLockStatus", status); } + }); + } - //API functions for people to use - public static void SetVehicleWindowState(Vehicle veh, WindowID window, WindowState state) + public static bool GetLockState(Vehicle veh) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + { + data = new VehicleSyncData(); + UpdateVehicleSyncData(veh, data); + } + return data.Locked; + } + + //Used internally only but publicly available in case any of you need it + public static VehicleSyncData GetVehicleSyncData(Vehicle veh) + { + if (veh != null) + { + if (NAPI.Entity.DoesEntityExist(veh)) { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) //If data doesn't exist create a new one. This is the process for all API functions - data = new VehicleSyncData(); - - data.Window[(int)window] = (int)state; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWindowStatus_Single", veh.Handle, (int)window, (int)state); - } - - public static WindowState GetVehicleWindowState(Vehicle veh, WindowID window) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) + if (NAPI.Data.HasEntitySharedData(veh, "VehicleSyncData")) + { + try { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); + //API converts class objects to JObject so we have to change it back + JObject obj = (JObject)NAPI.Data.GetEntitySharedData(veh, "VehicleSyncData"); + return obj.ToObject(); } - return (WindowState)data.Window[(int)window]; + catch (Exception) { return null; } + } } + } - public static void SetVehicleWheelState(Vehicle veh, WheelID wheel, WheelState state) + return default; //null + } + + //Used internally only but publicly available in case any of you need it + public static bool UpdateVehicleSyncData(Vehicle veh, VehicleSyncData data) + { + if (veh != null) + { + if (NAPI.Entity.DoesEntityExist(veh)) { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Wheel[(int)wheel] = (int)state; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWheelStatus_Single", veh.Handle, (int)wheel, (int)state); - } - - public static WheelState GetVehicleWheelState(Vehicle veh, WheelID wheel) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); - } - return (WheelState)data.Wheel[(int)wheel]; - } - - public static void SetVehicleDirt(Vehicle veh, float dirt) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Dirt = dirt; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDirtLevel", veh.Handle, dirt); - } - - public static float GetVehicleDirt(Vehicle veh) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); - } - return data.Dirt; - } - - public static void SetDoorState(Vehicle veh, DoorID door, DoorState state) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Door[(int)door] = (int)state; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus_Single", veh, (int)door, (int)state); - } - - public static DoorState GetDoorState(Vehicle veh, DoorID door) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); - } - return (DoorState)data.Door[(int)door]; - } - - public static void SetEngineState(Vehicle veh, bool status) - { - veh.EngineStatus = status; - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Engine = status; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetEngineStatus", veh, status); - } - - public static bool GetEngineState(Vehicle veh) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); - } - return veh.EngineStatus; - } - - public static void SetLockStatus(Vehicle veh, bool status) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Locked = status; - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetLockStatus", veh, status); - NAPI.Pools.GetAllPlayers().ForEach(p => - { - if (p.IsInVehicle && p.Vehicle.Handle == veh.Handle) - { - p.TriggerEvent("Vehicle_setLockStatus", status); - } - }); - } - - public static bool GetLockState(Vehicle veh) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - { - data = new VehicleSyncData(); - UpdateVehicleSyncData(veh, data); - } - return data.Locked; - } - - //Used internally only but publicly available in case any of you need it - public static VehicleSyncData GetVehicleSyncData(Vehicle veh) - { - if (veh != null) - { - if (NAPI.Entity.DoesEntityExist(veh)) - { - if (NAPI.Data.HasEntitySharedData(veh, "VehicleSyncData")) - { - try - { - //API converts class objects to JObject so we have to change it back - JObject obj = (JObject)NAPI.Data.GetEntitySharedData(veh, "VehicleSyncData"); - return obj.ToObject(); - } - catch (Exception) { return null; } - } - } - } - - return default; //null - } - - //Used internally only but publicly available in case any of you need it - public static bool UpdateVehicleSyncData(Vehicle veh, VehicleSyncData data) - { - if (veh != null) - { - if (NAPI.Entity.DoesEntityExist(veh)) - { - if (data != null) - { - data.Position = veh.Position; - data.Rotation = veh.Rotation; - NAPI.Data.SetEntitySharedData(veh, "VehicleSyncData", data); - return true; - } - } - } - return false; - } - - public static void SetVehicleRotation(Vehicle veh, VehicleSyncData data, Vector3 rot) - { - if (veh != null) - { - if (NAPI.Entity.DoesEntityExist(veh)) - { - if (data != null) - { - data.Rotation = rot; - NAPI.Data.SetEntitySharedData(veh, "VehicleSyncData", data); - } - } - } - } - - //Called from the client to sync dirt level - [RemoteEvent("VehStream_SetDirtLevel")] - public void VehStreamSetDirtLevel(Player player, Vehicle veh, float dirt) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Dirt = dirt; - - UpdateVehicleSyncData(veh, data); - - //Re-distribute the goods - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDirtLevel", veh.Handle, dirt); - } - - //Called from the client to sync door data - [RemoteEvent("VehStream_SetDoorData")] - public void VehStreamSetDoorData(Player player, Vehicle veh, int door1state, int door2state, int door3state, int door4state, int door5state, int door6state, int door7state, int door8state) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Door[0] = door1state; - data.Door[1] = door2state; - data.Door[2] = door3state; - data.Door[3] = door4state; - data.Door[4] = door5state; - data.Door[5] = door6state; - data.Door[6] = door7state; - data.Door[7] = door8state; - - UpdateVehicleSyncData(veh, data); - - //Re-distribute the goods - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, door1state, door2state, door3state, door4state, door5state, door6state, door7state, door8state); - } - - //Called from the client to sync window data - [RemoteEvent("VehStream_SetWindowData")] - public void VehStreamSetWindowData(Player player, Vehicle veh, int window1state, int window2state, int window3state, int window4state) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Window[0] = window1state; - data.Window[1] = window2state; - data.Window[2] = window3state; - data.Window[3] = window4state; - - UpdateVehicleSyncData(veh, data); - - //Re-distribute the goods - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWindowStatus", veh.Handle, window1state, window2state, window3state, window4state); - } - - //Called from the client to sync wheel data - [RemoteEvent("VehStream_SetWheelData")] - public void VehStreamSetWheelData(Player player, Vehicle veh, int wheel1state, int wheel2state, int wheel3state, int wheel4state, int wheel5state, int wheel6state, int wheel7state, int wheel8state, int wheel9state, int wheel10state) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Wheel[0] = wheel1state; - data.Wheel[1] = wheel2state; - data.Wheel[2] = wheel3state; - data.Wheel[3] = wheel4state; - data.Wheel[4] = wheel5state; - data.Wheel[5] = wheel6state; - data.Wheel[6] = wheel7state; - data.Wheel[7] = wheel8state; - data.Wheel[8] = wheel9state; - data.Wheel[9] = wheel10state; - UpdateVehicleSyncData(veh, data); - - //Re-distribute the goods - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWheelStatus", veh.Handle, wheel1state, wheel2state, wheel3state, wheel4state, wheel5state, wheel6state, wheel7state, wheel8state, wheel9state, wheel10state); - } - - //Other events - [ServerEvent(Event.PlayerEnterVehicleAttempt)] - public void VehStreamEnterAttempt(Player player, Vehicle veh, sbyte seat) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerEnterVehicleAttempt", veh.Handle.Value, seat); - } - - [ServerEvent(Event.PlayerExitVehicleAttempt)] - public void VehStreamExitAttempt(Player player, Vehicle veh) - { - if (player.HasData("isDead") && player.GetData("isDead")) - return; - - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - + if (data != null) + { data.Position = veh.Position; data.Rotation = veh.Rotation; - - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerExitVehicleAttempt", veh); - } - - [ServerEvent(Event.PlayerExitVehicle)] - public void VehStreamExit(Player player, Vehicle veh) - { - if (player.HasData("isDead") && player.GetData("isDead")) - return; - - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Position = veh.Position; - data.Rotation = veh.Rotation; - - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerExitVehicle", veh.Handle.Value); - } - - [ServerEvent(Event.PlayerEnterVehicle)] - public void VehStreamEnter(Player player, Vehicle veh, sbyte seat) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - UpdateVehicleSyncData(veh, data); - NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerEnterVehicle", veh, seat); - player.TriggerEvent("Vehicle_setLockStatus", data.Locked); - } - - //[ServerEvent(Event.VehicleDamage)] - //public void VehDamage(Vehicle veh, float bodyHealthLoss, float engineHealthLoss) - //{ - // VehicleSyncData data = GetVehicleSyncData(veh); - // if (data == default(VehicleSyncData)) - // data = new VehicleSyncData(); - - // data.BodyHealth -= bodyHealthLoss; - // data.EngineHealth -= engineHealthLoss; - - // UpdateVehicleSyncData(veh, data); - - // if (NAPI.Vehicle.GetVehicleDriver(veh) != default(Player)) //Doesn't work? - // NAPI.ClientEvent.TriggerClientEvent(NAPI.Vehicle.GetVehicleDriver(veh), "VehStream_PlayerExitVehicleAttempt", veh); - //} - - [ServerEvent(Event.VehicleDoorBreak)] - public void VehDoorBreak(Vehicle veh, int index) - { - VehicleSyncData data = GetVehicleSyncData(veh); - if (data == default(VehicleSyncData)) - data = new VehicleSyncData(); - - data.Door[index] = 2; - - UpdateVehicleSyncData(veh, data); - - NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, data.Door[0], data.Door[1], data.Door[2], data.Door[3], data.Door[4], data.Door[5], data.Door[6], data.Door[7]); - } - - // INDICATORS - - [RemoteEvent("CLIENT:toggleLeftIndicator")] - public void ToggleLeftIndicator(Player player) - { - if (!player.IsInVehicle || player.VehicleSeat != 0) return; - Vehicle veh = player.Vehicle; - - if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); - - if (data.Left && data.Right) - { - data.Right = false; - } - else - { - data.Left = !data.Left; - data.Right = false; - } - - veh.SetData("indicatorData", data); - NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); - } - - [RemoteEvent("CLIENT:toggleRightIndicator")] - public void ToggleRightIndicator(Player player) - { - if (!player.IsInVehicle || player.VehicleSeat != 0) return; - Vehicle veh = player.Vehicle; - - if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); - - if (data.Left && data.Right) - { - data.Left = false; - } - else - { - data.Right = !data.Right; - data.Left = false; - } - - veh.SetData("indicatorData", data); - NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); - } - - [RemoteEvent("CLIENT:toggleWarningIndicator")] - public void ToggleWarningIndicator(Player player) - { - if (!player.IsInVehicle || player.VehicleSeat != 0) return; - Vehicle veh = player.Vehicle; - - if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); - - if (data.Right && data.Left) - { - data.Right = false; - data.Left = false; - } - else - { - data.Right = true; - data.Left = true; - } - - veh.SetData("indicatorData", data); - NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); + NAPI.Data.SetEntitySharedData(veh, "VehicleSyncData", data); + return true; + } } + } + return false; } + + public static void SetVehicleRotation(Vehicle veh, VehicleSyncData data, Vector3 rot) + { + if (veh != null) + { + if (NAPI.Entity.DoesEntityExist(veh)) + { + if (data != null) + { + data.Rotation = rot; + NAPI.Data.SetEntitySharedData(veh, "VehicleSyncData", data); + } + } + } + } + + //Called from the client to sync dirt level + [RemoteEvent("VehStream_SetDirtLevel")] + public void VehStreamSetDirtLevel(Player player, Vehicle veh, float dirt) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Dirt = dirt; + + UpdateVehicleSyncData(veh, data); + + //Re-distribute the goods + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDirtLevel", veh.Handle, dirt); + } + + //Called from the client to sync door data + [RemoteEvent("VehStream_SetDoorData")] + public void VehStreamSetDoorData(Player player, Vehicle veh, int door1state, int door2state, int door3state, int door4state, int door5state, int door6state, int door7state, int door8state) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Door[0] = door1state; + data.Door[1] = door2state; + data.Door[2] = door3state; + data.Door[3] = door4state; + data.Door[4] = door5state; + data.Door[5] = door6state; + data.Door[6] = door7state; + data.Door[7] = door8state; + + UpdateVehicleSyncData(veh, data); + + //Re-distribute the goods + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, door1state, door2state, door3state, door4state, door5state, door6state, door7state, door8state); + } + + //Called from the client to sync window data + [RemoteEvent("VehStream_SetWindowData")] + public void VehStreamSetWindowData(Player player, Vehicle veh, int window1state, int window2state, int window3state, int window4state) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Window[0] = window1state; + data.Window[1] = window2state; + data.Window[2] = window3state; + data.Window[3] = window4state; + + UpdateVehicleSyncData(veh, data); + + //Re-distribute the goods + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWindowStatus", veh.Handle, window1state, window2state, window3state, window4state); + } + + //Called from the client to sync wheel data + [RemoteEvent("VehStream_SetWheelData")] + public void VehStreamSetWheelData(Player player, Vehicle veh, int wheel1state, int wheel2state, int wheel3state, int wheel4state, int wheel5state, int wheel6state, int wheel7state, int wheel8state, int wheel9state, int wheel10state) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Wheel[0] = wheel1state; + data.Wheel[1] = wheel2state; + data.Wheel[2] = wheel3state; + data.Wheel[3] = wheel4state; + data.Wheel[4] = wheel5state; + data.Wheel[5] = wheel6state; + data.Wheel[6] = wheel7state; + data.Wheel[7] = wheel8state; + data.Wheel[8] = wheel9state; + data.Wheel[9] = wheel10state; + UpdateVehicleSyncData(veh, data); + + //Re-distribute the goods + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleWheelStatus", veh.Handle, wheel1state, wheel2state, wheel3state, wheel4state, wheel5state, wheel6state, wheel7state, wheel8state, wheel9state, wheel10state); + } + + //Other events + [ServerEvent(Event.PlayerEnterVehicleAttempt)] + public void VehStreamEnterAttempt(Player player, Vehicle veh, sbyte seat) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerEnterVehicleAttempt", veh.Handle.Value, seat); + } + + [ServerEvent(Event.PlayerExitVehicleAttempt)] + public void VehStreamExitAttempt(Player player, Vehicle veh) + { + if (player.HasData("isDead") && player.GetData("isDead")) + return; + + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Position = veh.Position; + data.Rotation = veh.Rotation; + + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerExitVehicleAttempt", veh); + } + + [ServerEvent(Event.PlayerExitVehicle)] + public void VehStreamExit(Player player, Vehicle veh) + { + if (player.HasData("isDead") && player.GetData("isDead")) + return; + + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Position = veh.Position; + data.Rotation = veh.Rotation; + + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerExitVehicle", veh.Handle.Value); + } + + [ServerEvent(Event.PlayerEnterVehicle)] + public void VehStreamEnter(Player player, Vehicle veh, sbyte seat) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + UpdateVehicleSyncData(veh, data); + NAPI.ClientEvent.TriggerClientEvent(player, "VehStream_PlayerEnterVehicle", veh, seat); + player.TriggerEvent("Vehicle_setLockStatus", data.Locked); + } + + //[ServerEvent(Event.VehicleDamage)] + //public void VehDamage(Vehicle veh, float bodyHealthLoss, float engineHealthLoss) + //{ + // VehicleSyncData data = GetVehicleSyncData(veh); + // if (data == default(VehicleSyncData)) + // data = new VehicleSyncData(); + + // data.BodyHealth -= bodyHealthLoss; + // data.EngineHealth -= engineHealthLoss; + + // UpdateVehicleSyncData(veh, data); + + // if (NAPI.Vehicle.GetVehicleDriver(veh) != default(Player)) //Doesn't work? + // NAPI.ClientEvent.TriggerClientEvent(NAPI.Vehicle.GetVehicleDriver(veh), "VehStream_PlayerExitVehicleAttempt", veh); + //} + + [ServerEvent(Event.VehicleDoorBreak)] + public void VehDoorBreak(Vehicle veh, int index) + { + VehicleSyncData data = GetVehicleSyncData(veh); + if (data == default(VehicleSyncData)) + data = new VehicleSyncData(); + + data.Door[index] = 2; + + UpdateVehicleSyncData(veh, data); + + NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, data.Door[0], data.Door[1], data.Door[2], data.Door[3], data.Door[4], data.Door[5], data.Door[6], data.Door[7]); + } + + // INDICATORS + + [RemoteEvent("CLIENT:toggleLeftIndicator")] + public void ToggleLeftIndicator(Player player) + { + if (!player.IsInVehicle || player.VehicleSeat != 0) return; + Vehicle veh = player.Vehicle; + + if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); + + if (data.Left && data.Right) + { + data.Right = false; + } + else + { + data.Left = !data.Left; + data.Right = false; + } + + veh.SetData("indicatorData", data); + NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); + } + + [RemoteEvent("CLIENT:toggleRightIndicator")] + public void ToggleRightIndicator(Player player) + { + if (!player.IsInVehicle || player.VehicleSeat != 0) return; + Vehicle veh = player.Vehicle; + + if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); + + if (data.Left && data.Right) + { + data.Left = false; + } + else + { + data.Right = !data.Right; + data.Left = false; + } + + veh.SetData("indicatorData", data); + NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); + } + + [RemoteEvent("CLIENT:toggleWarningIndicator")] + public void ToggleWarningIndicator(Player player) + { + if (!player.IsInVehicle || player.VehicleSeat != 0) return; + Vehicle veh = player.Vehicle; + + if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData(); + + if (data.Right && data.Left) + { + data.Right = false; + data.Left = false; + } + else + { + data.Right = true; + data.Left = true; + } + + veh.SetData("indicatorData", data); + NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right); + } + } } diff --git a/ReallifeGamemode.Server/Wanted/Autowanted.cs b/ReallifeGamemode.Server/Wanted/Autowanted.cs index 9f9df9d5..bb708f31 100644 --- a/ReallifeGamemode.Server/Wanted/Autowanted.cs +++ b/ReallifeGamemode.Server/Wanted/Autowanted.cs @@ -6,24 +6,24 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Wanted { public class Autowanted + { + public static void Check_AutoWanted(Player killerPlayer, Player copPlayer) { - public static void Check_AutoWanted(Player killerPlayer, Player copPlayer) - { - User killer = killerPlayer.GetUser(); - if (killer.FactionId == 1 || killer.FactionId == 3) - return; + User killer = killerPlayer.GetUser(); + if (killer.FactionId == 1 || killer.FactionId == 3) + return; - User cop = copPlayer.GetUser(); - if (!cop.GetData("duty")) return; - if (cop.FactionId == 1 || cop.FactionId == 3) - { - using (var dbContext = new DatabaseContext()) - { - killer = killerPlayer.GetUser(dbContext); - killer.GiveWanteds(copPlayer, 10, "Beamten-Mord"); - dbContext.SaveChanges(); - } - } + User cop = copPlayer.GetUser(); + if (!cop.GetData("duty")) return; + if (cop.FactionId == 1 || cop.FactionId == 3) + { + using (var dbContext = new DatabaseContext()) + { + killer = killerPlayer.GetUser(dbContext); + killer.GiveWanteds(copPlayer, 10, "Beamten-Mord"); + dbContext.SaveChanges(); } + } } + } } diff --git a/ReallifeGamemode.Server/Wanted/Jail.cs b/ReallifeGamemode.Server/Wanted/Jail.cs index 65d9905e..28e175be 100644 --- a/ReallifeGamemode.Server/Wanted/Jail.cs +++ b/ReallifeGamemode.Server/Wanted/Jail.cs @@ -14,81 +14,81 @@ using Newtonsoft.Json; namespace ReallifeGamemode.Server.Wanted { public class Jail : Script + { + private static Dictionary Jailtime { get; set; } = new Dictionary(); //time in seconds + + public static void Check_PutBehindBars(Player client) { - private static Dictionary Jailtime { get; set; } = new Dictionary(); //time in seconds + User user = client.GetUser(); + if (user.JailTime > 0) + { + client.RemoveAllWeapons(); + client.Health = 100; + client.Armor = 0; + Random rnd = new Random(); + int rndInt = rnd.Next(1, 3); + if (rndInt == 1) + NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail + if (rndInt == 2) + NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail + if (rndInt == 3) + NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail + Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds + int timeMinutes = 0; - public static void Check_PutBehindBars(Player client) + if (((int)(user.JailTime / 60)) <= 1 && user.JailTime != 0) { - User user = client.GetUser(); - if (user.JailTime > 0) + timeMinutes = 1; + } + else + { + timeMinutes = (int)(user.JailTime / 60); + } + client.TriggerEvent("jailTime", timeMinutes); + return; + } + if (user.Wanteds <= 0) + return; + foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) + { + if (!copPlayer.IsLoggedIn()) continue; + User cop = copPlayer.GetUser(); + if (cop?.FactionId == 1 || cop?.FactionId == 3) + { + int jailTime = user.Wanteds * 54; + if (cop.GetData("duty") && copPlayer.Position.DistanceTo2D(client.Position) <= 200 && (!copPlayer.HasData("isDead") || copPlayer.GetData("isDead") != true)) + { + using (var dbContext = new DatabaseContext()) { - client.RemoveAllWeapons(); - client.Health = 100; - client.Armor = 0; - Random rnd = new Random(); - int rndInt = rnd.Next(1, 3); - if (rndInt == 1) - NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail - if (rndInt == 2) - NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail - if (rndInt == 3) - NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - Jailtime[user.Id] = user.JailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds - int timeMinutes = 0; + if (!client.HasData("isDead") || client.GetData("isDead") == false) + { + jailTime /= 2; + } - if (((int)(user.JailTime / 60)) <= 1 && user.JailTime != 0) - { - timeMinutes = 1; - } - else - { - timeMinutes = (int)(user.JailTime / 60); - } - client.TriggerEvent("jailTime", timeMinutes); - return; + client.GetUser(dbContext).JailTime = jailTime; + Jailtime[user.Id] = jailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds + + client.GetUser(dbContext).Wanteds = 0; + dbContext.SaveChanges(); } - if (user.Wanteds <= 0) - return; - foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) - { - if (!copPlayer.IsLoggedIn()) continue; - User cop = copPlayer.GetUser(); - if (cop?.FactionId == 1 || cop?.FactionId == 3) - { - int jailTime = user.Wanteds * 54; - if (cop.GetData("duty") && copPlayer.Position.DistanceTo2D(client.Position) <= 200 && (!copPlayer.HasData("isDead") || copPlayer.GetData("isDead") != true)) - { - using (var dbContext = new DatabaseContext()) - { - if (!client.HasData("isDead") || client.GetData("isDead") == false) - { - jailTime /= 2; - } + client.SetData("isDead", false); + client.RemoveAllWeapons(); + client.SetSharedData("blipColor", 0); + Random rnd = new Random(); + int rndInt = rnd.Next(1, 3); + if (rndInt == 1) + NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail + if (rndInt == 2) + NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail + if (rndInt == 3) + NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - client.GetUser(dbContext).JailTime = jailTime; - Jailtime[user.Id] = jailTime; // 54 sec for each wanted star -> in total 45min for 50 Wanteds + client.TriggerEvent("onPlayerRevived"); + MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name); + Medic.RemoveTaskFromList(task); + client.Health = 100; - client.GetUser(dbContext).Wanteds = 0; - dbContext.SaveChanges(); - } - client.SetData("isDead", false); - client.RemoveAllWeapons(); - client.SetSharedData("blipColor", 0); - Random rnd = new Random(); - int rndInt = rnd.Next(1, 3); - if (rndInt == 1) - NAPI.Player.SpawnPlayer(client, new Vector3(458.9842, -997.2126, 24.91485)); //send client to jail - if (rndInt == 2) - NAPI.Player.SpawnPlayer(client, new Vector3(459.696, -994.3766, 24.91486)); //send client to jail - if (rndInt == 3) - NAPI.Player.SpawnPlayer(client, new Vector3(458.3372, -1001.258, 24.91485)); //send client to jail - - client.TriggerEvent("onPlayerRevived"); - MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == client.Name); - Medic.RemoveTaskFromList(task); - client.Health = 100; - - int timeMinutes = 0; + int timeMinutes = 0; if (((int)(client.GetUser().JailTime / 60)) <= 1 && client.GetUser().JailTime != 0) { @@ -129,152 +129,152 @@ namespace ReallifeGamemode.Server.Wanted } } - /* - public static void JailTimer() - { - System.Timers.Timer timer = new System.Timers.Timer(60000); - System.Timers.Timer brakeOut = new System.Timers.Timer(10000); - System.Timers.Timer jailIn = new System.Timers.Timer(2500); - timer.Start(); - brakeOut.Start(); - jailIn.Start(); - //timer.Elapsed += Timer_Elapsed; - //brakeOut.Elapsed += BrakeOut_Elapsed; - //jailIn.Elapsed += JailIn_Elapsed; - } - */ - - public static void JailIn_Elapsed() - { - foreach (var player in NAPI.Pools.GetAllPlayers()) - { - User user = player.GetUser(); - if (user != null && !Jailtime.ContainsKey(user.Id)) - { - foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) - { - if (!copPlayer.IsLoggedIn()) return; - User cop = copPlayer.GetUser(); - if (cop.GetData("duty") && copPlayer.Position.DistanceTo2D(player.Position) <= 500 && (!copPlayer.HasData("isDead") || copPlayer.GetData("isDead") != true)) - { - if (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) <= 7) - { - if (player.Position.DistanceTo2D(copPlayer.Position) < 5) - { - Check_PutBehindBars(player); - } - } - } - } - } - } - } - - public static void BrakeOut_Elapsed() - { - foreach (var player in NAPI.Pools.GetAllPlayers()) - { - User user = player.GetUser(); - - if (user != null && player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) > 7 && Jailtime.ContainsKey(user.Id)) - { - using (var dbContext = new DatabaseContext()) - { - user = player.GetUser(dbContext); - user.JailTime = 0; - user.GiveWanteds(null, 50, "Knast-Ausbruch"); - player.TriggerEvent("jailTime", 0); - dbContext.SaveChanges(); - Jailtime.Remove(user.Id); - } - } - } - } - - public static void JailOut_Elapsed() - { - foreach (var player in NAPI.Pools.GetAllPlayers()) - { - User user = player.GetUser(); - if (user != null && Jailtime.ContainsKey(user.Id)) - { - if (user.JailTime <= 0) - { - Jailtime.Remove(user.Id); - player.Position = new Vector3(461.7256, -988.6035, 24.91487); - player.TriggerEvent("jailTime", 0); - return; - } - if (user.JailTime > 0) - { - using (var dbContext = new DatabaseContext()) - { - player.GetUser(dbContext).JailTime -= 60; - dbContext.SaveChanges(); - } - - int timeMinutes = 0; - - if (((int)(user.JailTime / 60)) == 0 && user.JailTime != 0) - { - timeMinutes = 1; - } - else - { - timeMinutes = (int)(user.JailTime / 60); - } - - player.TriggerEvent("jailTime", timeMinutes); - player.Health = 100; - } - } - } - } - - [RemoteEvent("setPrisonerFree")] - public void Release_Jail(Player cop, string client) - { - Player player = PlayerService.GetPlayerByNameOrId(client); - if (player == null) - return; - - User user = player.GetUser(); - if (Jailtime.ContainsKey(user.Id)) - { - Jailtime.Remove(user.Id); - using (var dbContext = new DatabaseContext()) - { - player.GetUser(dbContext).JailTime = 0; - dbContext.SaveChanges(); - } - player.Health = 100; - player.Position = new Vector3(461.7256, -988.6035, 24.91487); - - ChatService.HQMessage("!{#8181E9}HQ: Beamter " + cop.Name + " hat " + user.Name + " aus dem Knast entlassen."); - ChatService.SendMessage(player, "!{#8181E9}Der Beamte " + cop.Name + " hat dich aus dem Knast entlassen"); - player.TriggerEvent("jailTime", 0); - } - } - - public static void Release_Jail_Admin(Player admin, Player target) - { - User user = target.GetUser(); - if (Jailtime.ContainsKey(user.Id)) - { - Jailtime.Remove(user.Id); - using (var dbContext = new DatabaseContext()) - { - target.GetUser(dbContext).JailTime = 0; - dbContext.SaveChanges(); - } - target.Health = 100; - target.Position = new Vector3(461.7256, -988.6035, 24.91487); - - ChatService.HQMessage(" Admin " + admin.Name + " hat " + user.Name + " aus dem Knast entlassen."); - ChatService.SendMessage(target, "!{#8181E9}Admin " + admin.Name + " hat dich aus dem Knast entlassen"); - ChatService.SendMessage(admin, "!{#8181E9}Du hast " + user.Name + " administrativ aus dem Knast entlassen"); - target.TriggerEvent("jailTime", 0); - } - } + /* + public static void JailTimer() + { + System.Timers.Timer timer = new System.Timers.Timer(60000); + System.Timers.Timer brakeOut = new System.Timers.Timer(10000); + System.Timers.Timer jailIn = new System.Timers.Timer(2500); + timer.Start(); + brakeOut.Start(); + jailIn.Start(); + //timer.Elapsed += Timer_Elapsed; + //brakeOut.Elapsed += BrakeOut_Elapsed; + //jailIn.Elapsed += JailIn_Elapsed; } -} \ No newline at end of file + */ + + public static void JailIn_Elapsed() + { + foreach (var player in NAPI.Pools.GetAllPlayers()) + { + User user = player.GetUser(); + if (user != null && !Jailtime.ContainsKey(user.Id)) + { + foreach (var copPlayer in NAPI.Pools.GetAllPlayers()) + { + if (!copPlayer.IsLoggedIn()) return; + User cop = copPlayer.GetUser(); + if (cop.GetData("duty") && copPlayer.Position.DistanceTo2D(player.Position) <= 500 && (!copPlayer.HasData("isDead") || copPlayer.GetData("isDead") != true)) + { + if (player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) <= 7) + { + if (player.Position.DistanceTo2D(copPlayer.Position) < 5) + { + Check_PutBehindBars(player); + } + } + } + } + } + } + } + + public static void BrakeOut_Elapsed() + { + foreach (var player in NAPI.Pools.GetAllPlayers()) + { + User user = player.GetUser(); + + if (user != null && player.Position.DistanceTo2D(new Vector3(458.9842, -997.2126, 24.91485)) > 7 && Jailtime.ContainsKey(user.Id)) + { + using (var dbContext = new DatabaseContext()) + { + user = player.GetUser(dbContext); + user.JailTime = 0; + user.GiveWanteds(null, 50, "Knast-Ausbruch"); + player.TriggerEvent("jailTime", 0); + dbContext.SaveChanges(); + Jailtime.Remove(user.Id); + } + } + } + } + + public static void JailOut_Elapsed() + { + foreach (var player in NAPI.Pools.GetAllPlayers()) + { + User user = player.GetUser(); + if (user != null && Jailtime.ContainsKey(user.Id)) + { + if (user.JailTime <= 0) + { + Jailtime.Remove(user.Id); + player.Position = new Vector3(461.7256, -988.6035, 24.91487); + player.TriggerEvent("jailTime", 0); + return; + } + if (user.JailTime > 0) + { + using (var dbContext = new DatabaseContext()) + { + player.GetUser(dbContext).JailTime -= 60; + dbContext.SaveChanges(); + } + + int timeMinutes = 0; + + if (((int)(user.JailTime / 60)) == 0 && user.JailTime != 0) + { + timeMinutes = 1; + } + else + { + timeMinutes = (int)(user.JailTime / 60); + } + + player.TriggerEvent("jailTime", timeMinutes); + player.Health = 100; + } + } + } + } + + [RemoteEvent("setPrisonerFree")] + public void Release_Jail(Player cop, string client) + { + Player player = PlayerService.GetPlayerByNameOrId(client); + if (player == null) + return; + + User user = player.GetUser(); + if (Jailtime.ContainsKey(user.Id)) + { + Jailtime.Remove(user.Id); + using (var dbContext = new DatabaseContext()) + { + player.GetUser(dbContext).JailTime = 0; + dbContext.SaveChanges(); + } + player.Health = 100; + player.Position = new Vector3(461.7256, -988.6035, 24.91487); + + ChatService.HQMessage("!{#8181E9}HQ: Beamter " + cop.Name + " hat " + user.Name + " aus dem Knast entlassen."); + ChatService.SendMessage(player, "!{#8181E9}Der Beamte " + cop.Name + " hat dich aus dem Knast entlassen"); + player.TriggerEvent("jailTime", 0); + } + } + + public static void Release_Jail_Admin(Player admin, Player target) + { + User user = target.GetUser(); + if (Jailtime.ContainsKey(user.Id)) + { + Jailtime.Remove(user.Id); + using (var dbContext = new DatabaseContext()) + { + target.GetUser(dbContext).JailTime = 0; + dbContext.SaveChanges(); + } + target.Health = 100; + target.Position = new Vector3(461.7256, -988.6035, 24.91487); + + ChatService.HQMessage(" Admin " + admin.Name + " hat " + user.Name + " aus dem Knast entlassen."); + ChatService.SendMessage(target, "!{#8181E9}Admin " + admin.Name + " hat dich aus dem Knast entlassen"); + ChatService.SendMessage(admin, "!{#8181E9}Du hast " + user.Name + " administrativ aus dem Knast entlassen"); + target.TriggerEvent("jailTime", 0); + } + } + } +} diff --git a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs index 5c5dcea4..0585ed28 100644 --- a/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs +++ b/ReallifeGamemode.Server/Wanted/WantedEscapeTimer.cs @@ -13,53 +13,53 @@ using ReallifeGamemode.Server.Extensions; namespace ReallifeGamemode.Server.Wanted { public class WantedEscapeTimer + { + public static Dictionary waTimer { get; set; } = new Dictionary(); //zeit in ms + /* + public static void WantedTimer() { - public static Dictionary waTimer { get; set; } = new Dictionary(); //zeit in ms - /* - public static void WantedTimer() - { - //System.Timers.Timer timer = new System.Timers.Timer(2500); - //timer.Start(); - //timer.Elapsed += Timer_Elapsed; - } - */ + //System.Timers.Timer timer = new System.Timers.Timer(2500); + //timer.Start(); + //timer.Elapsed += Timer_Elapsed; + } + */ - public static void ResetWantedTimeToElapse(Player client) - { - User user = client.GetUser(); - if (user.FactionId == 1 || user.FactionId == 3) - return; + public static void ResetWantedTimeToElapse(Player client) + { + User user = client.GetUser(); + if (user.FactionId == 1 || user.FactionId == 3) + return; - waTimer[user.Id] = 300000; - } + waTimer[user.Id] = 300000; + } - public static void Timer_Elapsed() + public static void Timer_Elapsed() + { + foreach (var player in NAPI.Pools.GetAllPlayers()) + { + User user = player.GetUser(); + if (user != null && user.Wanteds > 0) { - foreach (var player in NAPI.Pools.GetAllPlayers()) + if (!waTimer.ContainsKey(user.Id)) + ResetWantedTimeToElapse(player); + + bool isNearCop = false; + foreach (var playerCop in NAPI.Pools.GetAllPlayers()) + { + if (!playerCop.IsLoggedIn()) continue; + + User cop = playerCop.GetUser(); + if (cop != null && (cop.FactionId == 1 || cop.FactionId == 3)) { - User user = player.GetUser(); - if (user != null && user.Wanteds > 0) - { - if (!waTimer.ContainsKey(user.Id)) - ResetWantedTimeToElapse(player); - - bool isNearCop = false; - foreach (var playerCop in NAPI.Pools.GetAllPlayers()) - { - if (!playerCop.IsLoggedIn()) continue; - - User cop = playerCop.GetUser(); - if (cop != null && (cop.FactionId == 1 || cop.FactionId == 3)) - { - if (cop.GetData("duty") && playerCop.Position.DistanceTo2D(player.Position) <= 500) - { - //Schriftzug 'abgetaucht' zerstören :( - isNearCop = true; - break; - } - //Hier abgetaucht schriftzug einfügen :) - } - } + if (cop.GetData("duty") && playerCop.Position.DistanceTo2D(player.Position) <= 500) + { + //Schriftzug 'abgetaucht' zerstören :( + isNearCop = true; + break; + } + //Hier abgetaucht schriftzug einfügen :) + } + } if (!waTimer.ContainsKey(user.Id)) waTimer[user.Id] = 300000; @@ -95,10 +95,10 @@ namespace ReallifeGamemode.Server.Wanted } } - if (!isNearCop) - waTimer[user.Id] -= 2500; - } - } + if (!isNearCop) + waTimer[user.Id] -= 2500; } + } } -} \ No newline at end of file + } +}