Init commit surgery branch

This commit is contained in:
VegaZ
2021-04-22 22:24:27 +02:00
parent 2ab112795a
commit 922acd6847
8 changed files with 3000 additions and 0 deletions

View File

@@ -0,0 +1,590 @@
import * as NativeUI from '../libs/NativeUI';
import * as Data from './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 Font = NativeUI.Font;
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
const creatorCoords = {
camera: new mp.Vector3(265.6026, -1340.2378, 25.000),
cameraLookAt: new mp.Vector3(266.472, -1339.1357, 25.000)
};
const localPlayer = mp.players.local;
export default function charSurgery(globalData: IGlobalData) {
var creatorHairMenu;
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;
let creatorMenus: NativeUI.Menu[] = [];
let creatorCamera: CameraMp;
// 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("Chirurg", "", new Point(0, screenRes.y / 3), null, null);
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("Erstellen", "Erstellt deinen Charakter.");
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 5:
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);
creatorCamera.destroy(true);
mp.events.callRemote("SaveSurgery", currentGender, JSON.stringify(parentData), JSON.stringify(featureData), JSON.stringify(appearanceData));
globalData.InMenu = false;
globalData.InMenu = false;
break;
case 6:
leaveCreator();
break;
}
});
creatorMainMenu.MenuClose.on(() => {
leaveCreator();
});
function leaveCreator() {
mp.gui.chat.show(true);
mp.game.ui.displayRadar(true);
mp.game.ui.displayHud(true);
localPlayer.freezePosition(false);
mp.game.cam.renderScriptCams(false, false, 0, true, false);
creatorCamera.destroy(true);
mp.events.callRemote("surgeryLeave");
globalData.InMenu = false;
globalData.InMenu = false;
}
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(0, screenRes.y / 3), null, null);
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(0, screenRes.y / 3), null, null);
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(0, screenRes.y / 3), null, null);
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(0, screenRes.y / 3), null, null);
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 0: // eyebrow color
localPlayer.setHeadOverlayColor(2, 1, listIndex, 0);
break;
case 1: // facial hair color
localPlayer.setHeadOverlayColor(1, 1, listIndex, 0);
break;
case 2: // eye color
localPlayer.setEyeColor(listIndex);
break;
case 3: // blush color
localPlayer.setHeadOverlayColor(5, 2, listIndex, 0);
break;
case 4: // lipstick color
localPlayer.setHeadOverlayColor(8, 2, listIndex, 0);
break;
case 5: // 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("toggleSurgery", () => {
if (!mp.cameras.exists(creatorCamera)) {
creatorCamera = mp.cameras.new("creatorCamera", creatorCoords.camera, new mp.Vector3(0, 0, 0), 45);
creatorCamera.pointAtCoord(creatorCoords.cameraLookAt.x, creatorCoords.cameraLookAt.y, creatorCoords.cameraLookAt.z);
creatorCamera.setActive(true);
globalData.InMenu = true;
globalData.InMenu = 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);
});
*/
creatorMenus.forEach(menu => {
menu.Visible = false;
})
}

View File

@@ -268,6 +268,9 @@ antiAfk(globalData);
import ammunation from './Interaction/ammunation/ammunation';
ammunation(globalData);
import charSurgery from './CharCreator/surgery';
charSurgery(globalData);
import spawnschutz from './Player/spawnschutz';
spawnschutz();

View File

@@ -127,6 +127,8 @@ namespace ReallifeGamemode.Database.Entities
public int warn { get; set; } = 0;
public bool FreeSurgery { get; set; } = true;
[NotMapped]
public Player Player
{

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class Surgery : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs");
migrationBuilder.AddColumn<bool>(
name: "FreeSurgery",
table: "Users",
nullable: false,
defaultValue: false);
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "ChatLogs",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs",
column: "FactionId",
principalTable: "Factions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs",
column: "GroupId",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs");
migrationBuilder.DropForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs");
migrationBuilder.DropColumn(
name: "FreeSurgery",
table: "Users");
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "ChatLogs",
type: "int",
nullable: true,
oldClrType: typeof(int));
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Users_UserId",
table: "ChatLogs",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Factions_FactionId",
table: "ChatLogs",
column: "FactionId",
principalTable: "Factions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ChatLogs_Groups_GroupId",
table: "ChatLogs",
column: "GroupId",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View File

@@ -1450,6 +1450,9 @@ namespace ReallifeGamemode.Database.Migrations
b.Property<bool>("FlyingLicensePlane")
.HasColumnType("tinyint(1)");
b.Property<bool>("FreeSurgery")
.HasColumnType("tinyint(1)");
b.Property<int?>("GroupId")
.HasColumnType("int");

View File

@@ -550,6 +550,10 @@ namespace ReallifeGamemode.Server.Events
nearestAmmunationPoint.Ammunation.LoadShopNUI(player);
}
}
if (CharacterCreator.surgeryPoint.DistanceTo(player.Position) <= 1.5)
{
CharacterCreator.StartSurgery(player);
}
if (user.FactionLeader)
{
player.TriggerEvent("CLIENT:StartGangwar");

View File

@@ -1,6 +1,7 @@
using System.Linq;
using GTANetworkAPI;
using Newtonsoft.Json.Linq;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
@@ -8,6 +9,17 @@ namespace ReallifeGamemode.Server.Managers
{
public class CharacterCreator : Script
{
public static Vector3 surgeryPoint = new Vector3(258.581, -1345.1406, 24.5378);
public CharacterCreator()
{
var point = surgeryPoint;
NAPI.Marker.CreateMarker(1, new Vector3(point.X, point.Y, point.Z - 2), new Vector3(point.X, point.Y, point.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Chirurg - Dr\u00fccke ~y~E", point, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
[RemoteEvent("creator_GenderChange")]
public void changeGender(Player player, int gender)
{
@@ -409,5 +421,105 @@ namespace ReallifeGamemode.Server.Managers
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
}
}
public static void StartSurgery(Player player)
{
/*
var gender;
var featureData;
var parentData;
var appearanceData;
using (var dbContext = new DatabaseContext())
{
User user = player.GetUser();
var character = dbContext.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
if (character == null) return;
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 };
}*/
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
currentPlayerCreatorDimension++;
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
player.SafeTeleport(new Vector3(266.472, -1339.1357, 24.5378));
player.Heading = 146.35101f;
player.TriggerEvent("toggleSurgery");
//player.TriggerEvent("toggleSurgery", bool gender, string parentData, string featureData, string appearanceData)
}
[RemoteEvent("surgeryLeave")]
public static void LeaveSurgery(Player player)
{
player.Dimension = 0;
player.SafeTeleport(new Vector3(258.581, -1345.1406, 24.5378), Main.DEFAULT_SPAWN_HEADING, true);
ApplyCharacter(player);
}
[RemoteEvent("SaveSurgery")]
public static void SaveSurgery(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
{
player.SafeTeleport(new Vector3(258.581, -1345.1406, 24.5378), Main.DEFAULT_SPAWN_HEADING, true);
var jParentData = JObject.Parse(parentData);
var jFeatureData = JArray.Parse(featureData);
var jAppearanceData = JArray.Parse(appearanceData);
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");
ApplyCharacter(player);
}
}
}