Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop

This commit is contained in:
hydrant
2018-10-24 21:08:15 +02:00
14 changed files with 1184 additions and 15 deletions

136
Client/CharCreator/data.js Normal file
View File

@@ -0,0 +1,136 @@
const fathers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 42, 43, 44];
const mothers = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 45];
const fatherNames = ["Benjamin", "Daniel", "Joshua", "Noah", "Andrew", "Juan", "Alex", "Isaac", "Evan", "Ethan", "Vincent", "Angel", "Diego", "Adrian", "Gabriel", "Michael", "Santiago", "Kevin", "Louis", "Samuel", "Anthony", "Claude", "Niko", "John"];
const motherNames = ["Hannah", "Aubrey", "Jasmine", "Gisele", "Amelia", "Isabella", "Zoe", "Ava", "Camila", "Violet", "Sophia", "Evelyn", "Nicole", "Ashley", "Gracie", "Brianna", "Natalie", "Olivia", "Elizabeth", "Charlotte", "Emma", "Misty"];
const featureNames = ["Nose Width", "Nose Bottom Height", "Nose Tip Length", "Nose Bridge Depth", "Nose Tip Height", "Nose Broken", "Brow Height", "Brow Depth", "Cheekbone Height", "Cheekbone Width", "Cheek Depth", "Eye Size", "Lip Thickness", "Jaw Width", "Jaw Shape", "Chin Height", "Chin Depth", "Chin Width", "Chin Indent", "Neck Width"];
const appearanceNames = ["Blemishes", "Facial Hair", "Eyebrows", "Ageing", "Makeup", "Blush", "Complexion", "Sun Damage", "Lipstick", "Moles & Freckles", "Chest Hair"];
const appearanceItemNames = [
// blemishes
["None", "Measles", "Pimples", "Spots", "Break Out", "Blackheads", "Build Up", "Pustules", "Zits", "Full Acne", "Acne", "Cheek Rash", "Face Rash", "Picker", "Puberty", "Eyesore", "Chin Rash", "Two Face", "T Zone", "Greasy", "Marked", "Acne Scarring", "Full Acne Scarring", "Cold Sores", "Impetigo"],
// facial hair
["None", "Light Stubble", "Balbo", "Circle Beard", "Goatee", "Chin", "Chin Fuzz", "Pencil Chin Strap", "Scruffy", "Musketeer", "Mustache", "Trimmed Beard", "Stubble", "Thin Circle Beard", "Horseshoe", "Pencil and 'Chops", "Chin Strap Beard", "Balbo and Sideburns", "Mutton Chops", "Scruffy Beard", "Curly", "Curly & Deep Stranger", "Handlebar", "Faustic", "Otto & Patch", "Otto & Full Stranger", "Light Franz", "The Hampstead", "The Ambrose", "Lincoln Curtain"],
// eyebrows
["None", "Balanced", "Fashion", "Cleopatra", "Quizzical", "Femme", "Seductive", "Pinched", "Chola", "Triomphe", "Carefree", "Curvaceous", "Rodent", "Double Tram", "Thin", "Penciled", "Mother Plucker", "Straight and Narrow", "Natural", "Fuzzy", "Unkempt", "Caterpillar", "Regular", "Mediterranean", "Groomed", "Bushels", "Feathered", "Prickly", "Monobrow", "Winged", "Triple Tram", "Arched Tram", "Cutouts", "Fade Away", "Solo Tram"],
// ageing
["None", "Crow's Feet", "First Signs", "Middle Aged", "Worry Lines", "Depression", "Distinguished", "Aged", "Weathered", "Wrinkled", "Sagging", "Tough Life", "Vintage", "Retired", "Junkie", "Geriatric"],
// makeup
["None", "Smoky Black", "Bronze", "Soft Gray", "Retro Glam", "Natural Look", "Cat Eyes", "Chola", "Vamp", "Vinewood Glamour", "Bubblegum", "Aqua Dream", "Pin Up", "Purple Passion", "Smoky Cat Eye", "Smoldering Ruby", "Pop Princess"],
// blush
["None", "Full", "Angled", "Round", "Horizontal", "High", "Sweetheart", "Eighties"],
// complexion
["None", "Rosy Cheeks", "Stubble Rash", "Hot Flush", "Sunburn", "Bruised", "Alchoholic", "Patchy", "Totem", "Blood Vessels", "Damaged", "Pale", "Ghostly"],
// sun damage
["None", "Uneven", "Sandpaper", "Patchy", "Rough", "Leathery", "Textured", "Coarse", "Rugged", "Creased", "Cracked", "Gritty"],
// lipstick
["None", "Color Matte", "Color Gloss", "Lined Matte", "Lined Gloss", "Heavy Lined Matte", "Heavy Lined Gloss", "Lined Nude Matte", "Liner Nude Gloss", "Smudged", "Geisha"],
// freckles
["None", "Cherub", "All Over", "Irregular", "Dot Dash", "Over the Bridge", "Baby Doll", "Pixie", "Sun Kissed", "Beauty Marks", "Line Up", "Modelesque", "Occasional", "Speckled", "Rain Drops", "Double Dip", "One Sided", "Pairs", "Growth"],
// chest hair
["None", "Natural", "The Strip", "The Tree", "Hairy", "Grisly", "Ape", "Groomed Ape", "Bikini", "Lightning Bolt", "Reverse Lightning", "Love Heart", "Chestache", "Happy Face", "Skull", "Snail Trail", "Slug and Nips", "Hairy Arms"]
];
const hairList = [
// male
[
{ID: 0, Name: "Close Shave", Collection: "mpbeach_overlays", Overlay: "FM_Hair_Fuzz"},
{ID: 1, Name: "Buzzcut", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_001"},
{ID: 2, Name: "Faux Hawk", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_002"},
{ID: 3, Name: "Hipster", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_003"},
{ID: 4, Name: "Side Parting", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_004"},
{ID: 5, Name: "Shorter Cut", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_005"},
{ID: 6, Name: "Biker", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_006"},
{ID: 7, Name: "Ponytail", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_007"},
{ID: 8, Name: "Cornrows", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_008"},
{ID: 9, Name: "Slicked", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_009"},
{ID: 10, Name: "Short Brushed", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_013"},
{ID: 11, Name: "Spikey", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_002"},
{ID: 12, Name: "Caesar", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_011"},
{ID: 13, Name: "Chopped", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_012"},
{ID: 14, Name: "Dreads", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_014"},
{ID: 15, Name: "Long Hair", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_015"},
{ID: 16, Name: "Shaggy Curls", Collection: "multiplayer_overlays", Overlay: "NGBea_M_Hair_000"},
{ID: 17, Name: "Surfer Dude", Collection: "multiplayer_overlays", Overlay: "NGBea_M_Hair_001"},
{ID: 18, Name: "Short Side Part", Collection: "multiplayer_overlays", Overlay: "NGBus_M_Hair_000"},
{ID: 19, Name: "High Slicked Sides", Collection: "multiplayer_overlays", Overlay: "NGBus_M_Hair_001"},
{ID: 20, Name: "Long Slicked", Collection: "multiplayer_overlays", Overlay: "NGHip_M_Hair_000"},
{ID: 21, Name: "Hipster Youth", Collection: "multiplayer_overlays", Overlay: "NGHip_M_Hair_001"},
{ID: 22, Name: "Mullet", Collection: "multiplayer_overlays", Overlay: "NGInd_M_Hair_000"},
{ID: 24, Name: "Classic Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_M_Hair_000"},
{ID: 25, Name: "Palm Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_M_Hair_001"},
{ID: 26, Name: "Lightning Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_M_Hair_002"},
{ID: 27, Name: "Whipped Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_M_Hair_003"},
{ID: 28, Name: "Zig Zag Cornrows", Collection: "mplowrider2_overlays", Overlay: "LR_M_Hair_004"},
{ID: 29, Name: "Snail Cornrows", Collection: "mplowrider2_overlays", Overlay: "LR_M_Hair_005"},
{ID: 30, Name: "Hightop", Collection: "mplowrider2_overlays", Overlay: "LR_M_Hair_006"},
{ID: 31, Name: "Loose Swept Back", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_000_M"},
{ID: 32, Name: "Undercut Swept Back", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_001_M"},
{ID: 33, Name: "Undercut Swept Side", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_002_M"},
{ID: 34, Name: "Spiked Mohawk", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_003_M"},
{ID: 35, Name: "Mod", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_004_M"},
{ID: 36, Name: "Layered Mod", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_005_M"},
{ID: 72, Name: "Flattop", Collection: "mpgunrunning_overlays", Overlay: "MP_Gunrunning_Hair_M_000_M"},
{ID: 73, Name: "Military Buzzcut", Collection: "mpgunrunning_overlays", Overlay: "MP_Gunrunning_Hair_M_001_M"}
],
// female
[
{ID: 0, Name: "Close Shave", Collection: "mpbeach_overlays", Overlay: "FM_Hair_Fuzz"},
{ID: 1, Name: "Short", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_001"},
{ID: 2, Name: "Layered Bob", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_002"},
{ID: 3, Name: "Pigtails", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_003"},
{ID: 4, Name: "Ponytail", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_004"},
{ID: 5, Name: "Braided Mohawk", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_005"},
{ID: 6, Name: "Braids", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_006"},
{ID: 7, Name: "Bob", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_007"},
{ID: 8, Name: "Faux Hawk", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_008"},
{ID: 9, Name: "French Twist", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_009"},
{ID: 10, Name: "Long Bob", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_010"},
{ID: 11, Name: "Loose Tied", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_011"},
{ID: 12, Name: "Pixie", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_012"},
{ID: 13, Name: "Shaved Bangs", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_013"},
{ID: 14, Name: "Top Knot", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_014"},
{ID: 15, Name: "Wavy Bob", Collection: "multiplayer_overlays", Overlay: "NG_M_Hair_015"},
{ID: 16, Name: "Messy Bun", Collection: "multiplayer_overlays", Overlay: "NGBea_F_Hair_000"},
{ID: 17, Name: "Pin Up Girl", Collection: "multiplayer_overlays", Overlay: "NGBea_F_Hair_001"},
{ID: 18, Name: "Tight Bun", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_007"},
{ID: 19, Name: "Twisted Bob", Collection: "multiplayer_overlays", Overlay: "NGBus_F_Hair_000"},
{ID: 20, Name: "Flapper Bob", Collection: "multiplayer_overlays", Overlay: "NGBus_F_Hair_001"},
{ID: 21, Name: "Big Bangs", Collection: "multiplayer_overlays", Overlay: "NGBea_F_Hair_001"},
{ID: 22, Name: "Braided Top Knot", Collection: "multiplayer_overlays", Overlay: "NGHip_F_Hair_000"},
{ID: 23, Name: "Mullet", Collection: "multiplayer_overlays", Overlay: "NGInd_F_Hair_000"},
{ID: 25, Name: "Pinched Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_F_Hair_000"},
{ID: 26, Name: "Leaf Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_F_Hair_001"},
{ID: 27, Name: "Zig Zag Cornrows", Collection: "mplowrider_overlays", Overlay: "LR_F_Hair_002"},
{ID: 28, Name: "Pigtail Bangs", Collection: "mplowrider2_overlays", Overlay: "LR_F_Hair_003"},
{ID: 29, Name: "Wave Braids", Collection: "mplowrider2_overlays", Overlay: "LR_F_Hair_003"},
{ID: 30, Name: "Coil Braids", Collection: "mplowrider2_overlays", Overlay: "LR_F_Hair_004"},
{ID: 31, Name: "Rolled Quiff", Collection: "mplowrider2_overlays", Overlay: "LR_F_Hair_006"},
{ID: 32, Name: "Loose Swept Back", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_000_F"},
{ID: 33, Name: "Undercut Swept Back", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_001_F"},
{ID: 34, Name: "Undercut Swept Side", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_002_F"},
{ID: 35, Name: "Spiked Mohawk", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_003_F"},
{ID: 36, Name: "Bandana and Braid", Collection: "multiplayer_overlays", Overlay: "NG_F_Hair_003"},
{ID: 37, Name: "Layered Mod", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_006_F"},
{ID: 38, Name: "Skinbyrd", Collection: "mpbiker_overlays", Overlay: "MP_Biker_Hair_004_F"},
{ID: 76, Name: "Neat Bun", Collection: "mpgunrunning_overlays", Overlay: "MP_Gunrunning_Hair_F_000_F"},
{ID: 77, Name: "Short Bob", Collection: "mpgunrunning_overlays", Overlay: "MP_Gunrunning_Hair_F_001_F"}
]
];
const eyeColors = ["Green", "Emerald", "Light Blue", "Ocean Blue", "Light Brown", "Dark Brown", "Hazel", "Dark Gray", "Light Gray", "Pink", "Yellow", "Purple", "Blackout", "Shades of Gray", "Tequila Sunrise", "Atomic", "Warp", "ECola", "Space Ranger", "Ying Yang", "Bullseye", "Lizard", "Dragon", "Extra Terrestrial", "Goat", "Smiley", "Possessed", "Demon", "Infected", "Alien", "Undead", "Zombie"];
exports = {
fathers: fathers,
mothers: mothers,
fatherNames: fatherNames,
motherNames: motherNames,
featureNames: featureNames,
appearanceNames: appearanceNames,
appearanceItemNames: appearanceItemNames,
hairList: hairList,
eyeColors: eyeColors,
maxHairColor: 64,
maxEyeColor: 32,
maxBlushColor: 27,
maxLipstickColor: 32
};

561
Client/CharCreator/index.js Normal file
View File

@@ -0,0 +1,561 @@
// shitcode will be better in the future
// <20>, <20> \u00dc, \u00fc
// <20>, <20> \u00c4, \u00e4
// <20>, <20> \u00d6, \u00f6
// <20> \u00df
const NativeUI = require("NativeUi");
const Data = require("CharCreator/data");
const Menu = NativeUI.Menu;
const UIMenuItem = NativeUI.UIMenuItem;
const UIMenuListItem = NativeUI.UIMenuListItem;
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
const BadgeStyle = NativeUI.BadgeStyle;
const Point = NativeUI.Point;
const ItemsCollection = NativeUI.ItemsCollection;
const Color = NativeUI.Color;
const creatorCoords = {
camera: new mp.Vector3(402.8664, -997.5515, -98.5),
cameraLookAt: new mp.Vector3(402.8664, -996.4108, -98.5)
};
const localPlayer = mp.players.local;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function colorForOverlayIdx(index) {
let color;
switch (index) {
case 1:
color = beardColorItem.Index;
break;
case 2:
color = eyebrowColorItem.Index;
break;
case 5:
color = blushColorItem.Index;
break;
case 8:
color = lipstickColorItem.Index;
break;
case 10:
color = chestHairColorItem.Index;
break;
default:
color = 0;
}
return color;
}
function updateParents() {
localPlayer.setHeadBlendData(
// shape
Data.mothers[motherItem.Index],
Data.fathers[fatherItem.Index],
0,
// skin
Data.mothers[motherItem.Index],
Data.fathers[fatherItem.Index],
0,
// mixes
similarityItem.Index * 0.01,
skinSimilarityItem.Index * 0.01,
0.0,
false
);
}
function updateFaceFeature(index) {
localPlayer.setFaceFeature(index, parseFloat(featureItems[index].SelectedValue));
}
function updateAppearance(index) {
let overlayID = (appearanceItems[index].Index == 0) ? 255 : appearanceItems[index].Index - 1;
localPlayer.setHeadOverlay(index, overlayID, appearanceOpacityItems[index].Index * 0.01, colorForOverlayIdx(index), 0);
}
function updateHairAndColors() {
localPlayer.setComponentVariation(2, Data.hairList[currentGender][hairItem.Index].ID, 0, 2);
localPlayer.setHairColor(hairColorItem.Index, hairHighlightItem.Index);
localPlayer.setEyeColor(eyeColorItem.Index);
localPlayer.setHeadOverlayColor(1, 1, beardColorItem.Index, 0);
localPlayer.setHeadOverlayColor(2, 1, eyebrowColorItem.Index, 0);
localPlayer.setHeadOverlayColor(5, 2, blushColorItem.Index, 0);
localPlayer.setHeadOverlayColor(8, 2, lipstickColorItem.Index, 0);
localPlayer.setHeadOverlayColor(10, 1, chestHairColorItem.Index, 0);
}
function applyCreatorOutfit() {
if (currentGender == 0) {
localPlayer.setDefaultComponentVariation();
localPlayer.setComponentVariation(3, 15, 0, 2);
localPlayer.setComponentVariation(4, 21, 0, 2);
localPlayer.setComponentVariation(6, 34, 0, 2);
localPlayer.setComponentVariation(8, 15, 0, 2);
localPlayer.setComponentVariation(11, 15, 0, 2);
} else {
localPlayer.setDefaultComponentVariation();
localPlayer.setComponentVariation(3, 15, 0, 2);
localPlayer.setComponentVariation(4, 10, 0, 2);
localPlayer.setComponentVariation(6, 35, 0, 2);
localPlayer.setComponentVariation(8, 15, 0, 2);
localPlayer.setComponentVariation(11, 15, 0, 2);
}
}
function fillHairMenu() {
hairItem = new UIMenuListItem("Haar", "Deine Haare", new ItemsCollection(Data.hairList[currentGender].map(h => h.Name)));
creatorHairMenu.AddItem(hairItem);
hairColorItem = new UIMenuListItem("Haarfarbe", "Deine Haarfarbe", new ItemsCollection(hairColors));
creatorHairMenu.AddItem(hairColorItem);
hairHighlightItem = new UIMenuListItem("Haarstr\u00e4hnen", "Farbe deiner Haarstr\u00e4hnen", new ItemsCollection(hairColors));
creatorHairMenu.AddItem(hairHighlightItem);
eyebrowColorItem = new UIMenuListItem("Augenbrauen Farbe", "Farbe deiner Augenbrauen", new ItemsCollection(hairColors));
creatorHairMenu.AddItem(eyebrowColorItem);
beardColorItem = new UIMenuListItem("Farbe der Gesichtsbehaarung", "Farbe deiner Gesichtsbehaarung", new ItemsCollection(hairColors));
creatorHairMenu.AddItem(beardColorItem);
eyeColorItem = new UIMenuListItem("Augenfarbe", "Farbe deiner Augen", new ItemsCollection(Data.eyeColors));
creatorHairMenu.AddItem(eyeColorItem);
blushColorItem = new UIMenuListItem("Rouge", "Farbe des Rouges.", new ItemsCollection(blushColors));
creatorHairMenu.AddItem(blushColorItem);
lipstickColorItem = new UIMenuListItem("Lippenstift Farbe", "Farbe deines Lippenstifts.", new ItemsCollection(lipstickColors));
creatorHairMenu.AddItem(lipstickColorItem);
chestHairColorItem = new UIMenuListItem("Farbe der Brustbehaarung", "Farbe deiner Brustbehaarung", new ItemsCollection(hairColors));
creatorHairMenu.AddItem(chestHairColorItem);
creatorHairMenu.AddItem(new UIMenuItem("Zuf\u00e4llig", "~r~Zuf\u00e4lliges Haar & Farben"));
creatorHairMenu.AddItem(new UIMenuItem("Zur\u00fccksetzen", "~r~Zur\u00fccksetzen von Haar & Farben"));
}
function resetParentsMenu(refresh = false) {
fatherItem.Index = 0;
motherItem.Index = 0;
similarityItem.Index = (currentGender == 0) ? 100 : 0;
skinSimilarityItem.Index = (currentGender == 0) ? 100 : 0;
updateParents();
if (refresh) creatorParentsMenu.RefreshIndex();
}
function resetFeaturesMenu(refresh = false) {
for (let i = 0; i < Data.featureNames.length; i++) {
featureItems[i].Index = 100;
updateFaceFeature(i);
}
if (refresh) creatorFeaturesMenu.RefreshIndex();
}
function resetAppearanceMenu(refresh = false) {
for (let i = 0; i < Data.appearanceNames.length; i++) {
appearanceItems[i].Index = 0;
appearanceOpacityItems[i].Index = 100;
updateAppearance(i);
}
if (refresh) creatorAppearanceMenu.RefreshIndex();
}
function resetHairAndColorsMenu(refresh = false) {
hairItem.Index = 0;
hairColorItem.Index = 0;
hairHighlightItem.Index = 0;
eyebrowColorItem.Index = 0;
beardColorItem.Index = 0;
eyeColorItem.Index = 0;
blushColorItem.Index = 0;
lipstickColorItem.Index = 0;
chestHairColorItem.Index = 0;
updateHairAndColors();
if (refresh) creatorHairMenu.RefreshIndex();
}
let currentGender = 0;
let creatorMenus = [];
let creatorCamera;
// color arrays
let hairColors = [];
for (let i = 0; i < Data.maxHairColor; i++) hairColors.push(i.toString());
let blushColors = [];
for (let i = 0; i < Data.maxBlushColor; i++) blushColors.push(i.toString());
let lipstickColors = [];
for (let i = 0; i < Data.maxLipstickColor; i++) lipstickColors.push(i.toString());
// CREATOR MAIN
let creatorMainMenu = new Menu("Charaktererstellung", "", new Point(50, 50));
let genderItem = new UIMenuListItem("Geschlecht", "~r~Dies setzt deine Einstellungen zur\u00fcck.", new ItemsCollection(["M\u00e4nnlich", "Weiblich"]));
creatorMainMenu.AddItem(genderItem);
creatorMainMenu.AddItem(new UIMenuItem("Eltern", "Eltern des Charakters."));
creatorMainMenu.AddItem(new UIMenuItem("Gesichtsz\u00fcge", "Gesichtsz\u00fcge des Charakters."));
creatorMainMenu.AddItem(new UIMenuItem("Aussehen", "Aussehen des Charakters."));
creatorMainMenu.AddItem(new UIMenuItem("Haar & Farben", "Haare & Farben deines Charakters."));
let angles = [];
for (let i = -180.0; i <= 180.0; i += 5.0) angles.push(i.toFixed(1));
let angleItem = new UIMenuListItem("Drehung", "", new ItemsCollection(angles));
creatorMainMenu.AddItem(angleItem);
let saveItem = new UIMenuItem("Speichern", "Speichert alle \u00c4nderungen.");
saveItem.BackColor = new Color(13, 71, 161);
saveItem.HighlightedBackColor = new Color(25, 118, 210);
creatorMainMenu.AddItem(saveItem);
//let cancelItem = new UIMenuItem("Abbrechen", "Setzt alle \u00c4nderungen zur\u00fcck.");
//cancelItem.BackColor = new Color(213, 0, 0);
//cancelItem.HighlightedBackColor = new Color(229, 57, 53);
//creatorMainMenu.AddItem(cancelItem);
creatorMainMenu.ListChange.on((item, listIndex) => {
if (item == genderItem) {
currentGender = listIndex;
mp.events.callRemote("creator_GenderChange", listIndex);
setTimeout(() => {
localPlayer.clearTasksImmediately();
applyCreatorOutfit();
angleItem.Index = 0;
resetParentsMenu(true);
resetFeaturesMenu(true);
resetAppearanceMenu(true);
creatorHairMenu.Clear();
fillHairMenu();
creatorHairMenu.RefreshIndex();
}, 200);
} else if (item == angleItem) {
localPlayer.setHeading(parseFloat(angleItem.SelectedValue));
localPlayer.clearTasksImmediately();
}
});
creatorMainMenu.ItemSelect.on((item, index) => {
switch (index) {
case 1:
creatorMainMenu.Visible = false;
creatorParentsMenu.Visible = true;
break;
case 2:
creatorMainMenu.Visible = false;
creatorFeaturesMenu.Visible = true;
break;
case 3:
creatorMainMenu.Visible = false;
creatorAppearanceMenu.Visible = true;
break;
case 4:
creatorMainMenu.Visible = false;
creatorHairMenu.Visible = true;
break;
case 6:
let parentData = {
Father: Data.fathers[fatherItem.Index],
Mother: Data.mothers[motherItem.Index],
Similarity: similarityItem.Index * 0.01,
SkinSimilarity: skinSimilarityItem.Index * 0.01
};
let featureData = [];
for (let i = 0; i < featureItems.length; i++) featureData.push(parseFloat(featureItems[i].SelectedValue));
let appearanceData = [];
for (let i = 0; i < appearanceItems.length; i++) appearanceData.push({Value: ((appearanceItems[i].Index == 0) ? 255 : appearanceItems[i].Index - 1), Opacity: appearanceOpacityItems[i].Index * 0.01});
let hairAndColors = [
Data.hairList[currentGender][hairItem.Index].ID,
hairColorItem.Index,
hairHighlightItem.Index,
eyebrowColorItem.Index,
beardColorItem.Index,
eyeColorItem.Index,
blushColorItem.Index,
lipstickColorItem.Index,
chestHairColorItem.Index
];
for (let i = 0; i < creatorMenus.length; i++) creatorMenus[i].Visible = false;
mp.gui.chat.show(true);
mp.game.ui.displayRadar(true);
mp.game.ui.displayHud(true);
localPlayer.freezePosition(false);
localPlayer.setDefaultComponentVariation();
localPlayer.setComponentVariation(2, Data.hairList[currentGender][hairItem.Index].ID, 0, 2);
mp.game.cam.renderScriptCams(false, false, 0, true, false);
mp.events.callRemote("creatorSave", currentGender, JSON.stringify(parentData), JSON.stringify(featureData), JSON.stringify(appearanceData), JSON.stringify(hairAndColors));
break;
case 7:
mp.events.callRemote("creator_Leave");
break;
}
});
creatorMainMenu.MenuClose.on(() => {
mp.events.callRemote("creator_Leave");
});
creatorMainMenu.Visible = false;
creatorMenus.push(creatorMainMenu);
// CREATOR MAIN END
// CREATOR PARENTS
let similarities = [];
for (let i = 0; i <= 100; i++) similarities.push(i + "%");
let creatorParentsMenu = new Menu("Eltern", "", new Point(50, 50));
let fatherItem = new UIMenuListItem("Vater", "Dem Charakter sein Vadda.", new ItemsCollection(Data.fatherNames));
let motherItem = new UIMenuListItem("Mutter", "Dem Charakter seine Mudda.", new ItemsCollection(Data.motherNames));
let similarityItem = new UIMenuListItem("\u00c4hnlichkeit", "\u00c4hnlichkeit zu den Eltern.\n(niedriger = feminin, h\u00f6her = maskulin)", new ItemsCollection(similarities));
let skinSimilarityItem = new UIMenuListItem("Hautfarbe", "Hautfarben \u00c4hnlichkeit zu den Eltern.\n(niedriger = Mutter, h\u00f6her = Vater)", new ItemsCollection(similarities));
creatorParentsMenu.AddItem(fatherItem);
creatorParentsMenu.AddItem(motherItem);
creatorParentsMenu.AddItem(similarityItem);
creatorParentsMenu.AddItem(skinSimilarityItem);
creatorParentsMenu.AddItem(new UIMenuItem("Zuf\u00e4llig", "~r~Zuf\u00e4llige Eltern."));
creatorParentsMenu.AddItem(new UIMenuItem("Zur\u00fccksetzen", "~r~Setzt die Eltern zur\u00fcck. :'("));
creatorParentsMenu.ItemSelect.on((item, index) => {
switch (item.Text) {
case "Zuf\u00e4llig":
fatherItem.Index = getRandomInt(0, Data.fathers.length - 1);
motherItem.Index = getRandomInt(0, Data.mothers.length - 1);
similarityItem.Index = getRandomInt(0, 100);
skinSimilarityItem.Index = getRandomInt(0, 100);
updateParents();
break;
case "Zur\u00fccksetzen":
resetParentsMenu();
break;
}
});
creatorParentsMenu.ListChange.on((item, listIndex) => {
updateParents();
});
creatorParentsMenu.ParentMenu = creatorMainMenu;
creatorParentsMenu.Visible = false;
creatorMenus.push(creatorParentsMenu);
// CREATOR PARENTS END
// CREATOR FEATURES
let featureItems = [];
let features = [];
for (let i = -1.0; i <= 1.01; i += 0.01) features.push(i.toFixed(2));
let creatorFeaturesMenu = new Menu("Gesichtsz\u00fcge", "", new Point(50, 50));
for (let i = 0; i < Data.featureNames.length; i++) {
let tempFeatureItem = new UIMenuListItem(Data.featureNames[i], "", new ItemsCollection(features));
tempFeatureItem.Index = 100;
featureItems.push(tempFeatureItem);
creatorFeaturesMenu.AddItem(tempFeatureItem);
}
creatorFeaturesMenu.AddItem(new UIMenuItem("Zuf\u00e4llig", "~r~Zuf\u00e4llige Gesichtsz\u00fcge."));
creatorFeaturesMenu.AddItem(new UIMenuItem("Zur\u00fccksetzen", "~r~Setzt Gesichtsz\u00fcge zur\u00fcck."));
creatorFeaturesMenu.ItemSelect.on((item, index) => {
switch (item.Text) {
case "Zuf\u00e4llig":
for (let i = 0; i < Data.featureNames.length; i++) {
featureItems[i].Index = getRandomInt(0, 200);
updateFaceFeature(i);
}
break;
case "Zur\u00fccksetzen":
resetFeaturesMenu();
break;
}
});
creatorFeaturesMenu.ListChange.on((item, listIndex) => {
updateFaceFeature(featureItems.indexOf(item));
});
creatorFeaturesMenu.ParentMenu = creatorMainMenu;
creatorFeaturesMenu.Visible = false;
creatorMenus.push(creatorFeaturesMenu);
// CREATOR FEATURES END
// CREATOR APPEARANCE
let appearanceItems = [];
let appearanceOpacityItems = [];
let opacities = [];
for (let i = 0; i <= 100; i++) opacities.push(i + "%");
let creatorAppearanceMenu = new Menu("Aussehen", "", new Point(50, 50));
for (let i = 0; i < Data.appearanceNames.length; i++) {
let items = [];
for (let j = 0, max = mp.game.ped.getNumHeadOverlayValues(i); j <= max; j++) items.push((Data.appearanceItemNames[i][j] === undefined) ? j.toString() : Data.appearanceItemNames[i][j]);
let tempAppearanceItem = new UIMenuListItem(Data.appearanceNames[i], "", new ItemsCollection(items));
appearanceItems.push(tempAppearanceItem);
creatorAppearanceMenu.AddItem(tempAppearanceItem);
let tempAppearanceOpacityItem = new UIMenuListItem(Data.appearanceNames[i] + " Transparenz", "", new ItemsCollection(opacities));
tempAppearanceOpacityItem.Index = 100;
appearanceOpacityItems.push(tempAppearanceOpacityItem);
creatorAppearanceMenu.AddItem(tempAppearanceOpacityItem);
}
creatorAppearanceMenu.AddItem(new UIMenuItem("Zuf\u00e4llig", "~r~Zuf\u00e4lliges Aussehen."));
creatorAppearanceMenu.AddItem(new UIMenuItem("Zur\u00fccksetzen", "~r~Setzt das Aussehen zur\u00fcck."));
creatorAppearanceMenu.ItemSelect.on((item, index) => {
switch (item.Text) {
case "Zuf\u00e4llig":
for (let i = 0; i < Data.appearanceNames.length; i++) {
appearanceItems[i].Index = getRandomInt(0, mp.game.ped.getNumHeadOverlayValues(i) - 1);
appearanceOpacityItems[i].Index = getRandomInt(0, 100);
updateAppearance(i);
}
break;
case "Zur\u00fccksetzen":
resetAppearanceMenu();
break;
}
});
creatorAppearanceMenu.ListChange.on((item, listIndex) => {
let idx = (creatorAppearanceMenu.CurrentSelection % 2 == 0) ? (creatorAppearanceMenu.CurrentSelection / 2) : Math.floor(creatorAppearanceMenu.CurrentSelection / 2);
updateAppearance(idx);
});
creatorAppearanceMenu.ParentMenu = creatorMainMenu;
creatorAppearanceMenu.Visible = false;
creatorMenus.push(creatorAppearanceMenu);
// CREATOR APPEARANCE END
// CREATOR HAIR & COLORS
let hairItem;
let hairColorItem;
let hairHighlightItem;
let eyebrowColorItem;
let beardColorItem;
let eyeColorItem;
let blushColorItem;
let lipstickColorItem;
let chestHairColorItem;
creatorHairMenu = new Menu("Haar & Farben", "", new Point(50, 50));
fillHairMenu();
creatorHairMenu.ItemSelect.on((item, index) => {
switch (item.Text) {
case "Zuf\u00e4llig":
hairItem.Index = getRandomInt(0, Data.hairList[currentGender].length - 1);
hairColorItem.Index = getRandomInt(0, Data.maxHairColor);
hairHighlightItem.Index = getRandomInt(0, Data.maxHairColor);
eyebrowColorItem.Index = getRandomInt(0, Data.maxHairColor);
beardColorItem.Index = getRandomInt(0, Data.maxHairColor);
eyeColorItem.Index = getRandomInt(0, Data.maxEyeColor);
blushColorItem.Index = getRandomInt(0, Data.maxBlushColor);
lipstickColorItem.Index = getRandomInt(0, Data.maxLipstickColor);
chestHairColorItem.Index = getRandomInt(0, Data.maxHairColor);
updateHairAndColors();
break;
case "Zur\u00fccksetzen":
resetHairAndColorsMenu();
break;
}
});
creatorHairMenu.ListChange.on((item, listIndex) => {
if (item == hairItem) {
let hairStyle = Data.hairList[currentGender][listIndex];
localPlayer.setComponentVariation(2, hairStyle.ID, 0, 2);
} else {
switch (creatorHairMenu.CurrentSelection) {
case 1: // hair color
localPlayer.setHairColor(listIndex, hairHighlightItem.Index);
break;
case 2: // hair highlight color
localPlayer.setHairColor(hairColorItem.Index, listIndex);
break;
case 3: // eyebrow color
localPlayer.setHeadOverlayColor(2, 1, listIndex, 0);
break;
case 4: // facial hair color
localPlayer.setHeadOverlayColor(1, 1, listIndex, 0);
break;
case 5: // eye color
localPlayer.setEyeColor(listIndex);
break;
case 6: // blush color
localPlayer.setHeadOverlayColor(5, 2, listIndex, 0);
break;
case 7: // lipstick color
localPlayer.setHeadOverlayColor(8, 2, listIndex, 0);
break;
case 8: // chest hair color
localPlayer.setHeadOverlayColor(10, 1, listIndex, 0);
break;
}
}
});
creatorHairMenu.ParentMenu = creatorMainMenu;
creatorHairMenu.Visible = false;
creatorMenus.push(creatorHairMenu);
// CREATOR HAIR & COLORS END
// EVENTS
mp.events.add("toggleCreator", (active, charData) => {
if (creatorCamera === undefined) {
creatorCamera = mp.cameras.new("creatorCamera", creatorCoords.camera, new mp.Vector3(0, 0, 0), 45);
creatorCamera.pointAtCoord(creatorCoords.cameraLookAt);
creatorCamera.setActive(true);
creatorMainMenu.Visible = true;
mp.gui.chat.show(false);
mp.game.ui.displayRadar(false);
mp.game.ui.displayHud(false);
localPlayer.clearTasksImmediately();
localPlayer.freezePosition(true);
mp.game.cam.renderScriptCams(true, false, 0, true, false);
}
});
mp.events.add("sendToServer", (characterData) => {
mp.events.callRemote("creatorSave", characterData);
});

1
Client/NativeUi/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -5,6 +5,12 @@
*/
require('./CharCreator/index.js')
require('./CharCreator/data.js')
require('./NativeUi/index.js')
require('./Login/main.js');
require('./Save/main.js');

View File

@@ -26,6 +26,7 @@ namespace reallife_gamemode
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
NAPI.Server.SetAutoSpawnOnConnect(false);
NAPI.Server.SetAutoRespawnAfterDeath(false);
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5), new Vector3(-334, -143, 41));

View File

@@ -41,6 +41,7 @@ namespace reallife_gamemode.Model
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { get; set; }
public DbSet<Server.Entities.Ban> Bans { get; set; }
public DbSet<Server.Entities.Character> Characters { get; set; }
//Faction
public DbSet<Server.Entities.Faction> Factions { get; set; }

View File

@@ -1731,6 +1731,11 @@ namespace reallife_gamemode.Server.Commands
SaveManager.SaveAllOnSave();
}
[Command("creator")]
public void CmdAdminCreator(Client player)
{
player.TriggerEvent("toggleCreator");
}
/*
[Command("restart")]
public void CmdAdminRestart(Client player)

View File

@@ -0,0 +1,92 @@
using Newtonsoft.Json;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Services;
using reallife_gamemode.Server.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
/**
* @overview Life of German Reallife - Entities Ban (Ban.cs)
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class Character
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("User")]
public int UserId { get; set; }
public User User { get; set; }
public bool Gender { get; set; }
public byte Father { get; set; }
public byte Mother { get; set; }
public float Similarity { get; set; }
public float SkinSimilarity { get; set; }
public float NoseWidth { get; set; }
public float NoseBottomHeight { get; set; }
public float NoseTipLength { get; set; }
public float NoseBridgeDepth { get; set; }
public float NoseTipHeight { get; set; }
public float NoseBroken { get; set; }
public float BrowHeight { get; set; }
public float BrowDepth { get; set; }
public float CheekboneHeight { get; set; }
public float CheekboneWidth { get; set; }
public float CheekDepth { get; set; }
public float EyeSize { get; set; }
public float LipThickness { get; set; }
public float JawWidth { get; set; }
public float JawShape { get; set; }
public float ChinHeight { get; set; }
public float ChinDepth { get; set; }
public float ChinWidth { get; set; }
public float ChinIndent { get; set; }
public float NeckWidth { get; set; }
public byte Blemishes { get; set; }
public float BlemishesOpacity { get; set; }
public byte FacialHair { get; set; }
public float FacialHairOpacity { get; set; }
public byte Eyebrows { get; set; }
public float EyebrowsOpacity { get; set; }
public byte Ageing { get; set; }
public float AgeingOpacity { get; set; }
public byte Makeup { get; set; }
public float MakeupOpacity { get; set; }
public byte Blush { get; set; }
public float BlushOpacity { get; set; }
public byte Complexion { get; set; }
public float ComplexionOpacity { get; set; }
public byte SunDamage { get; set; }
public float SunDamageOpacity { get; set; }
public byte Lipstick { get; set; }
public float LipstickOpacity { get; set; }
public byte Freckles { get; set; }
public float FrecklesOpacity { get; set; }
public byte ChestHair { get; set; }
public float ChestHairOpacity { get; set; }
public byte Hair { get; set; }
public byte HairColor { get; set; }
public byte HairHighlightColor { get; set; }
public byte EyebrowColor { get; set; }
public byte BeardColor { get; set; }
public byte EyeColor { get; set; }
public byte BlushColor { get; set; }
public byte LipstickColor { get; set; }
public byte ChestHairColor { get; set; }
}
}

View File

@@ -42,10 +42,13 @@ namespace reallife_gamemode.Server.Entities
public float PositionY { get; set; }
public float PositionZ { get; set; }
[ForeignKey("Character")]
public int? CharacterId { get; set; }
public Character Character { get; set; }
[ForeignKey("Ban")]
public int? BanId { get; set; }
public Ban Ban { get; set; }
public int? FactionId { get; set; }
public Faction Faction { get; set; }

View File

@@ -5,6 +5,7 @@ using System.Text;
using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Managers;
using reallife_gamemode.Server.Util;
/**
@@ -19,7 +20,7 @@ namespace reallife_gamemode.Server.Events
{
[RemoteEvent("OnPlayerLogin")]
public void OnPlayerLogin(Client player, string password)
{
{
using (var loginUser = new Model.DatabaseContext())
{
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
@@ -39,16 +40,17 @@ namespace reallife_gamemode.Server.Events
if (user.Password != NAPI.Util.GetHashSha256(password))
{
player.TriggerEvent("loginFail", "Passwort inkorrekt!");
}
}
else
{
player.TriggerEvent("loginSuccess");
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
player.TriggerEvent("loginSuccess");
player.SetData("isLoggedIn", true);
player.SetData("spec", true);
player.SetData("duty", false);
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
userBankAccount.Balance = userBankAccount.Balance;
if (user.Dead == true)
{
if (user.IsAdmin(AdminLevel.ADMIN) == true)
@@ -65,12 +67,7 @@ namespace reallife_gamemode.Server.Events
else
{
player.SetData("isDead", false);
}
var userBankAccount = loginUser.UserBankAccounts.SingleOrDefault(u => u.UserId == user.Id);
userBankAccount.Balance = userBankAccount.Balance;
player.TriggerEvent("draw", player.Name, player.Handle.Value);
}
if (user.Dead == true)
{
//player.TriggerEvent("startDeathTimer");
@@ -82,6 +79,21 @@ namespace reallife_gamemode.Server.Events
{
player.SetData("isDead", false);
}
if (user.CharacterId == null)
{
var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
currentPlayerCreatorDimension++;
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
player.TriggerEvent("toggleCreator");
}
else
{
CharacterCreator.ApplyCharacter(player);
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
player.TriggerEvent("draw", player.Name, player.Handle.Value);
}
}
}
}

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTANetworkAPI;
using Newtonsoft.Json;
using reallife_gamemode.Model;
/**
* @overview Life of German Reallife - Event Register (Register.cs)
@@ -41,11 +43,17 @@ namespace reallife_gamemode.Server.Events
dbContext.UserBankAccounts.Add(userBankAccount);
dbContext.SaveChanges();
player.TriggerEvent("registerSuccess");
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
player.TriggerEvent("registerSuccess");
player.SetData("isLoggedIn", true);
player.TriggerEvent("draw", player.Name, player.Handle.Value);
player.SetData("isDead", false);
var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
currentPlayerCreatorDimension++;
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.TriggerEvent("toggleCreator");
}
else if (player.SocialClubName == checkedUser.SocialClubName)
{
player.TriggerEvent("registerFail", "Dieser SocialClubAccount ist schon registriert!");

View File

@@ -1,5 +1,7 @@
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using System;

View File

@@ -31,5 +31,19 @@ namespace reallife_gamemode.Server.Extensions
return context.UserBankAccounts.FirstOrDefault(u => u.UserId == user.Id);
}
}
public static Character GetUserCharacter(this User user, DatabaseContext context = null)
{
if (context == null)
{
using (context = new DatabaseContext())
{
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
}
}
else
{
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
}
}
}
}

View File

@@ -0,0 +1,327 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GTANetworkAPI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Extensions;
namespace reallife_gamemode.Server.Managers
{
public class CharacterCreator : Script
{
public CharacterCreator()
{
}
[RemoteEvent("creatorSave")]
public void CreatorSave(Client player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
{
var jParentData = JObject.Parse(parentData);
var jFeatureData = JArray.Parse(featureData);
var jAppearanceData = JArray.Parse(appearanceData);
var jHairAndColorData = JArray.Parse(hairAndColorData);
byte father = jParentData.Value<byte>("Father");
byte mother = jParentData.Value<byte>("Mother");
float similarity = jParentData.Value<float>("Similarity");
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
float noseWidth = jFeatureData.Value<float>(0);
float noseBottomHeight = jFeatureData.Value<float>(1);
float noseTipLength = jFeatureData.Value<float>(2);
float noseBridgeDepth = jFeatureData.Value<float>(3);
float noseTipHeight = jFeatureData.Value<float>(4);
float noseBroken = jFeatureData.Value<float>(5);
float browHeight = jFeatureData.Value<float>(6);
float browDepth = jFeatureData.Value<float>(7);
float cheekboneHeight = jFeatureData.Value<float>(8);
float cheekboneWidth = jFeatureData.Value<float>(9);
float cheekDepth = jFeatureData.Value<float>(10);
float eyeSize = jFeatureData.Value<float>(11);
float lipThickness = jFeatureData.Value<float>(12);
float jawWidth = jFeatureData.Value<float>(13);
float jawShape = jFeatureData.Value<float>(14);
float chinHeight = jFeatureData.Value<float>(15);
float chinDepth = jFeatureData.Value<float>(16);
float chinWidth = jFeatureData.Value<float>(17);
float chinIndent = jFeatureData.Value<float>(18);
float neckWidth = jFeatureData.Value<float>(19);
byte blemishes = jAppearanceData[0].Value<byte>("Value");
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
byte facialHair = jAppearanceData[1].Value<byte>("Value");
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
byte ageing = jAppearanceData[3].Value<byte>("Value");
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
byte makeup = jAppearanceData[4].Value<byte>("Value");
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
byte blush = jAppearanceData[5].Value<byte>("Value");
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
byte complexion = jAppearanceData[6].Value<byte>("Value");
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
byte lipstick = jAppearanceData[8].Value<byte>("Value");
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
byte freckles = jAppearanceData[9].Value<byte>("Value");
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
byte chestHair = jAppearanceData[10].Value<byte>("Value");
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
byte hair = jHairAndColorData.Value<byte>(0);
byte hairColor = jHairAndColorData.Value<byte>(1);
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
byte beardColor = jHairAndColorData.Value<byte>(4);
byte eyeColor = jHairAndColorData.Value<byte>(5);
byte blushColor = jHairAndColorData.Value<byte>(6);
byte lipstickColor = jHairAndColorData.Value<byte>(7);
byte chestHairColor = jHairAndColorData.Value<byte>(8);
using (var saveCharacter = new DatabaseContext())
{
var character = new Entities.Character
{
UserId = player.GetUser().Id,
Gender = gender,
Father = father,
Mother = mother,
Similarity = similarity,
SkinSimilarity = skinSimilarity,
NoseWidth = noseWidth,
NoseBottomHeight = noseBottomHeight,
NoseTipLength = noseTipLength,
NoseBridgeDepth = noseBridgeDepth,
NoseTipHeight = noseTipHeight,
NoseBroken = noseBroken,
BrowHeight = browHeight,
BrowDepth = browDepth,
CheekboneHeight = cheekboneHeight,
CheekboneWidth = cheekboneWidth,
CheekDepth = cheekDepth,
EyeSize = eyeSize,
LipThickness = lipThickness,
JawWidth = jawWidth,
JawShape = jawShape,
ChinHeight = chinHeight,
ChinDepth = chinDepth,
ChinWidth = chinWidth,
ChinIndent = chinIndent,
NeckWidth = neckWidth,
Blemishes = blemishes,
BlemishesOpacity = blemishesOpacity,
FacialHair = facialHair,
FacialHairOpacity = facialHairOpacity,
Eyebrows = eyebrows,
EyebrowsOpacity = eyebrowsOpacity,
Ageing = ageing,
AgeingOpacity = ageingOpacity,
Makeup = makeup,
MakeupOpacity = makeupOpacity,
Blush = blush,
BlushOpacity = blushOpacity,
Complexion = complexion,
ComplexionOpacity = complexionOpacity,
SunDamage = sunDamage,
SunDamageOpacity = sunDamageOpacity,
Lipstick = lipstick,
LipstickOpacity = lipstickOpacity,
Freckles = freckles,
FrecklesOpacity = frecklesOpacity,
ChestHair = chestHair,
ChestHairOpacity = chestHairOpacity,
Hair = hair,
HairColor = hairColor,
HairHighlightColor = hairHighlightColor,
EyebrowColor = eyebrowColor,
BeardColor = beardColor,
EyeColor = eyeColor,
BlushColor = blushColor,
LipstickColor = lipstickColor,
ChestHairColor = chestHairColor
};
saveCharacter.Characters.Add(character);
saveCharacter.SaveChanges();
var userId = player.GetUser().Id;
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
user.CharacterId = character.Id;
saveCharacter.SaveChanges();
}
//HeadOverlay makeupHo = new HeadOverlay()
//{
// Index = 0,
// Opacity = 0.0f,
// Color = 0,
// SecondaryColor = 0
//};
//HeadOverlay blushHo = new HeadOverlay()
//{
// Index = 0,
// Opacity = 0.0f,
// Color = 0,
// SecondaryColor = 0
//};
//player.SetHeadOverlay(4, makeupHo);
//player.SetHeadOverlay(5, blushHo);
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
}
public static void ApplyCharacter(Client player)
{
var userId = player.GetUser().Id;
using (var loadCharacter = new DatabaseContext())
{
var character = loadCharacter.Characters.SingleOrDefault(c => c.UserId == userId);
//Männlich / Weiblich
if (character.Gender == false)
{
player.SetSkin(PedHash.FreemodeMale01);
}
else
{
player.SetSkin(PedHash.FreemodeFemale01);
}
//Gesichtszüge
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth,
character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth,
character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth };
for (var i = 0; i < faceFeatures.Length; i++)
{
player.SetFaceFeature(i, faceFeatures[i]);
}
//Gesichtsmerkmale
HeadOverlay blemishes = new HeadOverlay()
{
Index = character.Blemishes,
Opacity = character.BlemishesOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay facialHair = new HeadOverlay()
{
Index = character.FacialHair,
Opacity = character.FacialHairOpacity,
Color = character.BeardColor,
SecondaryColor = 255
};
HeadOverlay eyebrows = new HeadOverlay()
{
Index = character.Eyebrows,
Opacity = character.EyebrowsOpacity,
Color = character.EyebrowColor,
SecondaryColor = 255
};
HeadOverlay ageing = new HeadOverlay()
{
Index = character.Ageing,
Opacity = character.AgeingOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay makeup = new HeadOverlay()
{
Index = character.Makeup,
Opacity = character.MakeupOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay blush = new HeadOverlay()
{
Index = character.Blush,
Opacity = character.BlushOpacity,
Color = character.BlushColor,
SecondaryColor = 255
};
HeadOverlay complexion = new HeadOverlay()
{
Index = character.Complexion,
Opacity = character.ComplexionOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay sunDamage = new HeadOverlay()
{
Index = character.SunDamage,
Opacity = character.SunDamageOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay lipstick = new HeadOverlay()
{
Index = character.Lipstick,
Opacity = character.LipstickOpacity,
Color = character.LipstickColor,
SecondaryColor = 255
};
HeadOverlay freckles = new HeadOverlay()
{
Index = character.Freckles,
Opacity = character.FrecklesOpacity,
Color = 255,
SecondaryColor = 255
};
HeadOverlay chestHair = new HeadOverlay()
{
Index = character.ChestHair,
Opacity = character.ChestHairOpacity,
Color = character.ChestHairColor,
SecondaryColor = 255
};
player.SetHeadOverlay(0, blemishes);
player.SetHeadOverlay(1, facialHair);
player.SetHeadOverlay(2, eyebrows);
player.SetHeadOverlay(3, ageing);
player.SetHeadOverlay(4, makeup);
player.SetHeadOverlay(5, blush);
player.SetHeadOverlay(6, complexion);
player.SetHeadOverlay(7, sunDamage);
player.SetHeadOverlay(8, lipstick);
player.SetHeadOverlay(9, freckles);
player.SetHeadOverlay(10, chestHair);
player.SetHeadOverlay(11, blemishes);
player.SetHeadOverlay(12, blemishes);
//Gesicht (Vererbung durch Mutter / Vater)
HeadBlend headBlend = new HeadBlend()
{
ShapeFirst = character.Mother,
ShapeSecond = character.Father,
ShapeThird = 0,
SkinFirst = character.Mother,
SkinSecond = character.Father,
SkinThird = 0,
ShapeMix = character.Similarity,
SkinMix = character.SkinSimilarity,
ThirdMix = 0.0f
};
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
//Haare und Haarfarbe
player.SetClothes(2, character.Hair, 0);
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
//Augenfarbe
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
}
}
}
}