Add ItemShop, fix ClotheShop Payment, fix Vehicle Respawn, Add Vehicle Lock from outside
This commit is contained in:
107
ReallifeGamemode.Client/Interaction/ItemShop.ts
Normal file
107
ReallifeGamemode.Client/Interaction/ItemShop.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
@@ -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 = {
|
||||
|
||||
@@ -186,3 +186,6 @@ gangwarHandle(globalData);
|
||||
|
||||
import clotheShopList from './Interaction/clothes/ClotheShop';
|
||||
clotheShopList(globalData);
|
||||
|
||||
import itemShopList from './Interaction/ItemShop';
|
||||
itemShopList(globalData);
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
21
ReallifeGamemode.Database/Entities/ShopItem.cs
Normal file
21
ReallifeGamemode.Database/Entities/ShopItem.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
1426
ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs
generated
Normal file
1426
ReallifeGamemode.Database/Migrations/20200202153232_ShopItems.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -896,6 +896,24 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
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 =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
||||
@@ -128,5 +128,8 @@ namespace ReallifeGamemode.Database.Models
|
||||
//ClothesShop
|
||||
public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
|
||||
|
||||
//ItemShop
|
||||
public DbSet<Entities.ShopItem> ShopItems { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<bool>("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<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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
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);
|
||||
|
||||
|
||||
@@ -17,5 +17,6 @@ namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
string Description { get; }
|
||||
int Gewicht { get; }
|
||||
string Einheit { get; }
|
||||
int Price { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace ReallifeGamemode.Server
|
||||
|
||||
InventoryManager.LoadItems();
|
||||
ShopManager.LoadClotheShops();
|
||||
|
||||
ShopManager.LoadItemShops();
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DutyPoint> DutyPoints = new List<DutyPoint>();
|
||||
public static List<ColShape> DutyColShapes = new List<ColShape>();
|
||||
|
||||
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<ColShape> JailReleaseColShapes = new List<ColShape>();
|
||||
|
||||
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<ColShape> ShopColShapes = new List<ColShape>();
|
||||
public static List<ClotheshopPoint> clotheshopPoints = new List<ClotheshopPoint>();
|
||||
|
||||
public static List<ItemshopPoint> itemshopPoints = new List<ItemshopPoint>();
|
||||
|
||||
[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; }
|
||||
|
||||
@@ -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<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
@@ -42,7 +44,23 @@ 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<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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Vehicle newVeh = serverVehicle.Spawn(vehicle);
|
||||
await Task.Delay(2000);
|
||||
newVeh.Repair();
|
||||
newVeh.Rotation = new Vector3(0, 0, serverVehicle.Heading);
|
||||
|
||||
serverVehicle.Spawn(vehicle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
44
ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs
Normal file
44
ReallifeGamemode.Server/Shop/SevenEleven/ItemShop.cs
Normal 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user