Clothe Shop finished
This commit is contained in:
@@ -1,92 +1,52 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Shop.Clothing
|
||||
{
|
||||
public class ClotheShop
|
||||
{
|
||||
public int category { get; set; } = 1;
|
||||
public int category { get; set; }
|
||||
public Vector3 vector { get; set; }
|
||||
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
||||
|
||||
|
||||
public ClotheShop(int category)
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Command("buyclothes")]
|
||||
public void LoadShopNUI(Client client)
|
||||
{
|
||||
LoadClothes();
|
||||
bool gender = client.GetUser().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);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
List<Array> clothes = new List<Array>
|
||||
{
|
||||
List<Clothe> clothes = new List<Clothe>();
|
||||
bool gender = client.GetUser().Character.Gender;
|
||||
foreach (var clothe in clotheList)
|
||||
{
|
||||
if(clothe.TypeId == "clothes" )
|
||||
{
|
||||
switch (clothe.ComponentId)
|
||||
{
|
||||
case 11: //tops
|
||||
List<ClothCombination> combinations = dbContext.ClothCombinations.Where(c => c.Top == clothe.ClotheId && c.Gender == gender).ToList();
|
||||
foreach (var combination in combinations)
|
||||
{
|
||||
var top = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = combination.Undershirt,
|
||||
torsoId = combination.Torso
|
||||
};
|
||||
clothes.Add(top);
|
||||
}
|
||||
break;
|
||||
default: //everything else
|
||||
var garment = new Clothe
|
||||
{
|
||||
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
||||
ClotheId = clothe.ClotheId,
|
||||
Gender = gender,
|
||||
TypeId = "clothes",
|
||||
clothe = "clothes",
|
||||
Category = category,
|
||||
Price = clothe.Price,
|
||||
undershirtId = -1, //will not be used unless top
|
||||
torsoId = -1 //will not be used unless top
|
||||
};
|
||||
clothes.Add(garment);
|
||||
break;
|
||||
tops.ToArray(),
|
||||
legs.ToArray(),
|
||||
shoes.ToArray(),
|
||||
accessoires.ToArray()
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user