Changes to character\n*Fixed duty cloth changer when already duty\n*Changed basic character creation to add default values for cloth and props to database
This commit is contained in:
@@ -53,14 +53,15 @@ namespace ReallifeGamemode.Server.Events
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
User user;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser(context);
|
||||
|
||||
user = client.GetUser(context);
|
||||
|
||||
var character = user.GetCharacter(context);
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.Duty);
|
||||
@@ -133,34 +134,50 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
if (user.GetData<bool>("duty") == false)
|
||||
{
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Player player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
if (player.GetUser().GetData<bool>("duty") == false)
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.Where(c => c.UserId == user.Id && c.Duty == false).ToList();
|
||||
NAPI.Player.ClearPlayerAccessory(player, 0);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 1);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 2);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 6);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.Where(c => c.UserId == user.Id && c.Duty == false).ToList();
|
||||
NAPI.Player.ClearPlayerAccessory(player, 0);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 1);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 2);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 6);
|
||||
NAPI.Player.ClearPlayerAccessory(player, 7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
NAPI.Player.SetPlayerAccessory(player, cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Player.SetPlayerClothes(player, cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
if(cloth.ClothId != -1)
|
||||
{
|
||||
NAPI.Player.SetPlayerAccessory(player, cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
NAPI.Player.SetPlayerClothes(player, cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
|
||||
Reference in New Issue
Block a user