Files
reallife-gamemode/ReallifeGamemode.Server/Shop/Clothing/ClotheShop.cs
michael.reiswich b8815f79e9 add friseur
2021-01-25 14:17:57 +01:00

62 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Newtonsoft.Json;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
namespace ReallifeGamemode.Server.Shop.Clothing
{
public class ClotheShop
{
public int category { get; set; }
public Vector3 vector { get; set; }
public List<ShopClothe> clotheList = new List<ShopClothe>();
public ClotheShop(int category, Vector3 vector)
{
this.category = category;
this.vector = vector;
LoadClothes();
}
public void LoadClothes()
{
using (var dbContext = new DatabaseContext())
{
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
}
}
public void LoadShopNUI(Player client)
{
User u = client.GetUser();
if (u == null)
{
return;
}
bool gender = u.GetCharacter().Gender;
List<ShopClothe> tops = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 11);
List<ShopClothe> legs = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 4);
List<ShopClothe> shoes = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 6);
List<ShopClothe> accessoires = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 7);
List<ShopClothe> frisur = clotheList.ToList().FindAll(c => c.Gender == gender && c.ComponentId == 2);
List<Array> clothes = new List<Array>
{
tops.ToArray(),
legs.ToArray(),
shoes.ToArray(),
accessoires.ToArray(),
frisur.ToArray()
};
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()), gender);
}
}
}