From 154b0ca0fe2d4469fcfa9d42c6631c7649121659 Mon Sep 17 00:00:00 2001 From: Siga Date: Mon, 3 Feb 2020 18:13:10 +0100 Subject: [PATCH] Add ItemShop, fix ClotheShop Payment, fix Vehicle Respawn, Add Vehicle Lock from outside --- .../Interaction/ItemShop.ts | 107 ++ .../Interaction/clothes/ClotheShop.ts | 8 - ReallifeGamemode.Client/index.ts | 5 +- .../inventory/inventory.ts | 23 +- .../vehiclesync/vehiclesync.ts | 11 +- .../Entities/ShopItem.cs | 21 + .../20200202153232_ShopItems.Designer.cs | 1426 +++++++++++++++++ .../Migrations/20200202153232_ShopItems.cs | 33 + .../DatabaseContextModelSnapshot.cs | 18 + .../Models/DatabaseContext.cs | 3 + ReallifeGamemode.Server/Events/Key.cs | 15 +- ReallifeGamemode.Server/Events/Login.cs | 2 +- .../Events/UpdateCharacterCloth.cs | 5 +- ReallifeGamemode.Server/Events/Vehicle.cs | 83 +- .../Extensions/ServerVehicleExtensions.cs | 3 +- .../Inventory/Interfaces/IItem.cs | 1 + .../Inventory/Items/Aal.cs | 1 + .../Inventory/Items/Barsch.cs | 1 + .../Inventory/Items/Cannabis.cs | 1 + .../Inventory/Items/CarbineRifle.cs | 1 + .../Inventory/Items/Cheeseburger.cs | 2 + .../Inventory/Items/Cocain.cs | 1 + .../Inventory/Items/DropItem.cs | 1 + .../Inventory/Items/Flunder.cs | 1 + .../Inventory/Items/FoodItem.cs | 1 + .../Inventory/Items/Holz.cs | 4 +- .../Inventory/Items/Lachs.cs | 1 + .../Inventory/Items/Pistol50.cs | 1 + .../Inventory/Items/PumpShotgun.cs | 1 + .../Inventory/Items/SMG.cs | 1 + .../Inventory/Items/Schutzweste.cs | 1 + .../Inventory/Items/SniperRifle.cs | 1 + .../Inventory/Items/Thunfisch.cs | 1 + .../Inventory/Items/WeaponDealItem.cs | 1 + .../Inventory/Items/Zander.cs | 1 + ReallifeGamemode.Server/Main.cs | 2 +- .../Managers/InventoryManager.cs | 37 + .../Managers/PositionManager.cs | 44 +- .../Managers/ShopManager.cs | 20 +- .../Managers/VehicleManager.cs | 13 +- .../Shop/SevenEleven/ItemShop.cs | 44 + ReallifeGamemode.Server/Util/VehicleSync.cs | 23 + 42 files changed, 1920 insertions(+), 50 deletions(-) create mode 100644 ReallifeGamemode.Client/Interaction/ItemShop.ts create mode 100644 ReallifeGamemode.Database/Entities/ShopItem.cs create mode 100644 ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs create mode 100644 ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs create mode 100644 ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs diff --git a/ReallifeGamemode.Client/Interaction/ItemShop.ts b/ReallifeGamemode.Client/Interaction/ItemShop.ts new file mode 100644 index 00000000..0adcb86c --- /dev/null +++ b/ReallifeGamemode.Client/Interaction/ItemShop.ts @@ -0,0 +1,107 @@ +import * as NativeUI from 'NativeUI'; + +const UIMenu = NativeUI.Menu; +const UIMenuItem = NativeUI.UIMenuItem; +const UIMenuListItem = NativeUI.UIMenuListItem; +const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem; +const BadgeStyle = NativeUI.BadgeStyle; +const Point = NativeUI.Point; +const ItemsCollection = NativeUI.ItemsCollection; +const Color = NativeUI.Color; + +export default function itemShopList(globalData: GlobalData) { + + + const localPlayer = mp.players.local; + var playerPos; + var myVar; + + let mainMenu = null; + let items = []; + let currentMenuIdx = -1; + let menuTransition = false; // workaround for ItemSelect event being called twice between menu transitions + + + + function addItems(data) { + + // Fill it + + for (const item of data) { + + const tempItem = new UIMenuItem(item.Name, ""); + + tempItem.SetRightLabel(`${item.Price > 0 ? `$${item.Price}` : "FREE"}`); + + mainMenu.AddItem(tempItem); + + items.push(item); + } + + + } + + + + function myTimer() { + let dist = mp.game.gameplay.getDistanceBetweenCoords(localPlayer.position.x, localPlayer.position.y, 0, playerPos.x, playerPos.y, 0, false); + if (dist > 3) { + clearInterval(myVar); + if (mainMenu && mainMenu.Visible) mainMenu.Close(); + } + } + + mp.events.add("itemMenu:updateData", (jsonData) => { + if (!globalData.InMenu) { + globalData.InMenu = true; + playerPos = localPlayer.position; + var data = JSON.parse(jsonData); + + // Default menu banner + + const bannerSprite = { + library: "shopui_title_conveniencestore", + texture: "shopui_title_conveniencestore" + }; + + // Hide the chat + mp.gui.chat.show(false); + + // Reset some variables + currentMenuIdx = -1; + menuTransition = false; + + + // Create a new main menu + mainMenu = new UIMenu("", "CHOOSE A ITEM", new Point(0, 0), bannerSprite.library, bannerSprite.texture); + mainMenu.Visible = true; + + // Add items + addItems(data); + + myVar = setInterval(myTimer, 100); + + // Main menu events + mainMenu.ItemSelect.on((selectedItem, itemIndex) => { + const nextItem = items[itemIndex]; + mp.events.callRemote("SERVER:BuyItems", nextItem.Name); + + }); + + mainMenu.MenuClose.on(() => { + globalData.InMenu = false; + mp.gui.chat.show(true); + + currentMenuIdx = -1; + }); + } + }); + + mp.events.add("itemMenu:close", () => { + if (mainMenu && mainMenu.Visible) mainMenu.Close(); + }); + + mp.events.add("itemMenu:Error", () => { + mp.game.audio.playSoundFrontend(1, "Hack_Failed", "DLC_HEIST_BIOLAB_PREP_HACKING_SOUNDS", true); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts b/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts index 76d6abbc..8208a673 100644 --- a/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts +++ b/ReallifeGamemode.Client/Interaction/clothes/ClotheShop.ts @@ -16,14 +16,6 @@ const Point = NativeUI.Point; const ItemsCollection = NativeUI.ItemsCollection; const Color = NativeUI.Color; -let screenRes = mp.game.graphics.getScreenResolution(0, 0); -let saveItem = new UIMenuItem("Bestätigen", ""); -saveItem.BackColor = new Color(13, 71, 161); -saveItem.HighlightedBackColor = new Color(25, 118, 210); - -let cancelItem = new UIMenuItem("Abbrechen", ""); -cancelItem.BackColor = new Color(213, 0, 0); -cancelItem.HighlightedBackColor = new Color(229, 57, 53); export default function clotheShopList(globalData: GlobalData) { const categoryTitles = { diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index e1b9f18c..316cbc8c 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -185,4 +185,7 @@ import gangwarHandle from './util/Gangwar'; gangwarHandle(globalData); import clotheShopList from './Interaction/clothes/ClotheShop'; -clotheShopList(globalData); \ No newline at end of file +clotheShopList(globalData); + +import itemShopList from './Interaction/ItemShop'; +itemShopList(globalData); \ No newline at end of file diff --git a/ReallifeGamemode.Client/inventory/inventory.ts b/ReallifeGamemode.Client/inventory/inventory.ts index 0474de41..4fcc42be 100644 --- a/ReallifeGamemode.Client/inventory/inventory.ts +++ b/ReallifeGamemode.Client/inventory/inventory.ts @@ -21,23 +21,27 @@ export default function inventory(globalData: GlobalData): void { mp.events.add('showVehInventory', () => { invBrowser.execute(`execVehInv();`); }); - + var open = false; mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => { - if (!globalData.InMenu) { + if (invBrowser === null) { - mp.gui.cursor.show(true, true); - invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html'); - Players = playersArr; - itemIdArr = iIdArr; - itemAmountArr = iAmountArr; - itemNameArr = iNameArr; - invWeight = iWeight; + if (!globalData.InMenu) { + globalData.InMenu = true; + mp.gui.cursor.show(true, true); + invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html'); + Players = playersArr; + itemIdArr = iIdArr; + itemAmountArr = iAmountArr; + itemNameArr = iNameArr; + invWeight = iWeight; + } } else { try { invBrowser.destroy() invBrowser = null; + globalData.InMenu = false; } finally { mp.gui.cursor.show(false, false); @@ -45,7 +49,6 @@ export default function inventory(globalData: GlobalData): void { return; } - } }); var offer = 0; diff --git a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts index e263dae0..e7c14514 100644 --- a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts +++ b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts @@ -33,6 +33,7 @@ export default function vehicleSync() { var toggle = entity.getVariable("VehicleSyncData"); entity.setEngineOn(toggle.Engine, false, true); entity.setUndriveable(!toggle.Engine); + entity.setInvincible(false); } }); @@ -44,7 +45,6 @@ export default function vehicleSync() { entity.setEngineOn(toggle.Engine, true, false); entity.setUndriveable(!toggle.Engine); } - var level = entity.getDirtLevel(); mp.events.callRemote("VehStream_SetDirtLevel", entity, level); } @@ -548,4 +548,13 @@ export default function vehicleSync() { }, 1500); } }); + + mp.events.add("vehsync:OpenCar", (bool) => { + if (bool) { + mp.game.audio.playSoundFrontend(1, "OPENED", "MP_PROPERTIES_ELEVATOR_DOORS", true); + } else { + mp.game.audio.playSoundFrontend(1, "CLOSED", "MP_PROPERTIES_ELEVATOR_DOORS", true); + } + + }); } \ No newline at end of file diff --git a/ReallifeGamemode.Database/Entities/ShopItem.cs b/ReallifeGamemode.Database/Entities/ShopItem.cs new file mode 100644 index 00000000..acbafa1b --- /dev/null +++ b/ReallifeGamemode.Database/Entities/ShopItem.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace ReallifeGamemode.Database.Entities +{ + public partial class ShopItem + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + public int ShopId { get; set; } + + public int ItemId { get; set; } + public int Amount { get; set; } + public int Price { get; set; } + } +} diff --git a/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs new file mode 100644 index 00000000..cab22b1f --- /dev/null +++ b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs @@ -0,0 +1,1426 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ReallifeGamemode.Database.Models; + +namespace ReallifeGamemode.Database.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20200202153232_ShopItems")] + partial class ShopItems + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.1.11-servicing-32099") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ATM", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Faulty"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("ATMs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Ban", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Applied"); + + b.Property("BannedBy"); + + b.Property("Reason"); + + b.Property("UntilDateTime"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.BusinessBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Balance"); + + b.Property("BusinessId"); + + b.HasKey("Id"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.ToTable("BusinessBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.BusinessData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BusinessId"); + + b.Property("Price"); + + b.HasKey("Id"); + + b.ToTable("BusinessData"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.BusRoute", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.HasKey("Id"); + + b.ToTable("BusRoutes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.BusRoutePoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BusRouteId"); + + b.Property("Description"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.HasIndex("BusRouteId"); + + b.ToTable("BusRoutesPoints"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Ageing"); + + b.Property("AgeingOpacity"); + + b.Property("BeardColor"); + + b.Property("Blemishes"); + + b.Property("BlemishesOpacity"); + + b.Property("Blush"); + + b.Property("BlushColor"); + + b.Property("BlushOpacity"); + + b.Property("BrowDepth"); + + b.Property("BrowHeight"); + + b.Property("CheekDepth"); + + b.Property("CheekboneHeight"); + + b.Property("CheekboneWidth"); + + b.Property("ChestHair"); + + b.Property("ChestHairColor"); + + b.Property("ChestHairOpacity"); + + b.Property("ChinDepth"); + + b.Property("ChinHeight"); + + b.Property("ChinIndent"); + + b.Property("ChinWidth"); + + b.Property("Complexion"); + + b.Property("ComplexionOpacity"); + + b.Property("EyeColor"); + + b.Property("EyeSize"); + + b.Property("EyebrowColor"); + + b.Property("Eyebrows"); + + b.Property("EyebrowsOpacity"); + + b.Property("FacialHair"); + + b.Property("FacialHairOpacity"); + + b.Property("Father"); + + b.Property("Freckles"); + + b.Property("FrecklesOpacity"); + + b.Property("Gender"); + + b.Property("Hair"); + + b.Property("HairColor"); + + b.Property("HairHighlightColor"); + + b.Property("JawShape"); + + b.Property("JawWidth"); + + b.Property("LipThickness"); + + b.Property("Lipstick"); + + b.Property("LipstickColor"); + + b.Property("LipstickOpacity"); + + b.Property("Makeup"); + + b.Property("MakeupOpacity"); + + b.Property("Mother"); + + b.Property("NeckWidth"); + + b.Property("NoseBottomHeight"); + + b.Property("NoseBridgeDepth"); + + b.Property("NoseBroken"); + + b.Property("NoseTipHeight"); + + b.Property("NoseTipLength"); + + b.Property("NoseWidth"); + + b.Property("Similarity"); + + b.Property("SkinSimilarity"); + + b.Property("SunDamage"); + + b.Property("SunDamageOpacity"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Characters"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.CharacterCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("Duty"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.Property("Texture"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("CharacterClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ClothCombination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Gender"); + + b.Property("Top"); + + b.Property("Torso"); + + b.Property("Undershirt"); + + b.HasKey("Id"); + + b.ToTable("ClothCombinations"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Door", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Category"); + + b.Property("FactionId"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("Name"); + + b.Property("Radius"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("Doors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.DutyCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("FactionId"); + + b.Property("Gender"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("DutyClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Faction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("StateOwned"); + + b.Property("WeaponDealTime"); + + b.HasKey("Id"); + + b.ToTable("Factions"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Bic") + .HasMaxLength(12); + + b.Property("FactionId"); + + b.Property("Iban") + .HasMaxLength(32); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FactionId"); + + b.Property("Order"); + + b.Property("RankName"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionRanks"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionWeapon", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Ammount"); + + b.Property("FactionId"); + + b.Property("Rank"); + + b.Property("SlotID"); + + b.Property("WeaponModel"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionWeapons"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.GotoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Description") + .HasMaxLength(32); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("GotoPoints"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Balance"); + + b.Property("GroupId"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.House", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CanRentIn"); + + b.Property("OwnerId"); + + b.Property("Price"); + + b.Property("RentalFee"); + + b.Property("Type"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.ToTable("Houses"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.HouseRental", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("HouseId"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("HouseId"); + + b.HasIndex("UserId"); + + b.ToTable("HouseRentals"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Interior", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EnterPositionStr") + .HasColumnName("EnterPosition"); + + b.Property("ExitPositionStr") + .HasColumnName("ExitPosition"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Interiors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Description"); + + b.Property("Heading"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("Locations"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.BankAccountTransactionHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Fee"); + + b.Property("MoneySent"); + + b.Property("NewReceiverBalance"); + + b.Property("NewSenderBalance"); + + b.Property("Origin") + .HasMaxLength(32); + + b.Property("Receiver") + .HasMaxLength(32); + + b.Property("ReceiverBalance"); + + b.Property("Sender") + .HasMaxLength(32); + + b.Property("SenderBalance"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.HasKey("Id"); + + b.ToTable("BankAccountTransactionLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Death", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CauseOfDeath") + .HasMaxLength(64); + + b.Property("KillerHeading"); + + b.Property("KillerId"); + + b.Property("KillerPositionX"); + + b.Property("KillerPositionY"); + + b.Property("KillerPositionZ"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.Property("VictimHeading"); + + b.Property("VictimId"); + + b.Property("VictimPositionX"); + + b.Property("VictimPositionY"); + + b.Property("VictimPositionZ"); + + b.HasKey("Id"); + + b.HasIndex("KillerId"); + + b.HasIndex("VictimId"); + + b.ToTable("DeathLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Caption"); + + b.Property("Content"); + + b.Property("Timestamp"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedBlip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Alpha"); + + b.Property("Color"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Name"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Rotation"); + + b.Property("Scale"); + + b.Property("ShortRange"); + + b.Property("Sprite"); + + b.HasKey("Id"); + + b.ToTable("Blips"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedMarker", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DirectionX"); + + b.Property("DirectionY"); + + b.Property("DirectionZ"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Scale"); + + b.Property("Type"); + + b.Property("Visible"); + + b.HasKey("Id"); + + b.ToTable("Markers"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedPed", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("HashModel"); + + b.Property("Heading"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.HasKey("Id"); + + b.ToTable("Peds"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedPickup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("PositionX") + .HasMaxLength(128); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RespawnTime"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Vehicle"); + + b.HasKey("Id"); + + b.ToTable("Pickups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedTextLabel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Font"); + + b.Property("LOS"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("TextLabels"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ServerVehicle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active") + .ValueGeneratedOnAdd() + .HasDefaultValue(true); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("DistanceDriven"); + + b.Property("Heading"); + + b.Property("Livery"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("NumberPlate") + .HasMaxLength(8); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("PrimaryColor"); + + b.Property("SecondaryColor"); + + b.Property("TankAmount"); + + b.HasKey("Id"); + + b.ToTable("ServerVehicles"); + + b.HasDiscriminator("Discriminator").HasValue("ServerVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ShopClothe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Category"); + + b.Property("ClotheId"); + + b.Property("ComponentId"); + + b.Property("Gender"); + + b.Property("Price"); + + b.Property("TypeId"); + + b.HasKey("Id"); + + b.ToTable("ShopClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ShopItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Price"); + + b.Property("ShopId"); + + b.HasKey("Id"); + + b.ToTable("ShopItems"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.TuningGarage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("TuningGarages"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Turfs", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Color"); + + b.Property("FactionId"); + + b.Property("Name"); + + b.Property("Owner"); + + b.Property("Range"); + + b.Property("Rotation"); + + b.Property("Vector"); + + b.Property("X"); + + b.Property("Y"); + + b.HasKey("Id"); + + b.ToTable("Turfs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AdminLevel"); + + b.Property("BanId"); + + b.Property("BusinessId"); + + b.Property("CharacterId"); + + b.Property("Dead"); + + b.Property("DriverLicenseBike"); + + b.Property("DriverLicenseVehicle"); + + b.Property("Email") + .HasMaxLength(64); + + b.Property("FactionId"); + + b.Property("FactionLeader"); + + b.Property("FactionRankId"); + + b.Property("FlyingLicensePlane"); + + b.Property("GroupId"); + + b.Property("GroupRank"); + + b.Property("Handmoney"); + + b.Property("HouseId"); + + b.Property("JailTime"); + + b.Property("JobId"); + + b.Property("LogUserId"); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("Password") + .HasMaxLength(64); + + b.Property("PaydayTimer"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RegistrationDate") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName") + .HasMaxLength(32); + + b.Property("Wage"); + + b.Property("Wanteds"); + + b.HasKey("Id"); + + b.HasIndex("BanId"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.HasIndex("CharacterId"); + + b.HasIndex("FactionId"); + + b.HasIndex("FactionRankId"); + + b.HasIndex("GroupId"); + + b.HasIndex("HouseId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Bic") + .HasMaxLength(12); + + b.Property("Iban") + .HasMaxLength(32); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Slot"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserItems"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Slot"); + + b.Property("VehicleId"); + + b.HasKey("Id"); + + b.HasIndex("VehicleId"); + + b.ToTable("VehicleItems"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleMod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ModId"); + + b.Property("ServerVehicleId"); + + b.Property("Slot"); + + b.HasKey("Id"); + + b.HasIndex("ServerVehicleId", "Slot") + .IsUnique(); + + b.ToTable("VehicleMods"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Whitelist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName"); + + b.HasKey("Id"); + + b.ToTable("WhitelistEntries"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("FactionId"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionVehicles"); + + b.HasDiscriminator().HasValue("FactionVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupVehicle"); + + b.HasDiscriminator().HasValue("GroupVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.JobVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("JobId"); + + b.ToTable("JobVehicle"); + + b.HasDiscriminator().HasValue("JobVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Saves.SavedVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + + b.ToTable("SavedVehicle"); + + b.HasDiscriminator().HasValue("SavedVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.SchoolVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("SchoolId"); + + b.ToTable("SchoolVehicle"); + + b.HasDiscriminator().HasValue("SchoolVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ShopVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("BusinessId"); + + b.Property("Price"); + + b.ToTable("ShopVehicles"); + + b.HasDiscriminator().HasValue("ShopVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Database.Entities.ServerVehicle"); + + b.Property("UserId"); + + b.HasIndex("UserId"); + + b.ToTable("UserVehicles"); + + b.HasDiscriminator().HasValue("UserVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Ban", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.BusRoutePoint", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.BusRoute", "BusRoute") + .WithMany("RoutePoints") + .HasForeignKey("BusRouteId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Character", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.CharacterCloth", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Door", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.DutyCloth", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionBankAccount", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionRank", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionWeapon", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupBankAccount", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.House", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.HouseRental", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.House", "House") + .WithMany() + .HasForeignKey("HouseId"); + + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.Death", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "Killer") + .WithMany() + .HasForeignKey("KillerId"); + + b.HasOne("ReallifeGamemode.Database.Entities.User", "Victim") + .WithMany() + .HasForeignKey("VictimId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.User", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Ban", "Ban") + .WithMany() + .HasForeignKey("BanId"); + + b.HasOne("ReallifeGamemode.Database.Entities.Character", "Character") + .WithMany() + .HasForeignKey("CharacterId"); + + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + + b.HasOne("ReallifeGamemode.Database.Entities.FactionRank", "FactionRank") + .WithMany() + .HasForeignKey("FactionRankId"); + + b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + + b.HasOne("ReallifeGamemode.Database.Entities.House", "House") + .WithMany() + .HasForeignKey("HouseId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserBankAccount", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserItem", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleItem", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.ServerVehicle", "Vehicle") + .WithMany() + .HasForeignKey("VehicleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleMod", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.ServerVehicle", "Vehicle") + .WithMany() + .HasForeignKey("ServerVehicleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.FactionVehicle", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserVehicle", b => + { + b.HasOne("ReallifeGamemode.Database.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs new file mode 100644 index 00000000..6029e7a1 --- /dev/null +++ b/ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace ReallifeGamemode.Database.Migrations +{ + public partial class ShopItems : Migration + { + 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"); + } + } +} diff --git a/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs b/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs index 55c17b53..073cc208 100644 --- a/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/ReallifeGamemode.Database/Migrations/DatabaseContextModelSnapshot.cs @@ -896,6 +896,24 @@ namespace ReallifeGamemode.Database.Migrations b.ToTable("ShopClothes"); }); + modelBuilder.Entity("ReallifeGamemode.Database.Entities.ShopItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Price"); + + b.Property("ShopId"); + + b.HasKey("Id"); + + b.ToTable("ShopItems"); + }); + modelBuilder.Entity("ReallifeGamemode.Database.Entities.TuningGarage", b => { b.Property("Id") diff --git a/ReallifeGamemode.Database/Models/DatabaseContext.cs b/ReallifeGamemode.Database/Models/DatabaseContext.cs index b9b01ad8..a5ad8d4f 100644 --- a/ReallifeGamemode.Database/Models/DatabaseContext.cs +++ b/ReallifeGamemode.Database/Models/DatabaseContext.cs @@ -128,5 +128,8 @@ namespace ReallifeGamemode.Database.Models //ClothesShop public DbSet ShopClothes { get; set; } + //ItemShop + public DbSet ShopItems { get; set; } + } } diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index a3947402..34b8b7f3 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -148,7 +148,9 @@ namespace ReallifeGamemode.Server.Events WeaponPoint nearestWeapon = PositionManager.WeaponPoints.Find(w => w.Position.DistanceTo(player.Position) <= 1.5 && w.FactionId == user.FactionId); JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData("duty")); ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3)); - ShopPoint nearestShopPoint = PositionManager.ShopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); + ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); + ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); + if (nearestDuty != null)// Duty Point { var nameTagColor = new Color(0, 0, 0); @@ -326,9 +328,13 @@ namespace ReallifeGamemode.Server.Events } player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray())); } - if(nearestShopPoint != null) + if(nearestClotheShopPoint != null) { - nearestShopPoint.clotheShop.LoadShopNUI(player); + nearestClotheShopPoint.clotheShop.LoadShopNUI(player); + } + if(nearestItemShopPoint != null) + { + nearestItemShopPoint.itemShop.LoadShopNUI(player); } if (user.FactionLeader) { @@ -481,6 +487,9 @@ namespace ReallifeGamemode.Server.Events if (!player.IsInVehicle) { + + Vehicle.VehicleMenuLockCarEvent(player); + GroundItem.PickUpGroundItem(player); } diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index b22d4362..273adcb8 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -115,7 +115,7 @@ namespace ReallifeGamemode.Server.Events { CharacterCreator.ApplyCharacter(player); UpdateCharacterCloth.LoadCharacterDefaults(player); - if (user.JailTime == 0) + if (user.JailTime <= 0) { NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0); } diff --git a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs index 7dd307b4..aadbf946 100644 --- a/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs +++ b/ReallifeGamemode.Server/Events/UpdateCharacterCloth.cs @@ -251,9 +251,10 @@ namespace ReallifeGamemode.Server.Events undershirt.Texture = data[5]; } } - user.Handmoney -= data[6]; - client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + 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/Vehicle.cs b/ReallifeGamemode.Server/Events/Vehicle.cs index 99310ad4..d8e6ec9d 100644 --- a/ReallifeGamemode.Server/Events/Vehicle.cs +++ b/ReallifeGamemode.Server/Events/Vehicle.cs @@ -65,7 +65,7 @@ namespace ReallifeGamemode.Server.Events } [RemoteEvent("VehicleMenu_LockCar")] - public void VehicleMenuLockCarEvent(Client player) + public static void VehicleMenuLockCarEvent(Client player) { if (player.IsInVehicle && player.VehicleSeat == -1) { @@ -98,13 +98,80 @@ namespace ReallifeGamemode.Server.Events 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.FactionId != u.FactionId) + { + return; + } + } + else if (sV is UserVehicle uV) + { + if (uV.UserId != u.Id) + { + return; + } + } + else if (sV is JobVehicle) + { + return; + } + else if (sV is SchoolVehicle) + { + 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")] @@ -147,6 +214,16 @@ namespace ReallifeGamemode.Server.Events 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; @@ -199,10 +276,6 @@ namespace ReallifeGamemode.Server.Events } } - [ServerEvent(Event.VehicleDeath)] - public void VehicleDeathEvent(GTANetworkAPI.Vehicle veh) - { - } } } diff --git a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs index c646bcfb..24471332 100644 --- a/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs +++ b/ReallifeGamemode.Server/Extensions/ServerVehicleExtensions.cs @@ -27,10 +27,11 @@ namespace ReallifeGamemode.Server.Extensions 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; + 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); diff --git a/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs b/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs index 656e03d6..4c6e2ad2 100644 --- a/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs +++ b/ReallifeGamemode.Server/Inventory/Interfaces/IItem.cs @@ -17,5 +17,6 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces string Description { get; } int Gewicht { get; } string Einheit { get; } + int Price { get; } } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Aal.cs b/ReallifeGamemode.Server/Inventory/Items/Aal.cs index 9c5c4fd4..930c0b90 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Aal.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Aal.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Barsch.cs b/ReallifeGamemode.Server/Inventory/Items/Barsch.cs index a4566abc..54dd90c4 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Barsch.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Barsch.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Cannabis.cs b/ReallifeGamemode.Server/Inventory/Items/Cannabis.cs index 62e1ed3c..653cb29a 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Cannabis.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Cannabis.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public int Gewicht => 50; public string Einheit => "g"; public uint Object => 3076948544; + public int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/CarbineRifle.cs b/ReallifeGamemode.Server/Inventory/Items/CarbineRifle.cs index c8958023..ea55e6f6 100644 --- a/ReallifeGamemode.Server/Inventory/Items/CarbineRifle.cs +++ b/ReallifeGamemode.Server/Inventory/Items/CarbineRifle.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 4000; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs b/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs index 507ddb93..044ba1cb 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Cheeseburger.cs @@ -20,5 +20,7 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 2240524752; + public override int Price => 150; + } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Cocain.cs b/ReallifeGamemode.Server/Inventory/Items/Cocain.cs index 8f45ee7e..b9cd9d39 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Cocain.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Cocain.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 25; public override uint Object => 2240524752; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/DropItem.cs b/ReallifeGamemode.Server/Inventory/Items/DropItem.cs index 9a840a29..d7fb2b44 100644 --- a/ReallifeGamemode.Server/Inventory/Items/DropItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/DropItem.cs @@ -18,6 +18,7 @@ namespace ReallifeGamemode.Server.Inventory.Items 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, Client player, int amount) { diff --git a/ReallifeGamemode.Server/Inventory/Items/Flunder.cs b/ReallifeGamemode.Server/Inventory/Items/Flunder.cs index 1d81254c..a9696747 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Flunder.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Flunder.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs index b4df0940..495fbd5c 100644 --- a/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/FoodItem.cs @@ -18,6 +18,7 @@ namespace ReallifeGamemode.Server.Inventory.Items 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) { diff --git a/ReallifeGamemode.Server/Inventory/Items/Holz.cs b/ReallifeGamemode.Server/Inventory/Items/Holz.cs index 7f683200..0336e6db 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Holz.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Holz.cs @@ -1,7 +1,4 @@ using ReallifeGamemode.Server.Inventory.Interfaces; -using System; -using System.Collections.Generic; -using System.Text; /** * @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs) @@ -19,5 +16,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public int Gewicht => 650; public string Einheit => "g"; public uint Object => 1805779401; + public int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Lachs.cs b/ReallifeGamemode.Server/Inventory/Items/Lachs.cs index b66ffc22..75de97be 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Lachs.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Lachs.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Pistol50.cs b/ReallifeGamemode.Server/Inventory/Items/Pistol50.cs index 375db1d0..62496028 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Pistol50.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Pistol50.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 1180; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/PumpShotgun.cs b/ReallifeGamemode.Server/Inventory/Items/PumpShotgun.cs index 55c3d6e2..f540609f 100644 --- a/ReallifeGamemode.Server/Inventory/Items/PumpShotgun.cs +++ b/ReallifeGamemode.Server/Inventory/Items/PumpShotgun.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 3600; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/SMG.cs b/ReallifeGamemode.Server/Inventory/Items/SMG.cs index abadc8d3..99bc94a3 100644 --- a/ReallifeGamemode.Server/Inventory/Items/SMG.cs +++ b/ReallifeGamemode.Server/Inventory/Items/SMG.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 3080; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Schutzweste.cs b/ReallifeGamemode.Server/Inventory/Items/Schutzweste.cs index 0511623e..4c217e2c 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Schutzweste.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Schutzweste.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 3000; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/SniperRifle.cs b/ReallifeGamemode.Server/Inventory/Items/SniperRifle.cs index b032eea5..2a792fac 100644 --- a/ReallifeGamemode.Server/Inventory/Items/SniperRifle.cs +++ b/ReallifeGamemode.Server/Inventory/Items/SniperRifle.cs @@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override int Gewicht => 12900; public override string Einheit => "g"; public override uint Object => 3666746839; //3061944032 + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/Thunfisch.cs b/ReallifeGamemode.Server/Inventory/Items/Thunfisch.cs index 4a365dde..9723a074 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Thunfisch.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Thunfisch.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs b/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs index be35833f..efa6e31e 100644 --- a/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs +++ b/ReallifeGamemode.Server/Inventory/Items/WeaponDealItem.cs @@ -17,6 +17,7 @@ namespace ReallifeGamemode.Server.Inventory.Items public abstract int Gewicht { get; } public abstract string Einheit { get; } public abstract uint Object { get; } + public abstract int Price { get; } public bool noTransfer(Client client, UserItem uItem, FactionVehicle fVeh) { diff --git a/ReallifeGamemode.Server/Inventory/Items/Zander.cs b/ReallifeGamemode.Server/Inventory/Items/Zander.cs index 13ee6ce4..2ea621a3 100644 --- a/ReallifeGamemode.Server/Inventory/Items/Zander.cs +++ b/ReallifeGamemode.Server/Inventory/Items/Zander.cs @@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items public override string Einheit => "g"; public override int HpAmount => 20; public override uint Object => 786272259; + public override int Price => 0; } } diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index b7a8694d..11a6b502 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -45,7 +45,7 @@ namespace ReallifeGamemode.Server InventoryManager.LoadItems(); ShopManager.LoadClotheShops(); - + ShopManager.LoadItemShops(); TuningManager.LoadTuningGarages(); TimeManager.StartTimeManager(); diff --git a/ReallifeGamemode.Server/Managers/InventoryManager.cs b/ReallifeGamemode.Server/Managers/InventoryManager.cs index e56445a0..05c27955 100644 --- a/ReallifeGamemode.Server/Managers/InventoryManager.cs +++ b/ReallifeGamemode.Server/Managers/InventoryManager.cs @@ -863,5 +863,42 @@ namespace ReallifeGamemode.Server.Managers ChatService.SendMessage(target, $"{client.Name} hat deine Anfrage angenommen."); } + + [RemoteEvent("SERVER:BuyItems")] + public void SrvEvent_BuyItem(Client client, string itemName) + { + IItem shopItem = GetItemByName(itemName); + + using(var dbContext = new DatabaseContext()){ + User user = client.GetUser(dbContext); + + if (user.Handmoney < shopItem.Price) + { + client.TriggerEvent("itemMenu:Error"); + return; + } + + UserItem item = dbContext.UserItems.Where(i => i.ItemId == shopItem.Id && i.UserId == user.Id).FirstOrDefault(); + if(item == null) + { + var newItem = new UserItem + { + ItemId = shopItem.Id, + UserId = user.Id, + Amount = 1, + Slot = -1 + }; + dbContext.UserItems.Add(newItem); + } + else + { + item.Amount += 1; + } + user.Handmoney -= shopItem.Price; + dbContext.SaveChanges(); + client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney); + } + + } } } diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index cdc488fa..746b1cbc 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -1,25 +1,23 @@ using System.Collections.Generic; using GTANetworkAPI; using ReallifeGamemode.Server.Shop.Clothing; +using ReallifeGamemode.Server.Shop.SevenEleven; namespace ReallifeGamemode.Server.Managers { public class PositionManager : Script { public static List DutyPoints = new List(); - public static List DutyColShapes = new List(); public static List WeaponPoints = new List(); - public static List WeaponColShapes = new List(); public static List JailReleasePoints = new List(); - public static List JailReleaseColShapes = new List(); public static List ElevatorPoints = new List(); - public static List ElevatorColShapes = new List(); - public static List ShopPoints = new List(); - public static List ShopColShapes = new List(); + public static List clotheshopPoints = new List(); + + public static List itemshopPoints = new List(); [ServerEvent(Event.ResourceStart)] public void OnResourceStart() @@ -154,21 +152,40 @@ namespace ReallifeGamemode.Server.Managers foreach (var shop in ShopManager.clotheStores) { shop.LoadClothes(); - ShopPoint shopPoint = new ShopPoint() + ClotheshopPoint shopPoint = new ClotheshopPoint() { Position = shop.vector, clotheShop = shop }; - ShopPoints.Add(shopPoint); + clotheshopPoints.Add(shopPoint); } - foreach(ShopPoint s in ShopPoints) + foreach(ClotheshopPoint s in clotheshopPoints) { NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1), new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0); NAPI.TextLabel.CreateTextLabel("Kleiderladen - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); } + + foreach(var shop in ShopManager.itemShops) + { + shop.LoadItems(); + ItemshopPoint shopPoint = new ItemshopPoint() + { + Position = shop.vector3, + itemShop = shop + }; + itemshopPoints.Add(shopPoint); + } + + foreach(ItemshopPoint s in itemshopPoints) + { + NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1), + new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0); + NAPI.TextLabel.CreateTextLabel("24/7 - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0); + } + #endregion Shops } @@ -193,13 +210,20 @@ public class JailReleasePoint public Vector3 Position { get; set; } } -public class ShopPoint +public class ClotheshopPoint { public Vector3 Position { get; set; } public ClotheShop clotheShop { get; set; } } +public class ItemshopPoint +{ + public Vector3 Position { get; set; } + public ItemShop itemShop { get; set; } + +} + public class ElevatorPoint { public Vector3 Position { get; set; } diff --git a/ReallifeGamemode.Server/Managers/ShopManager.cs b/ReallifeGamemode.Server/Managers/ShopManager.cs index 24228957..2b5762c7 100644 --- a/ReallifeGamemode.Server/Managers/ShopManager.cs +++ b/ReallifeGamemode.Server/Managers/ShopManager.cs @@ -6,6 +6,7 @@ using GTANetworkAPI; using ReallifeGamemode.Database.Entities.Saves; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Shop.Clothing; +using ReallifeGamemode.Server.Shop.SevenEleven; namespace ReallifeGamemode.Server.Managers { @@ -13,6 +14,7 @@ namespace ReallifeGamemode.Server.Managers { public static List clotheStores = new List(); + public static List itemShops = new List(); public static void LoadClotheShops() { @@ -42,10 +44,26 @@ namespace ReallifeGamemode.Server.Managers 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/VehicleManager.cs b/ReallifeGamemode.Server/Managers/VehicleManager.cs index 0d6ed658..17ed96b7 100644 --- a/ReallifeGamemode.Server/Managers/VehicleManager.cs +++ b/ReallifeGamemode.Server/Managers/VehicleManager.cs @@ -2,9 +2,11 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Util; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using System.Timers; namespace ReallifeGamemode.Server.Managers @@ -862,17 +864,22 @@ namespace ReallifeGamemode.Server.Managers } [ServerEvent(Event.VehicleDeath)] - public static void VehicleManagerVehicleDeath(Vehicle vehicle) + public static async Task VehicleManagerVehicleDeath(Vehicle vehicle) { ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle); + if (serverVehicle == null) { vehicle.Delete(); return; } - - serverVehicle.Spawn(vehicle); + Vehicle newVeh = serverVehicle.Spawn(vehicle); + await Task.Delay(2000); + newVeh.Repair(); + newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading); + } + } } diff --git a/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs b/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs new file mode 100644 index 00000000..2b7aa4c1 --- /dev/null +++ b/ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GTANetworkAPI; +using Newtonsoft.Json; +using ReallifeGamemode.Database.Entities; +using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Inventory.Interfaces; +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) + { + 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(Client 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/VehicleSync.cs b/ReallifeGamemode.Server/Util/VehicleSync.cs index 4ac448af..449da6df 100644 --- a/ReallifeGamemode.Server/Util/VehicleSync.cs +++ b/ReallifeGamemode.Server/Util/VehicleSync.cs @@ -268,6 +268,21 @@ namespace ReallifeGamemode.Server.Util 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(Client player, Vehicle veh, float dirt) @@ -365,6 +380,11 @@ namespace ReallifeGamemode.Server.Util [ServerEvent(Event.PlayerExitVehicleAttempt)] public void VehStreamExitAttempt(Client player, Vehicle veh) { + + if (player.HasData("isDead") && player.GetData("isDead")) + return; + + VehicleSyncData data = GetVehicleSyncData(veh); if (data == default(VehicleSyncData)) data = new VehicleSyncData(); @@ -379,6 +399,9 @@ namespace ReallifeGamemode.Server.Util [ServerEvent(Event.PlayerExitVehicle)] public void VehStreamExit(Client player, Vehicle veh) { + if (player.HasData("isDead") && player.GetData("isDead")) + return; + VehicleSyncData data = GetVehicleSyncData(veh); if (data == default(VehicleSyncData)) data = new VehicleSyncData();