save clothes in database on /clothes command
This commit is contained in:
@@ -835,7 +835,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Command("clothes", "~m~Benutzung: ~s~/clothes [Spieler] [Component ID] [Drawable] (Textur)")]
|
[Command("clothes", "~m~Benutzung: ~s~/clothes [Spieler] [Component ID] [Drawable] (Textur)")]
|
||||||
public void CmdAdminClothes(Client player, string name, int slot, int component, int texture = 0)
|
public void CmdAdminClothes(Client player, string name, int component, int drawable, int texture = 0)
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true)
|
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN2) ?? true)
|
||||||
{
|
{
|
||||||
@@ -850,7 +850,32 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.SetClothes(slot, component, texture);
|
using(var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = target.GetUser(dbContext);
|
||||||
|
bool duty = user.GetData<bool>("duty");
|
||||||
|
CharacterCloth cloth = dbContext.CharacterClothes.Where(c => c.UserId == user.Id && c.SlotId == component && c.SlotType == 0 && c.Duty == duty).FirstOrDefault();
|
||||||
|
if(cloth == null)
|
||||||
|
{
|
||||||
|
cloth = new CharacterCloth()
|
||||||
|
{
|
||||||
|
Duty = duty,
|
||||||
|
ClothId = drawable,
|
||||||
|
SlotId = component,
|
||||||
|
SlotType = 0,
|
||||||
|
Texture = texture,
|
||||||
|
UserId = user.Id,
|
||||||
|
};
|
||||||
|
dbContext.CharacterClothes.Add(cloth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cloth.ClothId = drawable;
|
||||||
|
cloth.Texture = texture;
|
||||||
|
}
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
target.SetClothes(component, drawable, texture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("props", "~m~Benutzung: ~s~/props [Spieler] [Component ID] [Drawable] (Textur)")]
|
[Command("props", "~m~Benutzung: ~s~/props [Spieler] [Component ID] [Drawable] (Textur)")]
|
||||||
|
|||||||
Reference in New Issue
Block a user