vlt fix clothing

This commit is contained in:
hydrant
2020-05-10 13:29:11 +02:00
parent 81a2108ddb
commit 53d133ef89

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -111,7 +111,18 @@ namespace ReallifeGamemode.Server.Events
{ {
for (var x = 0; x < slotType.Length; x++) for (var x = 0; x < slotType.Length; x++)
{ {
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]); var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == (byte)slotType[x] && u.SlotId == slotId[x]);
if (loopCloth == null)
{
loopCloth = new CharacterCloth()
{
UserId = user.Id,
SlotType = (byte)slotType[x],
SlotId = slotId[x]
};
}
loopCloth.ClothId = clothId[x]; loopCloth.ClothId = clothId[x];
} }
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
@@ -164,7 +175,7 @@ namespace ReallifeGamemode.Server.Events
* [5] UndershirtTextureID * [5] UndershirtTextureID
* [6] Price * [6] Price
*/ */
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData); int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
User user = client.GetUser(); User user = client.GetUser();
if (user.Handmoney < data[6]) if (user.Handmoney < data[6])
@@ -172,7 +183,7 @@ namespace ReallifeGamemode.Server.Events
client.TriggerEvent("clothesMenu:Error"); client.TriggerEvent("clothesMenu:Error");
return; return;
} }
if (type == "clothe") if (type == "clothe")
{ {
if (data[0] == 11)//for tops if (data[0] == 11)//for tops
@@ -187,10 +198,10 @@ namespace ReallifeGamemode.Server.Events
} }
using (var dbContext = new DatabaseContext()) using (var dbContext = new DatabaseContext())
{ {
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false); var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
if(clothes == null) if (clothes == null)
{ {
CharacterCloth newCloth = new CharacterCloth CharacterCloth newCloth = new CharacterCloth
{ {
@@ -210,11 +221,11 @@ namespace ReallifeGamemode.Server.Events
clothes.ClothId = data[2]; clothes.ClothId = data[2];
clothes.Texture = data[1]; clothes.Texture = data[1];
} }
if(data[0] == 11) if (data[0] == 11)
{ {
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false); var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false); var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
if(torso == null) if (torso == null)
{ {
CharacterCloth newTorso = new CharacterCloth CharacterCloth newTorso = new CharacterCloth
{ {
@@ -232,7 +243,7 @@ namespace ReallifeGamemode.Server.Events
{ {
torso.ClothId = data[3]; torso.ClothId = data[3];
} }
if(undershirt == null) if (undershirt == null)
{ {
CharacterCloth newUndershirt = new CharacterCloth CharacterCloth newUndershirt = new CharacterCloth
{ {
@@ -240,7 +251,7 @@ namespace ReallifeGamemode.Server.Events
Duty = false, Duty = false,
SlotType = 0, SlotType = 0,
SlotId = 8, SlotId = 8,
ClothId = data[4], ClothId = data[4],
Texture = data[5] Texture = data[5]
}; };
dbContext.CharacterClothes.Add(newUndershirt); dbContext.CharacterClothes.Add(newUndershirt);