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:
VegaZ
2020-05-28 16:45:10 +02:00
parent e2067331c8
commit e298dc846d
2 changed files with 117 additions and 19 deletions

View File

@@ -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")]

View File

@@ -155,6 +155,87 @@ namespace ReallifeGamemode.Server.Managers
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
user.CharacterId = character.Id;
for (var x = 1; x <= 11; x++)
{
var s = 0;
if (x == 10) s = -1;
if (x == 2) continue;
var createClothes = new Database.Entities.CharacterCloth()
{
UserId = userId,
Duty = false,
SlotType = 0,
SlotId = x,
ClothId = s,
Texture = 0
};
saveCharacter.CharacterClothes.Add(createClothes);
}
for (var x = 0; x <= 7; x++)
{
var y = 0;
if (x == 0 || x == 1 || x == 2 || x == 6 || x == 7)
{
if (gender == false)
{
switch (x)
{
case 0:
y = 8;
break;
case 1:
y = 6;
break;
case 2:
y = -1;
break;
case 6:
y = -1;
break;
case 7:
y = -1;
break;
};
}
else
{
switch (x)
{
case 0:
y = 57;
break;
case 1:
y = 5;
break;
case 2:
y = -1;
break;
case 6:
y = -1;
break;
case 7:
y = -1;
break;
};
}
var createClothes = new Database.Entities.CharacterCloth()
{
UserId = userId,
Duty = false,
SlotType = 1,
SlotId = x,
ClothId = y,
Texture = 0
};
saveCharacter.CharacterClothes.Add(createClothes);
}
else
{
continue;
}
}
saveCharacter.SaveChanges();
}
//HeadOverlay makeupHo = new HeadOverlay()