Add ItemShop, fix ClotheShop Payment, fix Vehicle Respawn, Add Vehicle Lock from outside

This commit is contained in:
Siga
2020-02-03 18:13:10 +01:00
parent be6ef1cf1c
commit 154b0ca0fe
42 changed files with 1920 additions and 50 deletions

View File

@@ -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);
});
}

View File

@@ -16,14 +16,6 @@ const Point = NativeUI.Point;
const ItemsCollection = NativeUI.ItemsCollection; const ItemsCollection = NativeUI.ItemsCollection;
const Color = NativeUI.Color; 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) { export default function clotheShopList(globalData: GlobalData) {
const categoryTitles = { const categoryTitles = {

View File

@@ -185,4 +185,7 @@ import gangwarHandle from './util/Gangwar';
gangwarHandle(globalData); gangwarHandle(globalData);
import clotheShopList from './Interaction/clothes/ClotheShop'; import clotheShopList from './Interaction/clothes/ClotheShop';
clotheShopList(globalData); clotheShopList(globalData);
import itemShopList from './Interaction/ItemShop';
itemShopList(globalData);

View File

@@ -21,23 +21,27 @@ export default function inventory(globalData: GlobalData): void {
mp.events.add('showVehInventory', () => { mp.events.add('showVehInventory', () => {
invBrowser.execute(`execVehInv();`); invBrowser.execute(`execVehInv();`);
}); });
var open = false;
mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => { mp.events.add('inventoryShow', (iWeight, iNameArr, iAmountArr, iIdArr, playersArr) => {
if (!globalData.InMenu) {
if (invBrowser === null) { if (invBrowser === null) {
mp.gui.cursor.show(true, true); if (!globalData.InMenu) {
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html'); globalData.InMenu = true;
Players = playersArr; mp.gui.cursor.show(true, true);
itemIdArr = iIdArr; invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
itemAmountArr = iAmountArr; Players = playersArr;
itemNameArr = iNameArr; itemIdArr = iIdArr;
invWeight = iWeight; itemAmountArr = iAmountArr;
itemNameArr = iNameArr;
invWeight = iWeight;
}
} else { } else {
try { try {
invBrowser.destroy() invBrowser.destroy()
invBrowser = null; invBrowser = null;
globalData.InMenu = false;
} }
finally { finally {
mp.gui.cursor.show(false, false); mp.gui.cursor.show(false, false);
@@ -45,7 +49,6 @@ export default function inventory(globalData: GlobalData): void {
return; return;
} }
}
}); });
var offer = 0; var offer = 0;

View File

@@ -33,6 +33,7 @@ export default function vehicleSync() {
var toggle = entity.getVariable("VehicleSyncData"); var toggle = entity.getVariable("VehicleSyncData");
entity.setEngineOn(toggle.Engine, false, true); entity.setEngineOn(toggle.Engine, false, true);
entity.setUndriveable(!toggle.Engine); entity.setUndriveable(!toggle.Engine);
entity.setInvincible(false);
} }
}); });
@@ -44,7 +45,6 @@ export default function vehicleSync() {
entity.setEngineOn(toggle.Engine, true, false); entity.setEngineOn(toggle.Engine, true, false);
entity.setUndriveable(!toggle.Engine); entity.setUndriveable(!toggle.Engine);
} }
var level = entity.getDirtLevel(); var level = entity.getDirtLevel();
mp.events.callRemote("VehStream_SetDirtLevel", entity, level); mp.events.callRemote("VehStream_SetDirtLevel", entity, level);
} }
@@ -548,4 +548,13 @@ export default function vehicleSync() {
}, 1500); }, 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);
}
});
} }

View File

@@ -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; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -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<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ShopId = table.Column<int>(nullable: false),
ItemId = table.Column<int>(nullable: false),
Amount = table.Column<int>(nullable: false),
Price = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShopItems", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ShopItems");
}
}
}

View File

@@ -896,6 +896,24 @@ namespace ReallifeGamemode.Database.Migrations
b.ToTable("ShopClothes"); b.ToTable("ShopClothes");
}); });
modelBuilder.Entity("ReallifeGamemode.Database.Entities.ShopItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Amount");
b.Property<int>("ItemId");
b.Property<int>("Price");
b.Property<int>("ShopId");
b.HasKey("Id");
b.ToTable("ShopItems");
});
modelBuilder.Entity("ReallifeGamemode.Database.Entities.TuningGarage", b => modelBuilder.Entity("ReallifeGamemode.Database.Entities.TuningGarage", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")

View File

@@ -128,5 +128,8 @@ namespace ReallifeGamemode.Database.Models
//ClothesShop //ClothesShop
public DbSet<Entities.ShopClothe> ShopClothes { get; set; } public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
//ItemShop
public DbSet<Entities.ShopItem> ShopItems { get; set; }
} }
} }

View File

@@ -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); 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<bool>("duty")); JailReleasePoint nearestJailReleasePoint = PositionManager.JailReleasePoints.Find(j => j.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3) && user.GetData<bool>("duty"));
ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3)); 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<bool>("duty"))); ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty")));
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
if (nearestDuty != null)// Duty Point if (nearestDuty != null)// Duty Point
{ {
var nameTagColor = new Color(0, 0, 0); var nameTagColor = new Color(0, 0, 0);
@@ -326,9 +328,13 @@ namespace ReallifeGamemode.Server.Events
} }
player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray())); 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) if (user.FactionLeader)
{ {
@@ -481,6 +487,9 @@ namespace ReallifeGamemode.Server.Events
if (!player.IsInVehicle) if (!player.IsInVehicle)
{ {
Vehicle.VehicleMenuLockCarEvent(player);
GroundItem.PickUpGroundItem(player); GroundItem.PickUpGroundItem(player);
} }

View File

@@ -115,7 +115,7 @@ namespace ReallifeGamemode.Server.Events
{ {
CharacterCreator.ApplyCharacter(player); CharacterCreator.ApplyCharacter(player);
UpdateCharacterCloth.LoadCharacterDefaults(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); NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
} }

View File

@@ -251,9 +251,10 @@ namespace ReallifeGamemode.Server.Events
undershirt.Texture = data[5]; undershirt.Texture = data[5];
} }
} }
user.Handmoney -= data[6]; client.GetUser(dbContext).Handmoney -= data[6];
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
dbContext.SaveChanges(); dbContext.SaveChanges();
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
} }
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]); client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
} }

View File

@@ -65,7 +65,7 @@ namespace ReallifeGamemode.Server.Events
} }
[RemoteEvent("VehicleMenu_LockCar")] [RemoteEvent("VehicleMenu_LockCar")]
public void VehicleMenuLockCarEvent(Client player) public static void VehicleMenuLockCarEvent(Client player)
{ {
if (player.IsInVehicle && player.VehicleSeat == -1) if (player.IsInVehicle && player.VehicleSeat == -1)
{ {
@@ -98,13 +98,80 @@ namespace ReallifeGamemode.Server.Events
return; return;
} }
} }
else if(sV is JobVehicle)
{
return;
}
else if (sV is SchoolVehicle)
{
return;
}
} }
state = !state; state = !state;
VehicleStreaming.SetLockStatus(v, state); VehicleStreaming.SetLockStatus(v, state);
string msg = "Fahrzeug "; string msg = "Fahrzeug ";
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen"; msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
player.TriggerEvent("vehsync:OpenCar", state);
player.SendNotification(msg); 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")] [RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
@@ -147,6 +214,16 @@ namespace ReallifeGamemode.Server.Events
return; 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; Vector3 pos = v.Position;
@@ -199,10 +276,6 @@ namespace ReallifeGamemode.Server.Events
} }
} }
[ServerEvent(Event.VehicleDeath)]
public void VehicleDeathEvent(GTANetworkAPI.Vehicle veh)
{
}
} }
} }

View File

@@ -27,10 +27,11 @@ namespace ReallifeGamemode.Server.Extensions
int c1 = veh.PrimaryColor; int c1 = veh.PrimaryColor;
int c2 = veh.SecondaryColor; int c2 = veh.SecondaryColor;
Vehicle newVeh = NAPI.Vehicle.CreateVehicle(model, position, heading, c1, c2, "", 255, false, false); 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.SetEngineState(newVeh, false);
VehicleStreaming.SetLockStatus(newVeh, veh.Locked); VehicleStreaming.SetLockStatus(newVeh, veh.Locked);
VehicleManager.AddVehicle(veh, newVeh); VehicleManager.AddVehicle(veh, newVeh);
newVeh.Rotation = new Vector3(0,0,heading);
newVeh.SetSharedData("drivenDistance", veh.DistanceDriven); newVeh.SetSharedData("drivenDistance", veh.DistanceDriven);

View File

@@ -17,5 +17,6 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces
string Description { get; } string Description { get; }
int Gewicht { get; } int Gewicht { get; }
string Einheit { get; } string Einheit { get; }
int Price { get; }
} }
} }

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public int Gewicht => 50; public int Gewicht => 50;
public string Einheit => "g"; public string Einheit => "g";
public uint Object => 3076948544; public uint Object => 3076948544;
public int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 4000; public override int Gewicht => 4000;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -20,5 +20,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 2240524752; public override uint Object => 2240524752;
public override int Price => 150;
} }
} }

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 25; public override int HpAmount => 25;
public override uint Object => 2240524752; public override uint Object => 2240524752;
public override int Price => 0;
} }
} }

View File

@@ -18,6 +18,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public abstract int Gewicht { get; } public abstract int Gewicht { get; }
public abstract string Einheit { get; } public abstract string Einheit { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; }
public void Drop(UserItem uItem, Client player, int amount) public void Drop(UserItem uItem, Client player, int amount)
{ {

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -18,6 +18,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public abstract int Gewicht { get; } public abstract int Gewicht { get; }
public abstract string Einheit { get; } public abstract string Einheit { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; }
public void Use(UserItem uItem) public void Use(UserItem uItem)
{ {

View File

@@ -1,7 +1,4 @@
using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.Inventory.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
/** /**
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs) * @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
@@ -19,5 +16,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public int Gewicht => 650; public int Gewicht => 650;
public string Einheit => "g"; public string Einheit => "g";
public uint Object => 1805779401; public uint Object => 1805779401;
public int Price => 0;
} }
} }

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 1180; public override int Gewicht => 1180;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 3600; public override int Gewicht => 3600;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 3080; public override int Gewicht => 3080;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 3000; public override int Gewicht => 3000;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -19,5 +19,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override int Gewicht => 12900; public override int Gewicht => 12900;
public override string Einheit => "g"; public override string Einheit => "g";
public override uint Object => 3666746839; //3061944032 public override uint Object => 3666746839; //3061944032
public override int Price => 0;
} }
} }

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -17,6 +17,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
public abstract int Gewicht { get; } public abstract int Gewicht { get; }
public abstract string Einheit { get; } public abstract string Einheit { get; }
public abstract uint Object { get; } public abstract uint Object { get; }
public abstract int Price { get; }
public bool noTransfer(Client client, UserItem uItem, FactionVehicle fVeh) public bool noTransfer(Client client, UserItem uItem, FactionVehicle fVeh)
{ {

View File

@@ -20,5 +20,6 @@ namespace ReallifeGamemode.Server.Inventory.Items
public override string Einheit => "g"; public override string Einheit => "g";
public override int HpAmount => 20; public override int HpAmount => 20;
public override uint Object => 786272259; public override uint Object => 786272259;
public override int Price => 0;
} }
} }

View File

@@ -45,7 +45,7 @@ namespace ReallifeGamemode.Server
InventoryManager.LoadItems(); InventoryManager.LoadItems();
ShopManager.LoadClotheShops(); ShopManager.LoadClotheShops();
ShopManager.LoadItemShops();
TuningManager.LoadTuningGarages(); TuningManager.LoadTuningGarages();
TimeManager.StartTimeManager(); TimeManager.StartTimeManager();

View File

@@ -863,5 +863,42 @@ namespace ReallifeGamemode.Server.Managers
ChatService.SendMessage(target, $"{client.Name} hat deine Anfrage angenommen."); 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);
}
}
} }
} }

View File

@@ -1,25 +1,23 @@
using System.Collections.Generic; using System.Collections.Generic;
using GTANetworkAPI; using GTANetworkAPI;
using ReallifeGamemode.Server.Shop.Clothing; using ReallifeGamemode.Server.Shop.Clothing;
using ReallifeGamemode.Server.Shop.SevenEleven;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
{ {
public class PositionManager : Script public class PositionManager : Script
{ {
public static List<DutyPoint> DutyPoints = new List<DutyPoint>(); public static List<DutyPoint> DutyPoints = new List<DutyPoint>();
public static List<ColShape> DutyColShapes = new List<ColShape>();
public static List<WeaponPoint> WeaponPoints = new List<WeaponPoint>(); public static List<WeaponPoint> WeaponPoints = new List<WeaponPoint>();
public static List<ColShape> WeaponColShapes = new List<ColShape>();
public static List<JailReleasePoint> JailReleasePoints = new List<JailReleasePoint>(); public static List<JailReleasePoint> JailReleasePoints = new List<JailReleasePoint>();
public static List<ColShape> JailReleaseColShapes = new List<ColShape>();
public static List<ElevatorPoint> ElevatorPoints = new List<ElevatorPoint>(); public static List<ElevatorPoint> ElevatorPoints = new List<ElevatorPoint>();
public static List<ColShape> ElevatorColShapes = new List<ColShape>();
public static List<ShopPoint> ShopPoints = new List<ShopPoint>(); public static List<ClotheshopPoint> clotheshopPoints = new List<ClotheshopPoint>();
public static List<ColShape> ShopColShapes = new List<ColShape>();
public static List<ItemshopPoint> itemshopPoints = new List<ItemshopPoint>();
[ServerEvent(Event.ResourceStart)] [ServerEvent(Event.ResourceStart)]
public void OnResourceStart() public void OnResourceStart()
@@ -154,21 +152,40 @@ namespace ReallifeGamemode.Server.Managers
foreach (var shop in ShopManager.clotheStores) foreach (var shop in ShopManager.clotheStores)
{ {
shop.LoadClothes(); shop.LoadClothes();
ShopPoint shopPoint = new ShopPoint() ClotheshopPoint shopPoint = new ClotheshopPoint()
{ {
Position = shop.vector, Position = shop.vector,
clotheShop = shop 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), 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); 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); 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 #endregion Shops
} }
@@ -193,13 +210,20 @@ public class JailReleasePoint
public Vector3 Position { get; set; } public Vector3 Position { get; set; }
} }
public class ShopPoint public class ClotheshopPoint
{ {
public Vector3 Position { get; set; } public Vector3 Position { get; set; }
public ClotheShop clotheShop { get; set; } public ClotheShop clotheShop { get; set; }
} }
public class ItemshopPoint
{
public Vector3 Position { get; set; }
public ItemShop itemShop { get; set; }
}
public class ElevatorPoint public class ElevatorPoint
{ {
public Vector3 Position { get; set; } public Vector3 Position { get; set; }

View File

@@ -6,6 +6,7 @@ using GTANetworkAPI;
using ReallifeGamemode.Database.Entities.Saves; using ReallifeGamemode.Database.Entities.Saves;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Shop.Clothing; using ReallifeGamemode.Server.Shop.Clothing;
using ReallifeGamemode.Server.Shop.SevenEleven;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
{ {
@@ -13,6 +14,7 @@ namespace ReallifeGamemode.Server.Managers
{ {
public static List<ClotheShop> clotheStores = new List<ClotheShop>(); public static List<ClotheShop> clotheStores = new List<ClotheShop>();
public static List<ItemShop> itemShops = new List<ItemShop>();
public static void LoadClotheShops() public static void LoadClotheShops()
{ {
@@ -42,10 +44,26 @@ namespace ReallifeGamemode.Server.Managers
clotheStores.Add(newShop); clotheStores.Add(newShop);
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}"); NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
} }
} }
} }
public static void LoadItemShops()
{
using(var dbContext = new DatabaseContext())
{
int id = 0;
List<SavedBlip> 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");
}
}
} }
} }

View File

@@ -2,9 +2,11 @@
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Timers; using System.Timers;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
@@ -862,17 +864,22 @@ namespace ReallifeGamemode.Server.Managers
} }
[ServerEvent(Event.VehicleDeath)] [ServerEvent(Event.VehicleDeath)]
public static void VehicleManagerVehicleDeath(Vehicle vehicle) public static async Task VehicleManagerVehicleDeath(Vehicle vehicle)
{ {
ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle); ServerVehicle serverVehicle = GetServerVehicleFromVehicle(vehicle);
if (serverVehicle == null) if (serverVehicle == null)
{ {
vehicle.Delete(); vehicle.Delete();
return; return;
} }
Vehicle newVeh = serverVehicle.Spawn(vehicle);
serverVehicle.Spawn(vehicle); await Task.Delay(2000);
newVeh.Repair();
newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading);
} }
} }
} }

View File

@@ -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<ShopItem> shopItems = new List<ShopItem>();
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<ShopItem> itemList = shopItems.ToList().FindAll(s => s.Amount > 0);
List<IItem> items = new List<IItem>();
foreach(var item in itemList)
{
items.Add(InventoryManager.GetItemById(item.ItemId));
}
client.TriggerEvent("itemMenu:updateData", JsonConvert.SerializeObject(items.ToArray()));
}
}
}

View File

@@ -268,6 +268,21 @@ namespace ReallifeGamemode.Server.Util
return false; 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 //Called from the client to sync dirt level
[RemoteEvent("VehStream_SetDirtLevel")] [RemoteEvent("VehStream_SetDirtLevel")]
public void VehStreamSetDirtLevel(Client player, Vehicle veh, float dirt) public void VehStreamSetDirtLevel(Client player, Vehicle veh, float dirt)
@@ -365,6 +380,11 @@ namespace ReallifeGamemode.Server.Util
[ServerEvent(Event.PlayerExitVehicleAttempt)] [ServerEvent(Event.PlayerExitVehicleAttempt)]
public void VehStreamExitAttempt(Client player, Vehicle veh) public void VehStreamExitAttempt(Client player, Vehicle veh)
{ {
if (player.HasData("isDead") && player.GetData("isDead"))
return;
VehicleSyncData data = GetVehicleSyncData(veh); VehicleSyncData data = GetVehicleSyncData(veh);
if (data == default(VehicleSyncData)) if (data == default(VehicleSyncData))
data = new VehicleSyncData(); data = new VehicleSyncData();
@@ -379,6 +399,9 @@ namespace ReallifeGamemode.Server.Util
[ServerEvent(Event.PlayerExitVehicle)] [ServerEvent(Event.PlayerExitVehicle)]
public void VehStreamExit(Client player, Vehicle veh) public void VehStreamExit(Client player, Vehicle veh)
{ {
if (player.HasData("isDead") && player.GetData("isDead"))
return;
VehicleSyncData data = GetVehicleSyncData(veh); VehicleSyncData data = GetVehicleSyncData(veh);
if (data == default(VehicleSyncData)) if (data == default(VehicleSyncData))
data = new VehicleSyncData(); data = new VehicleSyncData();