Merge Ammunation in Develop
This commit is contained in:
89
ReallifeGamemode.Client/Interaction/ammunation/ammunation.ts
Normal file
89
ReallifeGamemode.Client/Interaction/ammunation/ammunation.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import * as NativeUI from '../../libs/NativeUI';
|
||||
|
||||
const Menu = NativeUI.Menu;
|
||||
const MenuItem = NativeUI.UIMenuItem;
|
||||
const MenuListItem = NativeUI.UIMenuListItem;
|
||||
const MenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
|
||||
export default function ammunation(globalData: IGlobalData) {
|
||||
|
||||
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
var weapons: Weapon[];
|
||||
|
||||
mp.events.add("AmmunationShop:LoadNativeUI", (weaponList: string) => {
|
||||
|
||||
weapons = JSON.parse(weaponList);
|
||||
var menu = getAmmunationMenu();
|
||||
|
||||
//Schaut nach ob mindestens eine Waffe in weapons existiert welche die CategoryId beinhaltet
|
||||
for (var c = 1; c < 10; c++) {
|
||||
switch (c) {
|
||||
case 1: { //Meelee
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: { //Pistolen
|
||||
if (weapons.find(w => w.CategoryId == c)) {
|
||||
var pistolItem = new MenuItem("Pistolen", "Das kleine Kaliber",);
|
||||
menu.AddItem(pistolItem);
|
||||
menu.BindMenuToItem(getWeaponsFromCategory(menu, c, "Pistolen"),pistolItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*case 9: { //Sonstiges (Armor / Fallschirm)
|
||||
var otherItem = new MenuItem("Sonstiges", "Schutzwesten, Fallschirme...",);
|
||||
menu.AddItem(otherItem);
|
||||
menu.BindMenuToItem(getWeaponsFromCategory(menu, c, "Sonstiges"), otherItem);
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
menu.Open();
|
||||
mp.gui.chat.activate(false);
|
||||
globalData.InMenu = true;
|
||||
|
||||
menu.MenuClose.on(() => {
|
||||
globalData.InMenu = false;
|
||||
mp.gui.chat.show(true);
|
||||
})
|
||||
});
|
||||
|
||||
function getAmmunationMenu(): NativeUI.Menu {
|
||||
return new Menu("", "AMMU NATION - Waffenladen", new Point(0, screenRes.y / 3), "shopui_title_gunclub", "shopui_title_gunclub");
|
||||
}
|
||||
|
||||
function getWeaponsFromCategory(parentMenu: NativeUI.Menu, category: number, categoryName: string): NativeUI.Menu {
|
||||
var categoryMenu = new Menu("", categoryName, new Point(0, screenRes.y / 3), "shopui_title_gunclub", "shopui_title_gunclub");
|
||||
|
||||
categoryMenu.Visible = false;
|
||||
|
||||
var cWeapons: Weapon[] = weapons.filter(w => w.CategoryId == category);
|
||||
|
||||
if (category < 9) { //Weapons aus Datenbank
|
||||
cWeapons.forEach(weapon => {
|
||||
var weaponItem: NativeUI.UIMenuItem = new MenuItem(weapon.WeaponModel, "Du erhältst " + weapon.Ammo + " Munition", [weapon.WeaponModel, weapon.Ammo, weapon.Price]);
|
||||
categoryMenu.AddItem(weaponItem);
|
||||
weaponItem.SetRightLabel("~g~$" + weapon.Price.toString());
|
||||
})
|
||||
} else { //Sonstiges = Schutzwesten / Fallschirme
|
||||
var armorItem = new MenuItem("Schutzweste", "Sch\u00fctzt dich","armor",);
|
||||
categoryMenu.AddItem(armorItem);
|
||||
armorItem.SetRightLabel("~g~$3000");
|
||||
|
||||
var parachuteItem = new MenuItem("Fallschirm", "Flieg damit wohin du willst");
|
||||
categoryMenu.AddItem(parachuteItem);
|
||||
parachuteItem.SetRightLabel("~g~$500");
|
||||
}
|
||||
|
||||
categoryMenu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
|
||||
mp.events.callRemote("CLIENT:Ammunation_BuyWeapon", item.Data[0], item.Data[1], item.Data[2]); //weaponmodel / ammo / price
|
||||
});
|
||||
|
||||
return categoryMenu;
|
||||
};
|
||||
};
|
||||
13
ReallifeGamemode.Client/global.d.ts
vendored
13
ReallifeGamemode.Client/global.d.ts
vendored
@@ -75,4 +75,17 @@ declare type FactionMember = {
|
||||
|
||||
declare type FactionRank = {
|
||||
|
||||
}
|
||||
|
||||
declare type Weapon = {
|
||||
WeaponModel: string;
|
||||
CategoryId: number;
|
||||
SlotID: number;
|
||||
Ammo: number;
|
||||
Price: number;
|
||||
}
|
||||
|
||||
declare type WeaponCategory = {
|
||||
Category: number;
|
||||
Weapons: Weapon[];
|
||||
}
|
||||
@@ -262,6 +262,9 @@ antiCheat(globalData);
|
||||
import antiAfk from './Player/antiafk';
|
||||
antiAfk(globalData);
|
||||
|
||||
import ammunation from './Interaction/ammunation/ammunation';
|
||||
ammunation(globalData);
|
||||
|
||||
require('./Gui/policedepartment');
|
||||
require('./Gui/helptext');
|
||||
|
||||
|
||||
25
ReallifeGamemode.Database/Entities/UserWeapon.cs
Normal file
25
ReallifeGamemode.Database/Entities/UserWeapon.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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 UserWeapon
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
[ForeignKey("Weapon")]
|
||||
public int WeaponId { get; set; }
|
||||
public Weapon Weapon { get; set; }
|
||||
|
||||
public int Ammo { get; set; }
|
||||
}
|
||||
}
|
||||
26
ReallifeGamemode.Database/Entities/Weapon.cs
Normal file
26
ReallifeGamemode.Database/Entities/Weapon.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Database.Entities
|
||||
{
|
||||
public partial class Weapon
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string WeaponModel { get; set; }
|
||||
[ForeignKey("WeaponCategory")]
|
||||
public int CategoryId { get; set; }
|
||||
public WeaponCategory WeaponCategory { get; set; }
|
||||
public int SlotID { get; set; }
|
||||
public int Ammo { get; set; }
|
||||
public float Price { get; set; }
|
||||
|
||||
public bool Legal { get; set; }
|
||||
public bool AmmunationActive { get; set; }
|
||||
}
|
||||
}
|
||||
17
ReallifeGamemode.Database/Entities/WeaponCategory.cs
Normal file
17
ReallifeGamemode.Database/Entities/WeaponCategory.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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 WeaponCategory
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string Category { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
1975
ReallifeGamemode.Database/Migrations/20210413201146_Ammunations.Designer.cs
generated
Normal file
1975
ReallifeGamemode.Database/Migrations/20210413201146_Ammunations.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,101 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Database.Migrations
|
||||
{
|
||||
public partial class Ammunations : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WeaponCategories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Category = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WeaponCategories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Weapons",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
WeaponModel = table.Column<string>(nullable: true),
|
||||
CategoryId = table.Column<int>(nullable: false),
|
||||
SlotID = table.Column<int>(nullable: false),
|
||||
Ammo = table.Column<int>(nullable: false),
|
||||
Price = table.Column<float>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Weapons", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Weapons_WeaponCategories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "WeaponCategories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "UserWeapons",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
UserId = table.Column<int>(nullable: false),
|
||||
WeaponId = table.Column<int>(nullable: false),
|
||||
Ammo = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_UserWeapons", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserWeapons_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_UserWeapons_Weapons_WeaponId",
|
||||
column: x => x.WeaponId,
|
||||
principalTable: "Weapons",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserWeapons_UserId",
|
||||
table: "UserWeapons",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_UserWeapons_WeaponId",
|
||||
table: "UserWeapons",
|
||||
column: "WeaponId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Weapons_CategoryId",
|
||||
table: "Weapons",
|
||||
column: "CategoryId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "UserWeapons");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Weapons");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "WeaponCategories");
|
||||
}
|
||||
}
|
||||
}
|
||||
1981
ReallifeGamemode.Database/Migrations/20210416175726_Ammunations2.Designer.cs
generated
Normal file
1981
ReallifeGamemode.Database/Migrations/20210416175726_Ammunations2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Database.Migrations
|
||||
{
|
||||
public partial class Ammunations2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "AmmunationActive",
|
||||
table: "Weapons",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Legal",
|
||||
table: "Weapons",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AmmunationActive",
|
||||
table: "Weapons");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Legal",
|
||||
table: "Weapons");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1519,6 +1519,30 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.ToTable("UserItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserWeapon", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Ammo")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("WeaponId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.HasIndex("WeaponId");
|
||||
|
||||
b.ToTable("UserWeapons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -1567,6 +1591,54 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
b.ToTable("VehicleMods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Weapon", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Ammo")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("AmmunationActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("Legal")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<float>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("SlotID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("WeaponModel")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Weapons");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.WeaponCategory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Category")
|
||||
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WeaponCategories");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Whitelist", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -1844,6 +1916,21 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.UserWeapon", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.Weapon", "Weapon")
|
||||
.WithMany()
|
||||
.HasForeignKey("WeaponId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.VehicleItem", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.ServerVehicle", "Vehicle")
|
||||
@@ -1862,6 +1949,15 @@ namespace ReallifeGamemode.Database.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Weapon", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.WeaponCategory", "WeaponCategory")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.GroupVehicle", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Database.Entities.Group", "Group")
|
||||
|
||||
@@ -74,6 +74,8 @@ namespace ReallifeGamemode.Database.Models
|
||||
public DbSet<Entities.UserVehicle> UserVehicles { get; set; }
|
||||
public DbSet<Entities.UserBankAccount> UserBankAccounts { get; set; }
|
||||
|
||||
public DbSet<Entities.UserWeapon> UserWeapons { get; set; }
|
||||
|
||||
|
||||
//Inventar
|
||||
public DbSet<Entities.UserItem> UserItems { get; set; }
|
||||
@@ -85,8 +87,13 @@ namespace ReallifeGamemode.Database.Models
|
||||
public DbSet<Entities.FactionVehicle> FactionVehicles { get; set; }
|
||||
|
||||
//Shops
|
||||
public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
|
||||
public DbSet<Entities.ShopItem> ShopItems { get; set; }
|
||||
public DbSet<Entities.Weapon> Weapons { get; set; }
|
||||
public DbSet<Entities.WeaponCategory> WeaponCategories { get; set; }
|
||||
|
||||
//Logs
|
||||
|
||||
//public DbSet<Logs.Ban> BanLogs { get; set; }
|
||||
public DbSet<Entities.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
|
||||
public DbSet<Entities.Logs.Death> DeathLogs { get; set; }
|
||||
@@ -155,12 +162,6 @@ namespace ReallifeGamemode.Database.Models
|
||||
//Gangwar
|
||||
public DbSet<Entities.Turfs> Turfs { get; set; }
|
||||
|
||||
//ClothesShop
|
||||
public DbSet<Entities.ShopClothe> ShopClothes { get; set; }
|
||||
|
||||
//ItemShop
|
||||
public DbSet<Entities.ShopItem> ShopItems { get; set; }
|
||||
|
||||
//Server Variablen
|
||||
public DbSet<Entities.ServerVariable> ServerVariables { get; set; }
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -235,6 +235,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6);
|
||||
Player nearestCuffPlayer = PositionManager.cuffPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6 && user.GetData<bool>("duty"));
|
||||
AmmunationPoint nearestAmmunationPoint = PositionManager.AmmunationPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
@@ -516,6 +517,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
nearestFriseurPoint.friseurShop.LoadShopNUI(player);
|
||||
}
|
||||
if (nearestAmmunationPoint != null)
|
||||
{
|
||||
if (!user.WeaponLicense)
|
||||
{
|
||||
player.SendNotification("~r~Du besitzt keinen Waffenschein");
|
||||
}
|
||||
else
|
||||
{
|
||||
nearestAmmunationPoint.Ammunation.LoadShopNUI(player);
|
||||
}
|
||||
}
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:StartGangwar");
|
||||
|
||||
@@ -118,5 +118,24 @@ namespace ReallifeGamemode.Server.Events
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Ammunation_BuyWeapon")]
|
||||
public void AmmunationBuyWeapoon(Player player, string weaponmodel, int ammo, int price)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
if (user.Handmoney < price)
|
||||
{
|
||||
player.SendNotification("Du hast nicht genügend Geld bei dir");
|
||||
return;
|
||||
}
|
||||
user.Handmoney -= price;
|
||||
dbContext.SaveChanges();
|
||||
player.GiveWeapon(NAPI.Util.WeaponNameToModel(weaponmodel), ammo);
|
||||
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace ReallifeGamemode.Server
|
||||
ShopManager.LoadClotheShops();
|
||||
ShopManager.LoadItemShops();
|
||||
ShopManager.LoadFriseur();
|
||||
ShopManager.LoadAmmunations();
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
|
||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
using ReallifeGamemode.Server.Shop.Friseur;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Shop.Ammunation;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -29,6 +30,8 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static List<Player> cuffPoints = new List<Player>();
|
||||
|
||||
public static List<AmmunationPoint> AmmunationPoints = new List<AmmunationPoint>();
|
||||
|
||||
public static void LoadPositionManager()
|
||||
{
|
||||
#region DutyPoints
|
||||
@@ -280,6 +283,20 @@ namespace ReallifeGamemode.Server.Managers
|
||||
NAPI.TextLabel.CreateTextLabel("24/7 - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
|
||||
foreach (Ammunation s in ShopManager.Ammunations)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(s.vector.X, s.vector.Y, s.vector.Z - 2), new Vector3(s.vector.X, s.vector.Y, s.vector.Z + 1),
|
||||
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Ammunation - Dr\u00fccke ~y~E", s.vector, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
|
||||
AmmunationPoint ammuShop = new AmmunationPoint
|
||||
{
|
||||
Position = s.vector,
|
||||
Ammunation = s
|
||||
};
|
||||
AmmunationPoints.Add(ammuShop);
|
||||
}
|
||||
|
||||
#endregion Shops
|
||||
}
|
||||
|
||||
@@ -407,3 +424,9 @@ public class ElevatorPoint
|
||||
public int FactionId { get; set; }
|
||||
public string Stage { get; set; }
|
||||
}
|
||||
|
||||
public class AmmunationPoint
|
||||
{
|
||||
public Vector3 Position { get; set; }
|
||||
public Ammunation Ammunation { get; set; }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Shop.Clothing;
|
||||
using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
using ReallifeGamemode.Server.Shop.Friseur;
|
||||
using ReallifeGamemode.Server.Shop.Ammunation;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
@@ -14,6 +15,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
public static List<Friseur> FriseurStores = new List<Friseur>();
|
||||
public static List<Ammunation> Ammunations = new List<Ammunation>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
@@ -81,5 +83,20 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAmmunations()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<SavedBlip> ammunations = dbContext.Blips.ToList().FindAll(s => s.Name == "Ammunation");
|
||||
|
||||
foreach (var store in ammunations)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
Ammunation newShop = new Ammunation(pos);
|
||||
Ammunations.Add(newShop);
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loading {ammunations.Count} Ammunations");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
ReallifeGamemode.Server/Shop/Ammunation/Ammunation.cs
Normal file
40
ReallifeGamemode.Server/Shop/Ammunation/Ammunation.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Ammunation
|
||||
{
|
||||
public class Ammunation
|
||||
{
|
||||
public Vector3 vector { get; set; }
|
||||
public List<Weapon> weaponList = new List<Weapon>();
|
||||
|
||||
public Ammunation(Vector3 position)
|
||||
{
|
||||
this.vector = position;
|
||||
LoadWeapons();
|
||||
}
|
||||
|
||||
public void LoadWeapons()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
weaponList = dbContext.Weapons.ToList().FindAll(w => w.AmmunationActive == true);
|
||||
}
|
||||
}
|
||||
public void LoadShopNUI(Player client)
|
||||
{
|
||||
|
||||
List<Weapon> shopWeapons = weaponList.ToList();
|
||||
client.TriggerEvent("AmmunationShop:LoadNativeUI", JsonConvert.SerializeObject(shopWeapons));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user