Clothe Shop finished
This commit is contained in:
@@ -23,7 +23,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
@@ -152,5 +151,112 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Client client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if(clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if(data[0] == 11)
|
||||
{
|
||||
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);
|
||||
if(torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
}
|
||||
if(undershirt == null)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
}
|
||||
}
|
||||
user.Handmoney -= data[6];
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user