SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // shitcode will be better in the future
  2. const NativeUI = require("nativeui");
  3. const Data = require("charcreator/data");
  4.  
  5. const Menu = NativeUI.Menu;
  6. const UIMenuItem = NativeUI.UIMenuItem;
  7. const UIMenuListItem = NativeUI.UIMenuListItem;
  8. const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
  9. const BadgeStyle = NativeUI.BadgeStyle;
  10. const Point = NativeUI.Point;
  11. const ItemsCollection = NativeUI.ItemsCollection;
  12. const Color = NativeUI.Color;
  13.  
  14. const creatorCoords = {
  15.     camera: new mp.Vector3(402.8664, -997.5515, -98.5),
  16.     cameraLookAt: new mp.Vector3(402.8664, -996.4108, -98.5)
  17. };
  18.  
  19. const localPlayer = mp.players.local;
  20.  
  21. function getRandomInt(min, max) {
  22.     return Math.floor(Math.random() * (max - min + 1)) + min;
  23. }
  24.  
  25. function colorForOverlayIdx(index) {
  26.     let color;
  27.  
  28.     switch (index) {
  29.         case 1:
  30.             color = beardColorItem.Index;
  31.         break;
  32.  
  33.         case 2:
  34.             color = eyebrowColorItem.Index;
  35.         break;
  36.  
  37.         case 5:
  38.             color = blushColorItem.Index;
  39.         break;
  40.  
  41.         case 8:
  42.             color = lipstickColorItem.Index;
  43.         break;
  44.  
  45.         case 10:
  46.             color = chestHairColorItem.Index;
  47.         break;
  48.  
  49.         default:
  50.             color = 0;
  51.     }
  52.  
  53.     return color;
  54. }
  55.  
  56. function updateParents() {
  57.     localPlayer.setHeadBlendData(
  58.         // shape
  59.         Data.mothers[motherItem.Index],
  60.         Data.fathers[fatherItem.Index],
  61.         0,
  62.  
  63.         // skin
  64.         Data.mothers[motherItem.Index],
  65.         Data.fathers[fatherItem.Index],
  66.         0,
  67.  
  68.         // mixes
  69.         similarityItem.Index * 0.01,
  70.         skinSimilarityItem.Index * 0.01,
  71.         0.0,
  72.  
  73.         false
  74.     );
  75. }
  76.  
  77. function updateFaceFeature(index) {
  78.     localPlayer.setFaceFeature(index, parseFloat(featureItems[index].SelectedValue));
  79. }
  80.  
  81. function updateAppearance(index) {
  82.     let overlayID = (appearanceItems[index].Index == 0) ? 255 : appearanceItems[index].Index - 1;
  83.     localPlayer.setHeadOverlay(index, overlayID, appearanceOpacityItems[index].Index * 0.01, colorForOverlayIdx(index), 0);
  84. }
  85.  
  86. function updateHairAndColors() {
  87.     localPlayer.setComponentVariation(2, Data.hairList[currentGender][hairItem.Index].ID, 0, 2);
  88.     localPlayer.setHairColor(hairColorItem.Index, hairHighlightItem.Index);
  89.     localPlayer.setEyeColor(eyeColorItem.Index);
  90.     localPlayer.setHeadOverlayColor(1, 1, beardColorItem.Index, 0);
  91.     localPlayer.setHeadOverlayColor(2, 1, eyebrowColorItem.Index, 0);
  92.     localPlayer.setHeadOverlayColor(5, 2, blushColorItem.Index, 0);
  93.     localPlayer.setHeadOverlayColor(8, 2, lipstickColorItem.Index, 0);
  94.     localPlayer.setHeadOverlayColor(10, 1, chestHairColorItem.Index, 0);
  95. }
  96.  
  97. function applyCreatorOutfit() {
  98.     if (currentGender == 0) {
  99.         localPlayer.setDefaultComponentVariation();
  100.         localPlayer.setComponentVariation(3, 15, 0, 2);
  101.         localPlayer.setComponentVariation(4, 21, 0, 2);
  102.         localPlayer.setComponentVariation(6, 34, 0, 2);
  103.         localPlayer.setComponentVariation(8, 15, 0, 2);
  104.         localPlayer.setComponentVariation(11, 15, 0, 2);
  105.     } else {
  106.         localPlayer.setDefaultComponentVariation();
  107.         localPlayer.setComponentVariation(3, 15, 0, 2);
  108.         localPlayer.setComponentVariation(4, 10, 0, 2);
  109.         localPlayer.setComponentVariation(6, 35, 0, 2);
  110.         localPlayer.setComponentVariation(8, 15, 0, 2);
  111.         localPlayer.setComponentVariation(11, 15, 0, 2);
  112.     }
  113. }
  114.  
  115. function fillHairMenu() {
  116.     hairItem = new UIMenuListItem("Hair", "Your character's hair.", new ItemsCollection(Data.hairList[currentGender].map(h => h.Name)));
  117.     creatorHairMenu.AddItem(hairItem);
  118.  
  119.     hairColorItem = new UIMenuListItem("Hair Color", "Your character's hair color.", new ItemsCollection(hairColors));
  120.     creatorHairMenu.AddItem(hairColorItem);
  121.  
  122.     hairHighlightItem = new UIMenuListItem("Hair Highlight Color", "Your character's hair highlight color.", new ItemsCollection(hairColors));
  123.     creatorHairMenu.AddItem(hairHighlightItem);
  124.  
  125.     eyebrowColorItem = new UIMenuListItem("Eyebrow Color", "Your character's eyebrow color.", new ItemsCollection(hairColors));
  126.     creatorHairMenu.AddItem(eyebrowColorItem);
  127.  
  128.     beardColorItem = new UIMenuListItem("Facial Hair Color", "Your character's facial hair color.", new ItemsCollection(hairColors));
  129.     creatorHairMenu.AddItem(beardColorItem);
  130.  
  131.     eyeColorItem = new UIMenuListItem("Eye Color", "Your character's eye color.", new ItemsCollection(Data.eyeColors));
  132.     creatorHairMenu.AddItem(eyeColorItem);
  133.  
  134.     blushColorItem = new UIMenuListItem("Blush Color", "Your character's blush color.", new ItemsCollection(blushColors));
  135.     creatorHairMenu.AddItem(blushColorItem);
  136.  
  137.     lipstickColorItem = new UIMenuListItem("Lipstick Color", "Your character's lipstick color.", new ItemsCollection(lipstickColors));
  138.     creatorHairMenu.AddItem(lipstickColorItem);
  139.  
  140.     chestHairColorItem = new UIMenuListItem("Chest Hair Color", "Your character's chest hair color.", new ItemsCollection(hairColors));
  141.     creatorHairMenu.AddItem(chestHairColorItem);
  142.  
  143.     creatorHairMenu.AddItem(new UIMenuItem("Randomize", "~r~Randomizes your hair & colors."));
  144.     creatorHairMenu.AddItem(new UIMenuItem("Reset", "~r~Resets your hair & colors."));
  145. }
  146.  
  147. function resetParentsMenu(refresh = false) {
  148.     fatherItem.Index = 0;
  149.     motherItem.Index = 0;
  150.     similarityItem.Index = (currentGender == 0) ? 100 : 0;
  151.     skinSimilarityItem.Index = (currentGender == 0) ? 100 : 0;
  152.  
  153.     updateParents();
  154.     if (refresh) creatorParentsMenu.RefreshIndex();
  155. }
  156.  
  157. function resetFeaturesMenu(refresh = false) {
  158.     for (let i = 0; i < Data.featureNames.length; i++) {
  159.         featureItems[i].Index = 100;
  160.         updateFaceFeature(i);
  161.     }
  162.  
  163.     if (refresh) creatorFeaturesMenu.RefreshIndex();
  164. }
  165.  
  166. function resetAppearanceMenu(refresh = false) {
  167.     for (let i = 0; i < Data.appearanceNames.length; i++) {
  168.         appearanceItems[i].Index = 0;
  169.         appearanceOpacityItems[i].Index = 100;
  170.         updateAppearance(i);
  171.     }
  172.  
  173.     if (refresh) creatorAppearanceMenu.RefreshIndex();
  174. }
  175.  
  176. function resetHairAndColorsMenu(refresh = false) {
  177.     hairItem.Index = 0;
  178.     hairColorItem.Index = 0;
  179.     hairHighlightItem.Index = 0;
  180.     eyebrowColorItem.Index = 0;
  181.     beardColorItem.Index = 0;
  182.     eyeColorItem.Index = 0;
  183.     blushColorItem.Index = 0;
  184.     lipstickColorItem.Index = 0;
  185.     chestHairColorItem.Index = 0;
  186.     updateHairAndColors();
  187.  
  188.     if (refresh) creatorHairMenu.RefreshIndex();
  189. }
  190.  
  191. let currentGender = 0;
  192. let creatorMenus = [];
  193. let creatorCamera;
  194.  
  195. // color arrays
  196. let hairColors = [];
  197. for (let i = 0; i < Data.maxHairColor; i++) hairColors.push(i.toString());
  198.  
  199. let blushColors = [];
  200. for (let i = 0; i < Data.maxBlushColor; i++) blushColors.push(i.toString());
  201.  
  202. let lipstickColors = [];
  203. for (let i = 0; i < Data.maxLipstickColor; i++) lipstickColors.push(i.toString());
  204.  
  205. // CREATOR MAIN
  206. let creatorMainMenu = new Menu("Creator", "", new Point(50, 50));
  207. let genderItem = new UIMenuListItem("Gender", "~r~Changing this will reset your customization.", new ItemsCollection(["Male", "Female"]));
  208. creatorMainMenu.AddItem(genderItem);
  209. creatorMainMenu.AddItem(new UIMenuItem("Parents", "Your character's parents."));
  210. creatorMainMenu.AddItem(new UIMenuItem("Features", "Your character's facial features."));
  211. creatorMainMenu.AddItem(new UIMenuItem("Appearance", "Your character's appearance."));
  212. creatorMainMenu.AddItem(new UIMenuItem("Hair & Colors", "Your character's hair and hair colors."));
  213.  
  214. let angles = [];
  215. for (let i = -180.0; i <= 180.0; i += 5.0) angles.push(i.toFixed(1));
  216. let angleItem = new UIMenuListItem("Angle", "", new ItemsCollection(angles));
  217. creatorMainMenu.AddItem(angleItem);
  218.  
  219. let saveItem = new UIMenuItem("Save", "Save all changes.");
  220. saveItem.BackColor = new Color(13, 71, 161);
  221. saveItem.HighlightedBackColor = new Color(25, 118, 210);
  222. creatorMainMenu.AddItem(saveItem);
  223.  
  224. let cancelItem = new UIMenuItem("Cancel", "Discard all changes.");
  225. cancelItem.BackColor = new Color(213, 0, 0);
  226. cancelItem.HighlightedBackColor = new Color(229, 57, 53);
  227. creatorMainMenu.AddItem(cancelItem);
  228.  
  229. creatorMainMenu.ListChange.on((item, listIndex) => {
  230.     if (item == genderItem) {
  231.         currentGender = listIndex;
  232.         mp.events.callRemote("creator_GenderChange", listIndex);
  233.  
  234.         setTimeout(() => {
  235.             localPlayer.clearTasksImmediately();
  236.             applyCreatorOutfit();
  237.             angleItem.Index = 0;
  238.             resetParentsMenu(true);
  239.             resetFeaturesMenu(true);
  240.             resetAppearanceMenu(true);
  241.  
  242.             creatorHairMenu.Clear();
  243.             fillHairMenu();
  244.             creatorHairMenu.RefreshIndex();
  245.         }, 200);
  246.     } else if (item == angleItem) {
  247.         localPlayer.setHeading(parseFloat(angleItem.SelectedValue));
  248.         localPlayer.clearTasksImmediately();
  249.     }
  250. });
  251.  
  252. creatorMainMenu.ItemSelect.on((item, index) => {
  253.     switch (index) {
  254.         case 1:
  255.             creatorMainMenu.Visible = false;
  256.             creatorParentsMenu.Visible = true;
  257.         break;
  258.  
  259.         case 2:
  260.             creatorMainMenu.Visible = false;
  261.             creatorFeaturesMenu.Visible = true;
  262.         break;
  263.  
  264.         case 3:
  265.             creatorMainMenu.Visible = false;
  266.             creatorAppearanceMenu.Visible = true;
  267.         break;
  268.  
  269.         case 4:
  270.             creatorMainMenu.Visible = false;
  271.             creatorHairMenu.Visible = true;
  272.         break;
  273.  
  274.         case 6:
  275.             let parentData = {
  276.                 Father: Data.fathers[fatherItem.Index],
  277.                 Mother: Data.mothers[motherItem.Index],
  278.                 Similarity: similarityItem.Index * 0.01,
  279.                 SkinSimilarity: skinSimilarityItem.Index * 0.01
  280.             };
  281.  
  282.             let featureData = [];
  283.             for (let i = 0; i < featureItems.length; i++) featureData.push(parseFloat(featureItems[i].SelectedValue));
  284.  
  285.             let appearanceData = [];
  286.             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});
  287.  
  288.             let hairAndColors = [
  289.                 Data.hairList[currentGender][hairItem.Index].ID,
  290.                 hairColorItem.Index,
  291.                 hairHighlightItem.Index,
  292.                 eyebrowColorItem.Index,
  293.                 beardColorItem.Index,
  294.                 eyeColorItem.Index,
  295.                 blushColorItem.Index,
  296.                 lipstickColorItem.Index,
  297.                 chestHairColorItem.Index
  298.             ];
  299.  
  300.             mp.events.callRemote("creator_Save", currentGender, JSON.stringify(parentData), JSON.stringify(featureData), JSON.stringify(appearanceData), JSON.stringify(hairAndColors));
  301.         break;
  302.  
  303.         case 7:
  304.             mp.events.callRemote("creator_Leave");
  305.         break;
  306.     }
  307. });
  308.  
  309. creatorMainMenu.MenuClose.on(() => {
  310.     mp.events.callRemote("creator_Leave");
  311. });
  312.  
  313. creatorMainMenu.Visible = false;
  314. creatorMenus.push(creatorMainMenu);
  315. // CREATOR MAIN END
  316.  
  317. // CREATOR PARENTS
  318. let similarities = [];
  319. for (let i = 0; i <= 100; i++) similarities.push(i + "%");
  320.  
  321. let creatorParentsMenu = new Menu("Parents", "", new Point(50, 50));
  322. let fatherItem = new UIMenuListItem("Father", "Your character's father.", new ItemsCollection(Data.fatherNames));
  323. let motherItem = new UIMenuListItem("Mother", "Your character's mother.", new ItemsCollection(Data.motherNames));
  324. let similarityItem = new UIMenuListItem("Resemblance", "Similarity to parents.\n(lower = feminine, higher = masculine)", new ItemsCollection(similarities));
  325. let skinSimilarityItem = new UIMenuListItem("Skin Tone", "Skin color similarity to parents.\n(lower = mother's, higher = father's)", new ItemsCollection(similarities));
  326. creatorParentsMenu.AddItem(fatherItem);
  327. creatorParentsMenu.AddItem(motherItem);
  328. creatorParentsMenu.AddItem(similarityItem);
  329. creatorParentsMenu.AddItem(skinSimilarityItem);
  330. creatorParentsMenu.AddItem(new UIMenuItem("Randomize", "~r~Randomizes your parents."));
  331. creatorParentsMenu.AddItem(new UIMenuItem("Reset", "~r~Resets your parents."));
  332.  
  333. creatorParentsMenu.ItemSelect.on((item, index) => {
  334.     switch (item.Text) {
  335.         case "Randomize":
  336.             fatherItem.Index = getRandomInt(0, Data.fathers.length - 1);
  337.             motherItem.Index = getRandomInt(0, Data.mothers.length - 1);
  338.             similarityItem.Index = getRandomInt(0, 100);
  339.             skinSimilarityItem.Index = getRandomInt(0, 100);
  340.             updateParents();
  341.         break;
  342.  
  343.         case "Reset":
  344.             resetParentsMenu();
  345.         break;
  346.     }
  347. });
  348.  
  349. creatorParentsMenu.ListChange.on((item, listIndex) => {
  350.     updateParents();
  351. });
  352.  
  353. creatorParentsMenu.ParentMenu = creatorMainMenu;
  354. creatorParentsMenu.Visible = false;
  355. creatorMenus.push(creatorParentsMenu);
  356. // CREATOR PARENTS END
  357.  
  358. // CREATOR FEATURES
  359. let featureItems = [];
  360. let features = [];
  361. for (let i = -1.0; i <= 1.01; i += 0.01) features.push(i.toFixed(2));
  362.  
  363. let creatorFeaturesMenu = new Menu("Features", "", new Point(50, 50));
  364.  
  365. for (let i = 0; i < Data.featureNames.length; i++) {
  366.     let tempFeatureItem = new UIMenuListItem(Data.featureNames[i], "", new ItemsCollection(features));
  367.     tempFeatureItem.Index = 100;
  368.     featureItems.push(tempFeatureItem);
  369.     creatorFeaturesMenu.AddItem(tempFeatureItem);
  370. }
  371.  
  372. creatorFeaturesMenu.AddItem(new UIMenuItem("Randomize", "~r~Randomizes your features."));
  373. creatorFeaturesMenu.AddItem(new UIMenuItem("Reset", "~r~Resets your features."));
  374.  
  375. creatorFeaturesMenu.ItemSelect.on((item, index) => {
  376.     switch (item.Text) {
  377.         case "Randomize":
  378.             for (let i = 0; i < Data.featureNames.length; i++) {
  379.                 featureItems[i].Index = getRandomInt(0, 200);
  380.                 updateFaceFeature(i);
  381.             }
  382.         break;
  383.  
  384.         case "Reset":
  385.             resetFeaturesMenu();
  386.         break;
  387.     }
  388. });
  389.  
  390. creatorFeaturesMenu.ListChange.on((item, listIndex) => {
  391.     updateFaceFeature(featureItems.indexOf(item));
  392. });
  393.  
  394. creatorFeaturesMenu.ParentMenu = creatorMainMenu;
  395. creatorFeaturesMenu.Visible = false;
  396. creatorMenus.push(creatorFeaturesMenu);
  397. // CREATOR FEATURES END
  398.  
  399. // CREATOR APPEARANCE
  400. let appearanceItems = [];
  401. let appearanceOpacityItems = [];
  402. let opacities = [];
  403. for (let i = 0; i <= 100; i++) opacities.push(i + "%");
  404.  
  405. let creatorAppearanceMenu = new Menu("Appearance", "", new Point(50, 50));
  406.  
  407. for (let i = 0; i < Data.appearanceNames.length; i++) {
  408.     let items = [];
  409.     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]);
  410.  
  411.     let tempAppearanceItem = new UIMenuListItem(Data.appearanceNames[i], "", new ItemsCollection(items));
  412.     appearanceItems.push(tempAppearanceItem);
  413.     creatorAppearanceMenu.AddItem(tempAppearanceItem);
  414.  
  415.     let tempAppearanceOpacityItem = new UIMenuListItem(Data.appearanceNames[i] + " Opacity", "", new ItemsCollection(opacities));
  416.     tempAppearanceOpacityItem.Index = 100;
  417.     appearanceOpacityItems.push(tempAppearanceOpacityItem);
  418.     creatorAppearanceMenu.AddItem(tempAppearanceOpacityItem);
  419. }
  420.  
  421. creatorAppearanceMenu.AddItem(new UIMenuItem("Randomize", "~r~Randomizes your appearance."));
  422. creatorAppearanceMenu.AddItem(new UIMenuItem("Reset", "~r~Resets your appearance."));
  423.  
  424. creatorAppearanceMenu.ItemSelect.on((item, index) => {
  425.     switch (item.Text) {
  426.         case "Randomize":
  427.             for (let i = 0; i < Data.appearanceNames.length; i++) {
  428.                 appearanceItems[i].Index = getRandomInt(0, mp.game.ped.getNumHeadOverlayValues(i) - 1);
  429.                 appearanceOpacityItems[i].Index = getRandomInt(0, 100);
  430.                 updateAppearance(i);
  431.             }
  432.         break;
  433.  
  434.         case "Reset":
  435.             resetAppearanceMenu();
  436.         break;
  437.     }
  438. });
  439.  
  440. creatorAppearanceMenu.ListChange.on((item, listIndex) => {
  441.     let idx = (creatorAppearanceMenu.CurrentSelection % 2 == 0) ? (creatorAppearanceMenu.CurrentSelection / 2) : Math.floor(creatorAppearanceMenu.CurrentSelection / 2);
  442.     updateAppearance(idx);
  443. });
  444.  
  445. creatorAppearanceMenu.ParentMenu = creatorMainMenu;
  446. creatorAppearanceMenu.Visible = false;
  447. creatorMenus.push(creatorAppearanceMenu);
  448. // CREATOR APPEARANCE END
  449.  
  450. // CREATOR HAIR & COLORS
  451. let hairItem;
  452. let hairColorItem;
  453. let hairHighlightItem;
  454. let eyebrowColorItem;
  455. let beardColorItem;
  456. let eyeColorItem;
  457. let blushColorItem;
  458. let lipstickColorItem;
  459. let chestHairColorItem;
  460.  
  461. creatorHairMenu = new Menu("Hair & Colors", "", new Point(50, 50));
  462. fillHairMenu();
  463.  
  464. creatorHairMenu.ItemSelect.on((item, index) => {
  465.     switch (item.Text) {
  466.         case "Randomize":
  467.             hairItem.Index = getRandomInt(0, Data.hairList[currentGender].length - 1);
  468.             hairColorItem.Index = getRandomInt(0, Data.maxHairColor);
  469.             hairHighlightItem.Index = getRandomInt(0, Data.maxHairColor);
  470.             eyebrowColorItem.Index = getRandomInt(0, Data.maxHairColor);
  471.             beardColorItem.Index = getRandomInt(0, Data.maxHairColor);
  472.             eyeColorItem.Index = getRandomInt(0, Data.maxEyeColor);
  473.             blushColorItem.Index = getRandomInt(0, Data.maxBlushColor);
  474.             lipstickColorItem.Index = getRandomInt(0, Data.maxLipstickColor);
  475.             chestHairColorItem.Index = getRandomInt(0, Data.maxHairColor);
  476.             updateHairAndColors();
  477.         break;
  478.  
  479.         case "Reset":
  480.             resetHairAndColorsMenu();
  481.         break;
  482.     }
  483. });
  484.  
  485. creatorHairMenu.ListChange.on((item, listIndex) => {
  486.     if (item == hairItem) {
  487.         let hairStyle = Data.hairList[currentGender][listIndex];
  488.         localPlayer.setComponentVariation(2, hairStyle.ID, 0, 2);
  489.     } else {
  490.         switch (creatorHairMenu.CurrentSelection) {
  491.             case 1: // hair color
  492.                 localPlayer.setHairColor(listIndex, hairHighlightItem.Index);
  493.             break;
  494.  
  495.             case 2: // hair highlight color
  496.                 localPlayer.setHairColor(hairColorItem.Index, listIndex);
  497.             break;
  498.  
  499.             case 3: // eyebrow color
  500.                 localPlayer.setHeadOverlayColor(2, 1, listIndex, 0);
  501.             break;
  502.  
  503.             case 4: // facial hair color
  504.                 localPlayer.setHeadOverlayColor(1, 1, listIndex, 0);
  505.             break;
  506.  
  507.             case 5: // eye color
  508.                 localPlayer.setEyeColor(listIndex);
  509.             break;
  510.  
  511.             case 6: // blush color
  512.                 localPlayer.setHeadOverlayColor(5, 2, listIndex, 0);
  513.             break;
  514.  
  515.             case 7: // lipstick color
  516.                 localPlayer.setHeadOverlayColor(8, 2, listIndex, 0);
  517.             break;
  518.  
  519.             case 8: // chest hair color
  520.                 localPlayer.setHeadOverlayColor(10, 1, listIndex, 0);
  521.             break;
  522.         }
  523.     }
  524. });
  525.  
  526. creatorHairMenu.ParentMenu = creatorMainMenu;
  527. creatorHairMenu.Visible = false;
  528. creatorMenus.push(creatorHairMenu);
  529. // CREATOR HAIR & COLORS END
  530.  
  531. // EVENTS
  532. mp.events.add("toggleCreator", (active, charData) => {
  533.     if (active) {
  534.         if (creatorCamera === undefined) {
  535.             creatorCamera = mp.cameras.new("creatorCamera", creatorCoords.camera, new mp.Vector3(0, 0, 0), 45);
  536.             creatorCamera.pointAtCoord(creatorCoords.cameraLookAt);
  537.             creatorCamera.setActive(true);
  538.         }
  539.  
  540.         // update menus with current character data
  541.         if (charData) {
  542.             charData = JSON.parse(charData);
  543.  
  544.             // gender
  545.             currentGender = charData.Gender;
  546.             genderItem.Index = charData.Gender;
  547.  
  548.             creatorHairMenu.Clear();
  549.             fillHairMenu();
  550.             applyCreatorOutfit();
  551.  
  552.             // parents
  553.             fatherItem.Index = Data.fathers.indexOf(charData.Parents.Father);
  554.             motherItem.Index = Data.mothers.indexOf(charData.Parents.Mother);
  555.             similarityItem.Index = parseInt(charData.Parents.Similarity * 100);
  556.             skinSimilarityItem.Index = parseInt(charData.Parents.SkinSimilarity * 100);
  557.             updateParents();
  558.  
  559.             // features
  560.             for (let i = 0; i < charData.Features.length; i++) {
  561.                 featureItems[i].Index = (charData.Features[i] * 100) + 100;
  562.                 updateFaceFeature(i);
  563.             }
  564.  
  565.             // hair and colors
  566.             let hair = Data.hairList[currentGender].find(h => h.ID == charData.Hair.Hair);
  567.             hairItem.Index = Data.hairList[currentGender].indexOf(hair);
  568.  
  569.             hairColorItem.Index = charData.Hair.Color;
  570.             hairHighlightItem.Index = charData.Hair.HighlightColor;
  571.             eyebrowColorItem.Index = charData.EyebrowColor;
  572.             beardColorItem.Index = charData.BeardColor;
  573.             eyeColorItem.Index = charData.EyeColor;
  574.             blushColorItem.Index = charData.BlushColor;
  575.             lipstickColorItem.Index = charData.LipstickColor;
  576.             chestHairColorItem.Index = charData.ChestHairColor;
  577.             updateHairAndColors();
  578.  
  579.             // appearance
  580.             for (let i = 0; i < charData.Appearance.length; i++) {
  581.                 appearanceItems[i].Index = (charData.Appearance[i].Value == 255) ? 0 : charData.Appearance[i].Value + 1;
  582.                 appearanceOpacityItems[i].Index = charData.Appearance[i].Opacity * 100;
  583.                 updateAppearance(i);
  584.             }
  585.         }
  586.  
  587.         creatorMainMenu.Visible = true;
  588.         mp.gui.chat.show(false);
  589.         mp.game.ui.displayRadar(false);
  590.         mp.game.ui.displayHud(false);
  591.         localPlayer.clearTasksImmediately();
  592.         localPlayer.freezePosition(true);
  593.  
  594.         mp.game.cam.renderScriptCams(true, false, 0, true, false);
  595.     } else {
  596.         for (let i = 0; i < creatorMenus.length; i++) creatorMenus[i].Visible = false;
  597.         mp.gui.chat.show(true);
  598.         mp.game.ui.displayRadar(true);
  599.         mp.game.ui.displayHud(true);
  600.         localPlayer.freezePosition(false);
  601.         localPlayer.setDefaultComponentVariation();
  602.         localPlayer.setComponentVariation(2, Data.hairList[currentGender][hairItem.Index].ID, 0, 2);
  603.  
  604.         mp.game.cam.renderScriptCams(false, false, 0, true, false);
  605.     }
  606. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top