Files
reallife-gamemode/ReallifeGamemode.Server/Shop/Ammunation/Ammunation.cs
2021-04-13 21:46:11 +02:00

58 lines
1.9 KiB
C#

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;
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 = vector;
LoadWeapons();
}
public void LoadWeapons()
{
using (var dbContext = new DatabaseContext())
{
weaponList = dbContext.Weapons.ToList();
}
}
public void LoadShopNUI(Player client)
{
User u = client.GetUser();
if (u == null)
{
return;
}
//List<Weapon> melee = weaponList.ToList().FindAll(w => w.Category == "Nahkampfwaffen");
List<Weapon> handguns = weaponList.ToList().FindAll(w => w.Category == "Pistolen");
//List<Weapon> smgs = weaponList.ToList().FindAll(w => w.Category == "Maschinenpistolen");
//List<Weapon> shotguns = weaponList.ToList().FindAll(w => w.Category == "Schrotflinten");
//List<Weapon> assaultrifles = weaponList.ToList().FindAll(w => w.Category == "Sturmgewehre");
//List<Weapon> lmgs = weaponList.ToList().FindAll(w => w.Category == "Leichte Maschinengewehre");
//List<Weapon> sniperrifles = weaponList.ToList().FindAll(w => w.Category == "Scharfschützengewehre");
//List<Weapon> heavyweapons = weaponList.ToList().FindAll(w => w.Category == "Schwere Waffen");
//List<Weapon> throwables = weaponList.ToList().FindAll(w => w.Category == "Werfbare Waffen");
List<Array> shopWeapons = new List<Array>
{
handguns.ToArray(),
};
client.TriggerEvent("AmmunationShop:LoadNativeUI", JsonConvert.SerializeObject(shopWeapons));
}
}
}