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,13 +53,14 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
[RemoteEvent("saveCharacterCloth")]
|
[RemoteEvent("saveCharacterCloth")]
|
||||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||||
{
|
{
|
||||||
|
User user;
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||||
|
|
||||||
User user = client.GetUser(context);
|
user = client.GetUser(context);
|
||||||
|
|
||||||
var character = user.GetCharacter(context);
|
var character = user.GetCharacter(context);
|
||||||
|
|
||||||
@@ -133,11 +134,16 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
if (user.GetData<bool>("duty") == false)
|
||||||
|
{
|
||||||
LoadCharacterDefaults(client);
|
LoadCharacterDefaults(client);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[RemoteEvent("defaultCharacterCloth")]
|
[RemoteEvent("defaultCharacterCloth")]
|
||||||
public static void LoadCharacterDefaults(Player player)
|
public static void LoadCharacterDefaults(Player player)
|
||||||
|
{
|
||||||
|
if (player.GetUser().GetData<bool>("duty") == false)
|
||||||
{
|
{
|
||||||
User user = player.GetUser();
|
User user = player.GetUser();
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
@@ -152,16 +158,27 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
foreach (var cloth in charClothes)
|
foreach (var cloth in charClothes)
|
||||||
{
|
{
|
||||||
if (cloth.SlotType == 1)
|
if (cloth.SlotType == 1)
|
||||||
|
{
|
||||||
|
if(cloth.ClothId != -1)
|
||||||
{
|
{
|
||||||
NAPI.Player.SetPlayerAccessory(player, cloth.SlotId, cloth.ClothId, 0);
|
NAPI.Player.SetPlayerAccessory(player, cloth.SlotId, cloth.ClothId, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (cloth.ClothId != -1)
|
||||||
{
|
{
|
||||||
NAPI.Player.SetPlayerClothes(player, cloth.SlotId, cloth.ClothId, cloth.Texture);
|
NAPI.Player.SetPlayerClothes(player, cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||||
|
|||||||
@@ -155,6 +155,87 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||||
|
|
||||||
user.CharacterId = character.Id;
|
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();
|
saveCharacter.SaveChanges();
|
||||||
}
|
}
|
||||||
//HeadOverlay makeupHo = new HeadOverlay()
|
//HeadOverlay makeupHo = new HeadOverlay()
|
||||||
|
|||||||
Reference in New Issue
Block a user