Finished migration to TypeScript, temporary disabled char creator
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
const NativeUI = require('../nativeui');
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
const ListItem = NativeUI.ListItem;
|
||||
|
||||
const moneyFormat = require("../moneyformat");
|
||||
|
||||
var shopMenu;
|
||||
|
||||
mp.events.add('ShopVehicle_OpenMenu', (businessName, price) => {
|
||||
var veh = mp.players.local.vehicle;
|
||||
if (!veh) return;
|
||||
mp.gui.chat.show(false);
|
||||
shopMenu = new Menu("Fahrzeugkauf", "Kaufe ein neues Auto", new Point(50, 50));
|
||||
|
||||
var carItem = new UIMenuItem("Fahrzeugname");
|
||||
carItem.SetRightLabel(mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(veh.model)));
|
||||
shopMenu.AddItem(carItem);
|
||||
|
||||
var shopItem = new UIMenuItem("Autohaus");
|
||||
shopItem.SetRightLabel(businessName);
|
||||
shopMenu.AddItem(shopItem);
|
||||
|
||||
var priceItem = new UIMenuItem("Preis");
|
||||
priceItem.SetRightLabel("~g~$~s~ "+ moneyFormat(price));
|
||||
shopMenu.AddItem(priceItem);
|
||||
|
||||
var saveItem = new UIMenuItem("Kaufen");
|
||||
saveItem.BackColor = new Color(0, 100, 0);
|
||||
saveItem.HighlightedBackColor = new Color(0, 150, 0);
|
||||
shopMenu.AddItem(saveItem);
|
||||
|
||||
var cancelItem = new UIMenuItem("Abbrechen");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
shopMenu.AddItem(cancelItem);
|
||||
|
||||
shopMenu.ItemSelect.on((item, index) => {
|
||||
if (item === cancelItem) {
|
||||
shopMenu.Close();
|
||||
} else if (item === saveItem) {
|
||||
mp.events.callRemote("VehShop_BuyVehicle");
|
||||
shopMenu.Close();
|
||||
}
|
||||
});
|
||||
|
||||
shopMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.show(true);
|
||||
mp.players.local.taskLeaveVehicle(veh.handle, 0);
|
||||
});
|
||||
|
||||
shopMenu.Open();
|
||||
});
|
||||
63
ReallifeGamemode.Client/Business/cardealer.ts
Normal file
63
ReallifeGamemode.Client/Business/cardealer.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
const ListItem = NativeUI.ListItem;
|
||||
|
||||
import moneyFormat from '../moneyformat';
|
||||
|
||||
export default function carDealer() {
|
||||
|
||||
var shopMenu;
|
||||
|
||||
mp.events.add('ShopVehicle_OpenMenu', (businessName, price) => {
|
||||
var veh = mp.players.local.vehicle;
|
||||
if (!veh) return;
|
||||
mp.gui.chat.show(false);
|
||||
shopMenu = new Menu("Fahrzeugkauf", "Kaufe ein neues Auto", new Point(50, 50), null, null);
|
||||
|
||||
var carItem = new UIMenuItem("Fahrzeugname");
|
||||
carItem.SetRightLabel(mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(veh.model)));
|
||||
shopMenu.AddItem(carItem);
|
||||
|
||||
var shopItem = new UIMenuItem("Autohaus");
|
||||
shopItem.SetRightLabel(businessName);
|
||||
shopMenu.AddItem(shopItem);
|
||||
|
||||
var priceItem = new UIMenuItem("Preis");
|
||||
priceItem.SetRightLabel("~g~$~s~ " + moneyFormat(price));
|
||||
shopMenu.AddItem(priceItem);
|
||||
|
||||
var saveItem = new UIMenuItem("Kaufen");
|
||||
saveItem.BackColor = new Color(0, 100, 0);
|
||||
saveItem.HighlightedBackColor = new Color(0, 150, 0);
|
||||
shopMenu.AddItem(saveItem);
|
||||
|
||||
var cancelItem = new UIMenuItem("Abbrechen");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
shopMenu.AddItem(cancelItem);
|
||||
|
||||
shopMenu.ItemSelect.on((item, index) => {
|
||||
if (item === cancelItem) {
|
||||
shopMenu.Close();
|
||||
} else if (item === saveItem) {
|
||||
mp.events.callRemote("VehShop_BuyVehicle");
|
||||
shopMenu.Close();
|
||||
}
|
||||
});
|
||||
|
||||
shopMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.show(true);
|
||||
mp.players.local.taskLeaveVehicle(veh.handle, 0);
|
||||
});
|
||||
|
||||
shopMenu.Open();
|
||||
});
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
var keyBound = false;
|
||||
|
||||
var closeMenu = false;
|
||||
|
||||
var businessName;
|
||||
var businessMoney;
|
||||
var mainMenu;
|
||||
var bankMenu;
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
const ListItem = NativeUI.ListItem;
|
||||
|
||||
const InputHelper = require("../inputhelper");
|
||||
|
||||
mp.events.add('business_showHelp', (bizName, bizMoney) => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Business zu verwalten');
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
businessName = bizName;
|
||||
businessMoney = bizMoney;
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
mp.events.add('business_removeHelp', (unbind) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
mp.gui.chat.show(true);
|
||||
|
||||
if (keyBound && unbind) {
|
||||
if (typeof mainMenu !== "undefined") mainMenu.Close();
|
||||
if (typeof bankMenu !== "undefined") {
|
||||
closeMenu = true;
|
||||
bankMenu.Close();
|
||||
}
|
||||
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('business_updateMoney', (newMoney) => {
|
||||
businessMoney = newMoney;
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
mp.events.call('business_removeHelp', false);
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
if (typeof mainMenu !== "undefined" && mainMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof bankMenu !== "undefined" && bankMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainMenu = new Menu("Businessverwaltung", businessName, new Point(50, 50));
|
||||
|
||||
var bankAccountItem = new UIMenuItem("Businesskasse", "Verwalte die Businesskasse");
|
||||
bankAccountItem.SetRightLabel("~g~~h~" + businessMoney);
|
||||
mainMenu.AddItem(bankAccountItem);
|
||||
|
||||
//var partnerItem = new UIMenuItem("Inteilhaber", "Verwalte den Inteilhaber");
|
||||
//partnerItem.SetRightLabel("Niemand");
|
||||
//mainMenu.AddItem(partnerItem);
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
mainMenu.ItemSelect.on((item, index) => {
|
||||
if (item === bankAccountItem) {
|
||||
// manage bank account
|
||||
|
||||
bankMenu = new Menu("Bankkonto", businessName, new Point(50, 50));
|
||||
|
||||
var infoItem = new UIMenuItem("Aktueller Kontostand");
|
||||
infoItem.SetRightLabel("~g~~h~" + businessMoney);
|
||||
bankMenu.AddItem(infoItem);
|
||||
|
||||
var depositItem = new UIMenuItem("Einzahlen", "Zahle Geld auf die Businesskasse ein");
|
||||
bankMenu.AddItem(depositItem);
|
||||
|
||||
var withdrawItem = new UIMenuItem("Auszahlen", "Zahle Geld von der Businesskasse aus");
|
||||
bankMenu.AddItem(withdrawItem);
|
||||
|
||||
bankMenu.ItemSelect.on((item, index) => {
|
||||
if (item === depositItem) {
|
||||
var depositInput = new InputHelper("Wie viel Geld möchtest du auf deine Businesskasse einzahlen?");
|
||||
depositInput.show();
|
||||
depositInput.getValue((data) => {
|
||||
var amount = parseInt(data);
|
||||
if (isNaN(amount)) {
|
||||
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
|
||||
return;
|
||||
}
|
||||
|
||||
mp.events.callRemote('Business_DepositMoney', amount);
|
||||
});
|
||||
} else if (item === withdrawItem) {
|
||||
var withdrawInput = new InputHelper("Wie viel Geld möchtest du von deiner Businesskasse abheben?");
|
||||
withdrawInput.show();
|
||||
withdrawInput.getValue((data) => {
|
||||
var amount = parseInt(data);
|
||||
if (isNaN(amount)) {
|
||||
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
|
||||
return;
|
||||
}
|
||||
|
||||
mp.events.callRemote('Business_WithdrawMoney', amount);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bankMenu.MenuClose.on(() => {
|
||||
if (closeMenu) {
|
||||
closeMenu = false;
|
||||
return;
|
||||
}
|
||||
mainMenu.Visible = true;
|
||||
});
|
||||
|
||||
bankMenu.Visible = true;
|
||||
mainMenu.Visible = false;
|
||||
|
||||
} else if (item === partnerItem) {
|
||||
// manage partner
|
||||
}
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
mp.events.call('business_removeHelp', false);
|
||||
});
|
||||
}
|
||||
147
ReallifeGamemode.Client/Business/main.ts
Normal file
147
ReallifeGamemode.Client/Business/main.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
const ListItem = NativeUI.ListItem;
|
||||
|
||||
import InputHelper from '../inputhelper';
|
||||
|
||||
export default function business() {
|
||||
|
||||
var keyBound = false;
|
||||
|
||||
var closeMenu = false;
|
||||
|
||||
var businessName;
|
||||
var businessMoney;
|
||||
var mainMenu;
|
||||
var bankMenu;
|
||||
|
||||
mp.events.add('business_showHelp', (bizName, bizMoney) => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Business zu verwalten');
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
businessName = bizName;
|
||||
businessMoney = bizMoney;
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
mp.events.add('business_removeHelp', (unbind) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
mp.gui.chat.show(true);
|
||||
|
||||
if (keyBound && unbind) {
|
||||
if (typeof mainMenu !== "undefined") mainMenu.Close();
|
||||
if (typeof bankMenu !== "undefined") {
|
||||
closeMenu = true;
|
||||
bankMenu.Close();
|
||||
}
|
||||
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('business_updateMoney', (newMoney) => {
|
||||
businessMoney = newMoney;
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
mp.events.call('business_removeHelp', false);
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
if (typeof mainMenu !== "undefined" && mainMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof bankMenu !== "undefined" && bankMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainMenu = new Menu("Businessverwaltung", businessName, new Point(50, 50), null, null);
|
||||
|
||||
var bankAccountItem = new UIMenuItem("Businesskasse", "Verwalte die Businesskasse");
|
||||
bankAccountItem.SetRightLabel("~g~~h~" + businessMoney);
|
||||
mainMenu.AddItem(bankAccountItem);
|
||||
|
||||
//var partnerItem = new UIMenuItem("Inteilhaber", "Verwalte den Inteilhaber");
|
||||
//partnerItem.SetRightLabel("Niemand");
|
||||
//mainMenu.AddItem(partnerItem);
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
mainMenu.ItemSelect.on((item, index) => {
|
||||
if (item === bankAccountItem) {
|
||||
// manage bank account
|
||||
|
||||
bankMenu = new Menu("Bankkonto", businessName, new Point(50, 50), null, null);
|
||||
|
||||
var infoItem = new UIMenuItem("Aktueller Kontostand");
|
||||
infoItem.SetRightLabel("~g~~h~" + businessMoney);
|
||||
bankMenu.AddItem(infoItem);
|
||||
|
||||
var depositItem = new UIMenuItem("Einzahlen", "Zahle Geld auf die Businesskasse ein");
|
||||
bankMenu.AddItem(depositItem);
|
||||
|
||||
var withdrawItem = new UIMenuItem("Auszahlen", "Zahle Geld von der Businesskasse aus");
|
||||
bankMenu.AddItem(withdrawItem);
|
||||
|
||||
bankMenu.ItemSelect.on((item, index) => {
|
||||
if (item === depositItem) {
|
||||
var depositInput = new InputHelper("Wie viel Geld möchtest du auf deine Businesskasse einzahlen?");
|
||||
depositInput.show();
|
||||
depositInput.getValue((data) => {
|
||||
var amount = parseInt(data);
|
||||
if (isNaN(amount)) {
|
||||
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
|
||||
return;
|
||||
}
|
||||
|
||||
mp.events.callRemote('Business_DepositMoney', amount);
|
||||
});
|
||||
} else if (item === withdrawItem) {
|
||||
var withdrawInput = new InputHelper("Wie viel Geld möchtest du von deiner Businesskasse abheben?");
|
||||
withdrawInput.show();
|
||||
withdrawInput.getValue((data) => {
|
||||
var amount = parseInt(data);
|
||||
if (isNaN(amount)) {
|
||||
mp.game.graphics.notify('~r~Du musst eine Nummer eingeben!');
|
||||
return;
|
||||
}
|
||||
|
||||
mp.events.callRemote('Business_WithdrawMoney', amount);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
bankMenu.MenuClose.on(() => {
|
||||
if (closeMenu) {
|
||||
closeMenu = false;
|
||||
return;
|
||||
}
|
||||
mainMenu.Visible = true;
|
||||
});
|
||||
|
||||
bankMenu.Visible = true;
|
||||
mainMenu.Visible = false;
|
||||
|
||||
}
|
||||
//else if (item === partnerItem) {
|
||||
// // manage partner
|
||||
//}
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
mp.events.call('business_removeHelp', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -119,18 +119,23 @@ const hairList = [
|
||||
|
||||
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
|
||||
const maxHairColor = 64;
|
||||
const maxEyeColor = 32;
|
||||
const maxBlushColor = 27;
|
||||
const maxLipstickColor = 32;
|
||||
|
||||
export {
|
||||
fathers,
|
||||
mothers,
|
||||
fatherNames,
|
||||
motherNames,
|
||||
featureNames,
|
||||
appearanceNames,
|
||||
appearanceItemNames,
|
||||
hairList,
|
||||
eyeColors,
|
||||
maxHairColor,
|
||||
maxEyeColor,
|
||||
maxBlushColor,
|
||||
maxLipstickColor
|
||||
};
|
||||
@@ -1,564 +0,0 @@
|
||||
// shitcode will be better in the future
|
||||
// , \u00dc, \u00fc
|
||||
// , \u00c4, \u00e4
|
||||
// , \u00d6, \u00f6
|
||||
// \u00df
|
||||
|
||||
var creatorHairMenu;
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
const Data = require("./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("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 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);
|
||||
});
|
||||
572
ReallifeGamemode.Client/CharCreator/main.ts
Normal file
572
ReallifeGamemode.Client/CharCreator/main.ts
Normal file
@@ -0,0 +1,572 @@
|
||||
// shitcode will be better in the future
|
||||
// , \u00dc, \u00fc
|
||||
// , \u00c4, \u00e4
|
||||
// , \u00d6, \u00f6
|
||||
// \u00df
|
||||
|
||||
|
||||
import * as NativeUI from '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 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;
|
||||
|
||||
export default function charCreator() {
|
||||
|
||||
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 = 0;
|
||||
let creatorMenus: NativeUI.Menu[] = [];
|
||||
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), 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 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), 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(50, 50), 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(50, 50), 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(50, 50), 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 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);
|
||||
});
|
||||
|
||||
creatorMenus.forEach(menu => {
|
||||
menu.Visible = false;
|
||||
})
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
mp.events.add('changeDoorState', (doorHash, x, y, z, locked, p5, p6, p7) => {
|
||||
locked === 1 ? locked = true : locked = false;
|
||||
|
||||
mp.game.object.doorControl(doorHash, x, y, z, locked, p5, p6, p7);
|
||||
});
|
||||
7
ReallifeGamemode.Client/DoorManager/doormanager.ts
Normal file
7
ReallifeGamemode.Client/DoorManager/doormanager.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function doorManager() {
|
||||
mp.events.add('changeDoorState', (doorHash, x, y, z, locked, p5, p6, p7) => {
|
||||
locked === 1 ? locked = true : locked = false;
|
||||
|
||||
mp.game.object.doorControl(doorHash, x, y, z, locked, p5, p6, p7);
|
||||
});
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Faction Manager Main (main.js)
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var manageFactionRanksBrowser = null;
|
||||
var rankData = null;
|
||||
|
||||
mp.events.add('manageFactionRanks', (ranks) => {
|
||||
if (manageFactionRanksBrowser !== null) return;
|
||||
manageFactionRanksBrowser = mp.browsers.new('package://assets/html/factionmanagement/ranks/index.html');
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
rankData = JSON.parse(ranks);
|
||||
});
|
||||
|
||||
mp.events.add('onManageFactionRanksLoaded', () => {
|
||||
if (manageFactionRanksBrowser !== null) {
|
||||
|
||||
manageFactionRanksBrowser.execute(`loadData(` + JSON.stringify(rankData.Ranks) + `)`);
|
||||
mp.gui.cursor.show(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('saveFactionRankData', function (data) {
|
||||
if (manageFactionRanksBrowser !== null) {
|
||||
manageFactionRanksBrowser.destroy();
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
|
||||
var obj = new Object();
|
||||
obj.FactionId = rankData.FactionId;
|
||||
obj.Ranks = JSON.parse(data);
|
||||
|
||||
mp.events.callRemote('OnFactionRanksEdit', JSON.stringify(obj));
|
||||
|
||||
manageFactionRanksBrowser = null;
|
||||
}
|
||||
});
|
||||
44
ReallifeGamemode.Client/FactionManagement/main.ts
Normal file
44
ReallifeGamemode.Client/FactionManagement/main.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Faction Manager Main (main.js)
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
export default function factionManagement() {
|
||||
|
||||
var manageFactionRanksBrowser = null;
|
||||
var rankData = null;
|
||||
|
||||
mp.events.add('manageFactionRanks', (ranks) => {
|
||||
if (manageFactionRanksBrowser !== null) return;
|
||||
manageFactionRanksBrowser = mp.browsers.new('package://assets/html/factionmanagement/ranks/index.html');
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
rankData = JSON.parse(ranks);
|
||||
});
|
||||
|
||||
mp.events.add('onManageFactionRanksLoaded', () => {
|
||||
if (manageFactionRanksBrowser !== null) {
|
||||
|
||||
manageFactionRanksBrowser.execute(`loadData(` + JSON.stringify(rankData.Ranks) + `)`);
|
||||
mp.gui.cursor.show(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('saveFactionRankData', function (data) {
|
||||
if (manageFactionRanksBrowser !== null) {
|
||||
manageFactionRanksBrowser.destroy();
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
|
||||
var obj: FactionRanks = {
|
||||
factionId: rankData.FactionId,
|
||||
ranks: JSON.parse(data)
|
||||
};
|
||||
|
||||
mp.events.callRemote('OnFactionRanksEdit', JSON.stringify(obj));
|
||||
|
||||
manageFactionRanksBrowser = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
1061
ReallifeGamemode.Client/Gui/Inventory/inventory.ts
Normal file
1061
ReallifeGamemode.Client/Gui/Inventory/inventory.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Gui Infobox infobox.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var playerName;
|
||||
var playerId;
|
||||
var playerMoney;
|
||||
var dutyMedics = 0;
|
||||
|
||||
var isDeath = false;
|
||||
var deathTime;
|
||||
var respawnTime;
|
||||
var deathSeconds;
|
||||
var fade;
|
||||
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
|
||||
mp.events.add("startDeathTimer", (isAdmin) => {
|
||||
if (isDeath === false) {
|
||||
isDeath = true;
|
||||
if (isAdmin) {
|
||||
mp.gui.chat.activate(true);
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.activate(false);
|
||||
}
|
||||
mp.game.audio.playSoundFrontend(-1, "Bed", "WastedSounds", true);
|
||||
deathDate = new Date();
|
||||
respawnTime = Math.floor(deathDate.getTime() / 1000 + 120);
|
||||
fade = 255 - 120;
|
||||
mp.game.graphics.requestStreamedTextureDict("Mptattoos", true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("onPlayerRevived", () => {
|
||||
isDeath = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("Mptattoos");
|
||||
});
|
||||
|
||||
mp.events.add("respawnDeathPlayer", () => {
|
||||
isDeath = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("Mptattoos");
|
||||
});
|
||||
|
||||
mp.events.add("updateDutyMedics", (count) => {
|
||||
dutyMedics = count;
|
||||
});
|
||||
|
||||
|
||||
|
||||
mp.events.add("render", () => {
|
||||
currentDate = new Date();
|
||||
|
||||
if (isDeath === true) {
|
||||
|
||||
var medicString;
|
||||
if (dutyMedics > 0) {
|
||||
medicString = "Derzeit ";
|
||||
if (dutyMedics === 1) {
|
||||
medicString += "ist ~g~" + dutyMedics + " Medic";
|
||||
} else {
|
||||
medicString = "sind ~g~" + dutyMedics + " Medics";
|
||||
}
|
||||
medicString += " ~s~im Dienst ~c~und versuchen dich wiederzubeleben...";
|
||||
} else {
|
||||
medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst.";
|
||||
}
|
||||
|
||||
deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000);
|
||||
var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000);
|
||||
if (deathSeconds >= 0) {
|
||||
mp.game.graphics.set2dLayer(2);
|
||||
mp.game.graphics.drawSprite("Mptattoos", "clearout", 0.625, 0.52, 0.1, 0.1, 0, 255, 255, 255, 236);
|
||||
mp.game.graphics.drawText("Respawn in: ~y~" + deathSeconds, [0.5, 0.5],
|
||||
{
|
||||
font: 7,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.8, 0.8],
|
||||
outline: true
|
||||
});
|
||||
mp.game.graphics.drawText(medicString, [0.5, 0.975],
|
||||
{
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true
|
||||
});
|
||||
mp.game.graphics.set2dLayer(1);
|
||||
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||
|
||||
} else {
|
||||
mp.events.call("respawnDeathPlayer");
|
||||
}
|
||||
}
|
||||
});
|
||||
108
ReallifeGamemode.Client/Gui/deathscreen.ts
Normal file
108
ReallifeGamemode.Client/Gui/deathscreen.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Gui Infobox infobox.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
export default function deathScreen() {
|
||||
|
||||
var playerName;
|
||||
var playerId;
|
||||
var playerMoney;
|
||||
var dutyMedics = 0;
|
||||
|
||||
var isDeath = false;
|
||||
var deathTime;
|
||||
var respawnTime;
|
||||
var deathSeconds;
|
||||
var fade;
|
||||
var deathDate: Date;
|
||||
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
|
||||
mp.events.add("startDeathTimer", (isAdmin) => {
|
||||
if (isDeath === false) {
|
||||
isDeath = true;
|
||||
if (isAdmin) {
|
||||
mp.gui.chat.activate(true);
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.activate(false);
|
||||
}
|
||||
mp.game.audio.playSoundFrontend(-1, "Bed", "WastedSounds", true);
|
||||
deathDate = new Date();
|
||||
respawnTime = Math.floor(deathDate.getTime() / 1000 + 120);
|
||||
fade = 255 - 120;
|
||||
mp.game.graphics.requestStreamedTextureDict("Mptattoos", true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("onPlayerRevived", () => {
|
||||
isDeath = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("Mptattoos");
|
||||
});
|
||||
|
||||
mp.events.add("respawnDeathPlayer", () => {
|
||||
isDeath = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("Mptattoos");
|
||||
});
|
||||
|
||||
mp.events.add("updateDutyMedics", (count) => {
|
||||
dutyMedics = count;
|
||||
});
|
||||
|
||||
|
||||
|
||||
mp.events.add("render", () => {
|
||||
var currentDate = new Date();
|
||||
|
||||
if (isDeath === true) {
|
||||
|
||||
var medicString;
|
||||
if (dutyMedics > 0) {
|
||||
medicString = "Derzeit ";
|
||||
if (dutyMedics === 1) {
|
||||
medicString += "ist ~g~" + dutyMedics + " Medic";
|
||||
} else {
|
||||
medicString = "sind ~g~" + dutyMedics + " Medics";
|
||||
}
|
||||
medicString += " ~s~im Dienst ~c~und versuchen dich wiederzubeleben...";
|
||||
} else {
|
||||
medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst.";
|
||||
}
|
||||
|
||||
deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000);
|
||||
var alpha = fade + Math.floor(currentDate.getTime() / 1000 - deathDate.getTime() / 1000);
|
||||
if (deathSeconds >= 0) {
|
||||
mp.game.graphics.set2dLayer(2);
|
||||
mp.game.graphics.drawSprite("Mptattoos", "clearout", 0.625, 0.52, 0.1, 0.1, 0, 255, 255, 255, 236);
|
||||
mp.game.graphics.drawText("Respawn in: ~y~" + deathSeconds, [0.5, 0.5],
|
||||
{
|
||||
font: 7,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.8, 0.8],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
mp.game.graphics.drawText(medicString, [0.5, 0.975],
|
||||
{
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
mp.game.graphics.set2dLayer(1);
|
||||
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||
|
||||
} else {
|
||||
mp.events.call("respawnDeathPlayer");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
var keyBound = false;
|
||||
var interiorId = -1;
|
||||
var enterExit = undefined;
|
||||
|
||||
mp.events.add('InteriorManager_ClearHelpText', () => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
|
||||
enterExit = undefined;
|
||||
|
||||
if (keyBound) {
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('InteriorManager_ShowHelpText', (interior, intId, entEx) => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um ~b~' + interior + ' ~s~zu ' + (entEx === 0 ? 'betreten' : 'verlassen'));
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
interiorId = intId;
|
||||
enterExit = entEx;
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
if (globalData.InChat) return;
|
||||
mp.events.callRemote('InteriorManager_UseTeleport', interiorId, enterExit);
|
||||
}
|
||||
34
ReallifeGamemode.Client/Gui/interiors.ts
Normal file
34
ReallifeGamemode.Client/Gui/interiors.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export default function interiors(globalData: GlobalData) {
|
||||
|
||||
var keyBound = false;
|
||||
var interiorId = -1;
|
||||
var enterExit = undefined;
|
||||
|
||||
mp.events.add('InteriorManager_ClearHelpText', () => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
|
||||
enterExit = undefined;
|
||||
|
||||
if (keyBound) {
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('InteriorManager_ShowHelpText', (interior, intId, entEx) => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um ~b~' + interior + ' ~s~zu ' + (entEx === 0 ? 'betreten' : 'verlassen'));
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
interiorId = intId;
|
||||
enterExit = entEx;
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
if (globalData.InChat) return;
|
||||
mp.events.callRemote('InteriorManager_UseTeleport', interiorId, enterExit);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
const maxDistance = 25 * 25;
|
||||
const width = 0.03;
|
||||
const height = 0.0065;
|
||||
const border = 0.001;
|
||||
const color = [255, 255, 255, 255];
|
||||
|
||||
mp.nametags.enabled = false;
|
||||
|
||||
mp.events.add('render', (nametags) => {
|
||||
const graphics = mp.game.graphics;
|
||||
const screenRes = graphics.getScreenResolution(0, 0);
|
||||
|
||||
nametags.forEach(nametag => {
|
||||
let [player, x, y, distance] = nametag;
|
||||
|
||||
if (distance <= maxDistance) {
|
||||
let scale = distance / maxDistance;
|
||||
if (scale < 0.6) scale = 0.6;
|
||||
|
||||
var health = player.getHealth();
|
||||
health = health < 100 ? 0 : (health - 100) / 100;
|
||||
|
||||
var armour = player.getArmour() / 100;
|
||||
|
||||
y -= scale * (0.005 * (screenRes.y / 1080));
|
||||
|
||||
mp.game.graphics.drawText(player.name + " (" + player.remoteId + ")", [x, y],
|
||||
{
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true
|
||||
});
|
||||
|
||||
if (mp.game.player.isFreeAimingAtEntity(player.handle)) {
|
||||
let y2 = y + 0.042;
|
||||
|
||||
if (armour > 0) {
|
||||
graphics.drawRect(x, y2, width + border * 2, 0.0085, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2, width, height, 150, 150, 150, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200);
|
||||
|
||||
x2 = x + width / 2 + border / 2;
|
||||
|
||||
graphics.drawRect(x, y2 + height, width + border * 2, height + border * 2, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2 + height, width, height, 41, 66, 78, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - armour), y2 + height, width * armour, height, 48, 108, 135, 200);
|
||||
}
|
||||
else {
|
||||
graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2, width, height, 150, 150, 150, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
61
ReallifeGamemode.Client/Gui/nametags.ts
Normal file
61
ReallifeGamemode.Client/Gui/nametags.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
const maxDistance = 25 * 25;
|
||||
const width = 0.03;
|
||||
const height = 0.0065;
|
||||
const border = 0.001;
|
||||
const color = [255, 255, 255, 255];
|
||||
|
||||
export default function customNametags() {
|
||||
|
||||
mp.nametags.enabled = false;
|
||||
|
||||
mp.events.add('render', (nametags) => {
|
||||
const graphics = mp.game.graphics;
|
||||
const screenRes = graphics.getScreenResolution(0, 0);
|
||||
|
||||
nametags.forEach(nametag => {
|
||||
let [player, x, y, distance] = nametag;
|
||||
|
||||
if (distance <= maxDistance) {
|
||||
let scale = distance / maxDistance;
|
||||
if (scale < 0.6) scale = 0.6;
|
||||
|
||||
var health = player.getHealth();
|
||||
health = health < 100 ? 0 : (health - 100) / 100;
|
||||
|
||||
var armour = player.getArmour() / 100;
|
||||
|
||||
y -= scale * (0.005 * (screenRes.y / 1080));
|
||||
|
||||
mp.game.graphics.drawText(player.name + " (" + player.remoteId + ")", [x, y],
|
||||
{
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
if (mp.game.player.isPlayerFreeAimingAtEntity(player.handle)) {
|
||||
let y2 = y + 0.042;
|
||||
|
||||
if (armour > 0) {
|
||||
graphics.drawRect(x, y2, width + border * 2, 0.0085, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2, width, height, 150, 150, 150, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200);
|
||||
|
||||
var x2 = x + width / 2 + border / 2;
|
||||
|
||||
graphics.drawRect(x, y2 + height, width + border * 2, height + border * 2, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2 + height, width, height, 41, 66, 78, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - armour), y2 + height, width * armour, height, 48, 108, 135, 200);
|
||||
}
|
||||
else {
|
||||
graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200);
|
||||
graphics.drawRect(x, y2, width, height, 150, 150, 150, 255);
|
||||
graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Gui Playerlist playerlist.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var playerlistBrowser
|
||||
var pList;
|
||||
|
||||
mp.events.add("showPlayerlist", () => {
|
||||
if (!playerlistBrowser) {
|
||||
playerlistBrowser = mp.browsers.new('package://Gui/playerlist.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("fetchPlayerList", (playersJson) => {
|
||||
|
||||
pList = JSON.parse(playersJson);
|
||||
|
||||
pList.forEach((player) => {
|
||||
mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//function getTable() {
|
||||
// var table = "";
|
||||
// pList.forEach((player) => {
|
||||
// var tableRow = "<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td>";
|
||||
// table = table + tableRow;
|
||||
// })
|
||||
// return document.write(table);
|
||||
//}
|
||||
37
ReallifeGamemode.Client/Gui/playerlist.ts
Normal file
37
ReallifeGamemode.Client/Gui/playerlist.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Gui Playerlist playerlist.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
export default function playerList() {
|
||||
|
||||
var playerlistBrowser
|
||||
var pList;
|
||||
|
||||
mp.events.add("showPlayerlist", () => {
|
||||
if (!playerlistBrowser) {
|
||||
playerlistBrowser = mp.browsers.new('package://Gui/playerlist.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("fetchPlayerList", (playersJson) => {
|
||||
|
||||
pList = JSON.parse(playersJson);
|
||||
|
||||
pList.forEach((player) => {
|
||||
mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//function getTable() {
|
||||
// var table = "";
|
||||
// pList.forEach((player) => {
|
||||
// var tableRow = "<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td>";
|
||||
// table = table + tableRow;
|
||||
// })
|
||||
// return document.write(table);
|
||||
//}
|
||||
@@ -1,103 +0,0 @@
|
||||
let menuBrowser = null;
|
||||
|
||||
const NativeUI = require('../../nativeui');
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||
const UIMenuSliderItem = NativeUI.UIMenuSliderItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
const Color = NativeUI.Color;
|
||||
const ListItem = NativeUI.ListItem;
|
||||
|
||||
mp.events.add('ToggleVehicleMenu', () => {
|
||||
if (menuBrowser !== null) {
|
||||
menuBrowser.destroy();
|
||||
menuBrowser = null;
|
||||
mp.gui.chat.show(true);
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.game.graphics.stopScreenEffect("FocusIn");
|
||||
mp.game.graphics.startScreenEffect("FocusOut", 0, false);
|
||||
return;
|
||||
}
|
||||
|
||||
mp.game.graphics.stopScreenEffect("FocusOut");
|
||||
mp.game.graphics.startScreenEffect("FocusIn", 0, false);
|
||||
menuBrowser = mp.browsers.new("package://assets/html/vehiclemenu/index.html");
|
||||
mp.gui.chat.show(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
});
|
||||
|
||||
mp.events.add('doAction', (action) => {
|
||||
mp.events.call('ToggleVehicleMenu');
|
||||
switch (action) {
|
||||
case 8: // Motor
|
||||
mp.events.callRemote("VehicleMenu_ToggleEngine");
|
||||
break;
|
||||
case 5: // Auf -/ Abschließen
|
||||
mp.events.callRemote("VehicleMenu_LockCar");
|
||||
break;
|
||||
case 3: // Türen
|
||||
showDoorsMenu();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function showDoorsMenu() {
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
var doorMenu = new Menu("Türen", "Türen verwalten", new Point(50, 50));
|
||||
|
||||
doorMenu.AddItem(new UIMenuListItem("Tür", "Welche Tür darf's sein?", new ItemsCollection([
|
||||
" Fahrertür",
|
||||
" Beifahrertür",
|
||||
"Hinten links",
|
||||
"Hinten rechts",
|
||||
"Motorhaube",
|
||||
"Kofferraum"
|
||||
])));
|
||||
|
||||
doorMenu.AddItem(new UIMenuItem("Alle öffnen", "Öffnet alle Türen"));
|
||||
doorMenu.AddItem(new UIMenuItem("Alle schließen", "Schließt alle Türen"));
|
||||
|
||||
doorMenu.ItemSelect.on((item, index) => {
|
||||
if (index === 0) {
|
||||
var doorId = -1;
|
||||
switch (item.SelectedItem.DisplayText) {
|
||||
case " Fahrertür":
|
||||
doorId = 0;
|
||||
break;
|
||||
case " Beifahrertür":
|
||||
doorId = 1;
|
||||
break;
|
||||
case "Hinten links":
|
||||
doorId = 2;
|
||||
break;
|
||||
case "Hinten rechts":
|
||||
doorId = 3;
|
||||
break;
|
||||
case "Motorhaube":
|
||||
doorId = 4;
|
||||
break;
|
||||
case "Kofferraum":
|
||||
doorId = 5;
|
||||
break;
|
||||
}
|
||||
if (doorId !== -1) {
|
||||
mp.events.callRemote("VehicleMenu_ToggleSingleDoor", doorId);
|
||||
}
|
||||
} else if (index === 1) {
|
||||
mp.events.callRemote("VehicleMenu_OpenAllDoors");
|
||||
} else if (index === 2) {
|
||||
mp.events.callRemote("VehicleMenu_CloseAllDoors");
|
||||
}
|
||||
});
|
||||
|
||||
doorMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.show(true);
|
||||
});
|
||||
|
||||
doorMenu.Open();
|
||||
}
|
||||
103
ReallifeGamemode.Client/Gui/vehiclemenu/main.ts
Normal file
103
ReallifeGamemode.Client/Gui/vehiclemenu/main.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||
const Point = NativeUI.Point;
|
||||
const ItemsCollection = NativeUI.ItemsCollection;
|
||||
|
||||
export default function vehicleMenu() {
|
||||
|
||||
|
||||
let menuBrowser = null;
|
||||
|
||||
mp.events.add('ToggleVehicleMenu', () => {
|
||||
if (menuBrowser !== null) {
|
||||
menuBrowser.destroy();
|
||||
menuBrowser = null;
|
||||
mp.gui.chat.show(true);
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.game.graphics.stopScreenEffect("FocusIn");
|
||||
mp.game.graphics.startScreenEffect("FocusOut", 0, false);
|
||||
return;
|
||||
}
|
||||
|
||||
mp.game.graphics.stopScreenEffect("FocusOut");
|
||||
mp.game.graphics.startScreenEffect("FocusIn", 0, false);
|
||||
menuBrowser = mp.browsers.new("package://assets/html/vehiclemenu/index.html");
|
||||
mp.gui.chat.show(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
});
|
||||
|
||||
mp.events.add('doAction', (action) => {
|
||||
mp.events.call('ToggleVehicleMenu');
|
||||
switch (action) {
|
||||
case 8: // Motor
|
||||
mp.events.callRemote("VehicleMenu_ToggleEngine");
|
||||
break;
|
||||
case 5: // Auf -/ Abschließen
|
||||
mp.events.callRemote("VehicleMenu_LockCar");
|
||||
break;
|
||||
case 3: // Türen
|
||||
showDoorsMenu();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function showDoorsMenu() {
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
var doorMenu = new Menu("Türen", "Türen verwalten", new Point(50, 50), null, null);
|
||||
|
||||
doorMenu.AddItem(new UIMenuListItem("Tür", "Welche Tür darf's sein?", new ItemsCollection([
|
||||
" Fahrertür",
|
||||
" Beifahrertür",
|
||||
"Hinten links",
|
||||
"Hinten rechts",
|
||||
"Motorhaube",
|
||||
"Kofferraum"
|
||||
])));
|
||||
|
||||
doorMenu.AddItem(new UIMenuItem("Alle öffnen", "Öffnet alle Türen"));
|
||||
doorMenu.AddItem(new UIMenuItem("Alle schließen", "Schließt alle Türen"));
|
||||
|
||||
doorMenu.ItemSelect.on((item, index) => {
|
||||
if (index === 0) {
|
||||
var doorId = -1;
|
||||
switch (item.SelectedItem.DisplayText) {
|
||||
case " Fahrertür":
|
||||
doorId = 0;
|
||||
break;
|
||||
case " Beifahrertür":
|
||||
doorId = 1;
|
||||
break;
|
||||
case "Hinten links":
|
||||
doorId = 2;
|
||||
break;
|
||||
case "Hinten rechts":
|
||||
doorId = 3;
|
||||
break;
|
||||
case "Motorhaube":
|
||||
doorId = 4;
|
||||
break;
|
||||
case "Kofferraum":
|
||||
doorId = 5;
|
||||
break;
|
||||
}
|
||||
if (doorId !== -1) {
|
||||
mp.events.callRemote("VehicleMenu_ToggleSingleDoor", doorId);
|
||||
}
|
||||
} else if (index === 1) {
|
||||
mp.events.callRemote("VehicleMenu_OpenAllDoors");
|
||||
} else if (index === 2) {
|
||||
mp.events.callRemote("VehicleMenu_CloseAllDoors");
|
||||
}
|
||||
});
|
||||
|
||||
doorMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.show(true);
|
||||
});
|
||||
|
||||
doorMenu.Open();
|
||||
}
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
var player = mp.players.local;
|
||||
var tasks;
|
||||
var initTasks;
|
||||
var newTasks;
|
||||
var sorting = 0;
|
||||
var firstSorting = true;
|
||||
var activeTask = false;
|
||||
var activeCheckpoint;
|
||||
var taskStart;
|
||||
var taskFinish;
|
||||
var taskRange;
|
||||
var ambulanceImagePos;
|
||||
var rangeLeft;
|
||||
var sortText;
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
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;
|
||||
|
||||
var factionInteractionMenu;
|
||||
var reviveTaskMenu;
|
||||
|
||||
mp.events.add("updateFactionBlips", (type, taskList) => {
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("showFactionInteraction", (userFactionId, isDuty, userFactionName, isFactionLeader, reviveTaskCount, healTaskCount, fireTaskCount) => {
|
||||
mp.gui.chat.activate(false);
|
||||
globalData.Interaction = true;
|
||||
|
||||
var rP = ((reviveTaskCount === "0") ? "~r~" : "~g~");
|
||||
var hP = ((healTaskCount === "0") ? "~r~" : "~g~");
|
||||
var fP = ((fireTaskCount === "0") ? "~r~" : "~g~");
|
||||
|
||||
factionInteractionMenu = new Menu("Fraktionsinteraktion", userFactionName, new Point(0, screenRes.y / 2));
|
||||
|
||||
if (isFactionLeader) {
|
||||
let leaderMenu = new UIMenuItem("Leadermen\u00fc", "Verwaltung der Fraktion");
|
||||
leaderMenu.SetRightBadge(BadgeStyle.Star);
|
||||
factionInteractionMenu.AddItem(leaderMenu);
|
||||
}
|
||||
let reviveTaskMenu;
|
||||
let healTaskMenu;
|
||||
let fireTaskMenu;
|
||||
if (isDuty)
|
||||
{
|
||||
switch (userFactionId)
|
||||
{
|
||||
case 2:
|
||||
reviveTaskMenu = new UIMenuItem("Reviveauftr\u00e4ge");
|
||||
reviveTaskMenu.SetRightLabel(rP + reviveTaskCount)
|
||||
factionInteractionMenu.AddItem(reviveTaskMenu);
|
||||
|
||||
healTaskMenu = new UIMenuItem("Healauftr\u00e4ge");
|
||||
healTaskMenu.SetRightLabel(hP + healTaskCount)
|
||||
factionInteractionMenu.AddItem(healTaskMenu);
|
||||
|
||||
fireTaskMenu = new UIMenuItem("Feuerauftr\u00e4ge");
|
||||
fireTaskMenu.SetRightLabel(fP + fireTaskCount)
|
||||
factionInteractionMenu.AddItem(fireTaskMenu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let cancelItem = new UIMenuItem("Schlie\u00dfen", "Schlie\u00dft die Fraktionsinteraktion");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
factionInteractionMenu.AddItem(cancelItem);
|
||||
|
||||
factionInteractionMenu.Visible = true;
|
||||
|
||||
factionInteractionMenu.ItemSelect.on((item) => {
|
||||
switch (item) {
|
||||
case cancelItem:
|
||||
factionInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
break;
|
||||
case reviveTaskMenu:
|
||||
mp.events.callRemote("loadMedicTasks", 0)
|
||||
factionInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
factionInteractionMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("showMedicTasks", (type, taskList) => {
|
||||
tasks = JSON.parse(taskList);
|
||||
if (sorting === 0) {
|
||||
initTasks = tasks;
|
||||
}
|
||||
|
||||
mp.events.call("sortFactionTasks", false);
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
globalData.Interaction = true;
|
||||
switch (type) {
|
||||
case 0:
|
||||
reviveTaskMenu = new Menu("Revives", "\u00c4lteste zu erst", new Point(0, screenRes.y / 2));
|
||||
let aTask;
|
||||
for (var i = 0; i < tasks.length; i++) {
|
||||
if (tasks[i].MedicName === "none") {
|
||||
aTask = new UIMenuItem("~g~" + tasks[i].Victim);
|
||||
} else {
|
||||
aTask = new UIMenuItem("~r~" + tasks[i].Victim);
|
||||
}
|
||||
|
||||
aTask.SetRightLabel(mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[i].Position.x, tasks[i].Position.y, tasks[i].Position.z, true).toFixed(2).toString() + " ~g~m");
|
||||
reviveTaskMenu.AddItem(aTask);
|
||||
}
|
||||
|
||||
let backItem = new UIMenuItem("Zur\u00fcck", "Zur\u00fcck zur Fraktionsinteraktion");
|
||||
backItem.BackColor = new Color(213, 0, 0);
|
||||
backItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
reviveTaskMenu.AddItem(backItem);
|
||||
|
||||
reviveTaskMenu.ItemSelect.on((item, index) => {
|
||||
if (item === backItem) {
|
||||
reviveTaskMenu.Visible = false;
|
||||
factionInteractionMenu.Visible = true;
|
||||
} else {
|
||||
if (tasks[index].MedicName === "none") {
|
||||
mp.game.graphics.requestStreamedTextureDict("medicimages", true);
|
||||
mp.events.callRemote("updateMedicTask", 0, index, player.name);
|
||||
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
||||
activeCheckpoint = mp.markers.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0, {
|
||||
color: [255, 0, 0, 150],
|
||||
visible: true,
|
||||
dimension: 0
|
||||
});
|
||||
reviveTaskMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
ambulanceImagePos = 0.325
|
||||
taskStart = player.position;
|
||||
taskFinish = tasks[index].Position;
|
||||
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
||||
activeTask = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reviveTaskMenu.MenuClose.on(() => {
|
||||
reviveTaskMenu.Visible = false;
|
||||
factionInteractionMenu.Visible = true;
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("sortFactionTasks", (sortByKey) => {
|
||||
if (firstSorting) {
|
||||
sortText = "Nach Uhrzeit";
|
||||
firstSorting = false;
|
||||
//mp.gui.chat.push("Init Sort");
|
||||
return;
|
||||
} else {
|
||||
if (sortByKey) {
|
||||
if (sorting < 1) {
|
||||
sorting++;
|
||||
} else {
|
||||
sorting = 0;
|
||||
}
|
||||
|
||||
switch (sorting) {
|
||||
case 0: //Standartsortierung
|
||||
|
||||
reviveTaskMenu.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Nach Uhrzeit";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(initTasks));
|
||||
break;
|
||||
|
||||
case 1: //Sortierung nach Metern (aufsteigend)
|
||||
for (var d = 0; d < tasks.length; d++) {
|
||||
for (var e = 0; e < tasks.length - 1; e++) {
|
||||
if (getDistance1(e) > getDistance2(e + 1)) {
|
||||
var tempTask = tasks[e];
|
||||
tasks[e] = tasks[e + 1];
|
||||
tasks[e + 1] = tempTask;
|
||||
mp.gui.chat.push("SWITCH");
|
||||
}
|
||||
}
|
||||
}
|
||||
reviveTaskMenu.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Entfernung aufsteigend";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(tasks));
|
||||
break;
|
||||
|
||||
//case 2: //Sortierung nach Metern (absteigend)
|
||||
// mp.gui.chat.push("Sorting 2");
|
||||
// sortText = "Entfernung absteigend";
|
||||
// break;
|
||||
//case 3: //Sortierung nach Zeit (aufsteigend)
|
||||
// mp.gui.chat.push("Sorting 3");
|
||||
// sortText = "Restzeit aufsteigend";
|
||||
// break;
|
||||
//case 4: //Sortierung nach Zeit (absteigend)
|
||||
// mp.gui.chat.push("Sorting 4");
|
||||
// sortText = "Restzeit absteigend";
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function getDistance1(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
function getDistance2(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
|
||||
mp.events.add('render', () => {
|
||||
if (activeTask) {
|
||||
rangeLeft = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true).toFixed(2);
|
||||
if (rangeLeft > 1.9) {
|
||||
ambulanceImagePos = 0.655 - (mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true) / taskRange * 0.35);
|
||||
mp.game.graphics.drawRect(0.5, 0.945, 0.35, 0.025, 150, 0, 0, 200);
|
||||
mp.game.graphics.drawText(rangeLeft.toString() + "m", [0.5, 0.93], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: true
|
||||
});
|
||||
if (taskRange < rangeLeft) ambulanceImagePos = 0.3;
|
||||
mp.game.graphics.drawSprite("medicimages", "finish", 0.655, 0.898, 0.04, 0.07, 0, 255, 255, 255, 255);
|
||||
if (player.isInAnyVehicle(false)) {
|
||||
mp.game.graphics.drawSprite("medicimages", "ambulance", ambulanceImagePos + 0.01, 0.915, 0.04, 0.07, 0, 255, 255, 255, 255);
|
||||
} else {
|
||||
mp.game.graphics.drawSprite("medicimages", "running", ambulanceImagePos + 0.02, 0.915, 0.02, 0.035, 0, 255, 0, 0, 255);
|
||||
}
|
||||
} else {
|
||||
activeTask = false;
|
||||
activeCheckpoint.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
259
ReallifeGamemode.Client/Interaction/factioninteraction.ts
Normal file
259
ReallifeGamemode.Client/Interaction/factioninteraction.ts
Normal file
@@ -0,0 +1,259 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
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;
|
||||
|
||||
export default function factionInteraction(globalData: GlobalData) {
|
||||
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
var player = mp.players.local;
|
||||
var tasks;
|
||||
var initTasks;
|
||||
var newTasks;
|
||||
var sorting = 0;
|
||||
var firstSorting = true;
|
||||
var activeTask = false;
|
||||
var activeCheckpoint;
|
||||
var taskStart;
|
||||
var taskFinish;
|
||||
var taskRange;
|
||||
var ambulanceImagePos;
|
||||
var rangeLeft;
|
||||
var sortText;
|
||||
|
||||
var factionInteractionMenu;
|
||||
var reviveTaskMenu;
|
||||
|
||||
mp.events.add("updateFactionBlips", (type, taskList) => {
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("showFactionInteraction", (userFactionId, isDuty, userFactionName, isFactionLeader, reviveTaskCount, healTaskCount, fireTaskCount) => {
|
||||
mp.gui.chat.activate(false);
|
||||
globalData.Interaction = true;
|
||||
|
||||
var rP = ((reviveTaskCount === "0") ? "~r~" : "~g~");
|
||||
var hP = ((healTaskCount === "0") ? "~r~" : "~g~");
|
||||
var fP = ((fireTaskCount === "0") ? "~r~" : "~g~");
|
||||
|
||||
factionInteractionMenu = new Menu("Fraktionsinteraktion", userFactionName, new Point(0, screenRes.y / 2), null, null);
|
||||
|
||||
if (isFactionLeader) {
|
||||
let leaderMenu = new UIMenuItem("Leadermen\u00fc", "Verwaltung der Fraktion");
|
||||
leaderMenu.SetRightBadge(BadgeStyle.Star);
|
||||
factionInteractionMenu.AddItem(leaderMenu);
|
||||
}
|
||||
let reviveTaskMenu;
|
||||
let healTaskMenu;
|
||||
let fireTaskMenu;
|
||||
if (isDuty) {
|
||||
switch (userFactionId) {
|
||||
case 2:
|
||||
reviveTaskMenu = new UIMenuItem("Reviveauftr\u00e4ge");
|
||||
reviveTaskMenu.SetRightLabel(rP + reviveTaskCount)
|
||||
factionInteractionMenu.AddItem(reviveTaskMenu);
|
||||
|
||||
healTaskMenu = new UIMenuItem("Healauftr\u00e4ge");
|
||||
healTaskMenu.SetRightLabel(hP + healTaskCount)
|
||||
factionInteractionMenu.AddItem(healTaskMenu);
|
||||
|
||||
fireTaskMenu = new UIMenuItem("Feuerauftr\u00e4ge");
|
||||
fireTaskMenu.SetRightLabel(fP + fireTaskCount)
|
||||
factionInteractionMenu.AddItem(fireTaskMenu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let cancelItem = new UIMenuItem("Schlie\u00dfen", "Schlie\u00dft die Fraktionsinteraktion");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
factionInteractionMenu.AddItem(cancelItem);
|
||||
|
||||
factionInteractionMenu.Visible = true;
|
||||
|
||||
factionInteractionMenu.ItemSelect.on((item) => {
|
||||
switch (item) {
|
||||
case cancelItem:
|
||||
factionInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
break;
|
||||
case reviveTaskMenu:
|
||||
mp.events.callRemote("loadMedicTasks", 0)
|
||||
factionInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
factionInteractionMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
mp.events.add("showMedicTasks", (type, taskList) => {
|
||||
tasks = JSON.parse(taskList);
|
||||
if (sorting === 0) {
|
||||
initTasks = tasks;
|
||||
}
|
||||
|
||||
mp.events.call("sortFactionTasks", false);
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
globalData.Interaction = true;
|
||||
switch (type) {
|
||||
case 0:
|
||||
reviveTaskMenu = new Menu("Revives", "\u00c4lteste zu erst", new Point(0, screenRes.y / 2), null, null);
|
||||
let aTask;
|
||||
for (var i = 0; i < tasks.length; i++) {
|
||||
if (tasks[i].MedicName === "none") {
|
||||
aTask = new UIMenuItem("~g~" + tasks[i].Victim);
|
||||
} else {
|
||||
aTask = new UIMenuItem("~r~" + tasks[i].Victim);
|
||||
}
|
||||
|
||||
aTask.SetRightLabel(mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[i].Position.x, tasks[i].Position.y, tasks[i].Position.z, true).toFixed(2).toString() + " ~g~m");
|
||||
reviveTaskMenu.AddItem(aTask);
|
||||
}
|
||||
|
||||
let backItem = new UIMenuItem("Zur\u00fcck", "Zur\u00fcck zur Fraktionsinteraktion");
|
||||
backItem.BackColor = new Color(213, 0, 0);
|
||||
backItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
reviveTaskMenu.AddItem(backItem);
|
||||
|
||||
reviveTaskMenu.ItemSelect.on((item, index) => {
|
||||
if (item === backItem) {
|
||||
reviveTaskMenu.Visible = false;
|
||||
factionInteractionMenu.Visible = true;
|
||||
} else {
|
||||
if (tasks[index].MedicName === "none") {
|
||||
mp.game.graphics.requestStreamedTextureDict("medicimages", true);
|
||||
mp.events.callRemote("updateMedicTask", 0, index, player.name);
|
||||
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
||||
activeCheckpoint = mp.markers.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0, {
|
||||
color: [255, 0, 0, 150],
|
||||
visible: true,
|
||||
dimension: 0
|
||||
});
|
||||
reviveTaskMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
ambulanceImagePos = 0.325
|
||||
taskStart = player.position;
|
||||
taskFinish = tasks[index].Position;
|
||||
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
||||
activeTask = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reviveTaskMenu.MenuClose.on(() => {
|
||||
reviveTaskMenu.Visible = false;
|
||||
factionInteractionMenu.Visible = true;
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("sortFactionTasks", (sortByKey) => {
|
||||
if (firstSorting) {
|
||||
sortText = "Nach Uhrzeit";
|
||||
firstSorting = false;
|
||||
//mp.gui.chat.push("Init Sort");
|
||||
return;
|
||||
} else {
|
||||
if (sortByKey) {
|
||||
if (sorting < 1) {
|
||||
sorting++;
|
||||
} else {
|
||||
sorting = 0;
|
||||
}
|
||||
|
||||
switch (sorting) {
|
||||
case 0: //Standartsortierung
|
||||
|
||||
reviveTaskMenu.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Nach Uhrzeit";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(initTasks));
|
||||
break;
|
||||
|
||||
case 1: //Sortierung nach Metern (aufsteigend)
|
||||
for (var d = 0; d < tasks.length; d++) {
|
||||
for (var e = 0; e < tasks.length - 1; e++) {
|
||||
if (getDistance1(e) > getDistance2(e + 1)) {
|
||||
var tempTask = tasks[e];
|
||||
tasks[e] = tasks[e + 1];
|
||||
tasks[e + 1] = tempTask;
|
||||
mp.gui.chat.push("SWITCH");
|
||||
}
|
||||
}
|
||||
}
|
||||
reviveTaskMenu.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Entfernung aufsteigend";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(tasks));
|
||||
break;
|
||||
|
||||
//case 2: //Sortierung nach Metern (absteigend)
|
||||
// mp.gui.chat.push("Sorting 2");
|
||||
// sortText = "Entfernung absteigend";
|
||||
// break;
|
||||
//case 3: //Sortierung nach Zeit (aufsteigend)
|
||||
// mp.gui.chat.push("Sorting 3");
|
||||
// sortText = "Restzeit aufsteigend";
|
||||
// break;
|
||||
//case 4: //Sortierung nach Zeit (absteigend)
|
||||
// mp.gui.chat.push("Sorting 4");
|
||||
// sortText = "Restzeit absteigend";
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function getDistance1(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
function getDistance2(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
|
||||
mp.events.add('render', () => {
|
||||
if (activeTask) {
|
||||
rangeLeft = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true).toFixed(2);
|
||||
if (rangeLeft > 1.9) {
|
||||
ambulanceImagePos = 0.655 - (mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true) / taskRange * 0.35);
|
||||
mp.game.graphics.drawRect(0.5, 0.945, 0.35, 0.025, 150, 0, 0, 200);
|
||||
mp.game.graphics.drawText(rangeLeft.toString() + "m", [0.5, 0.93], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: true
|
||||
});
|
||||
if (taskRange < rangeLeft) ambulanceImagePos = 0.3;
|
||||
mp.game.graphics.drawSprite("medicimages", "finish", 0.655, 0.898, 0.04, 0.07, 0, 255, 255, 255, 255);
|
||||
if (player.isInAnyVehicle(false)) {
|
||||
mp.game.graphics.drawSprite("medicimages", "ambulance", ambulanceImagePos + 0.01, 0.915, 0.04, 0.07, 0, 255, 255, 255, 255);
|
||||
} else {
|
||||
mp.game.graphics.drawSprite("medicimages", "running", ambulanceImagePos + 0.02, 0.915, 0.02, 0.035, 0, 255, 0, 0, 255);
|
||||
}
|
||||
} else {
|
||||
activeTask = false;
|
||||
activeCheckpoint.destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
var nearbyPlayers = [];
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
var tradeRequest;
|
||||
var tradeRequester;
|
||||
var timerBarSize = 0.5;
|
||||
var tradeTimeLeft;
|
||||
var tradeSelection = "none";
|
||||
var tradeSelectHover = "none";
|
||||
var acceptColor = 100;
|
||||
var declineColor = 100;
|
||||
|
||||
const { x: screenX, y: screenY } = mp.game.graphics.getScreenActiveResolution(0, 0);
|
||||
let rxC = 0.5;
|
||||
let ryC = 0.4;
|
||||
let rWidth = 0.4;
|
||||
let sX = (screenX * 0.1 / 1000);
|
||||
let sY = (screenY * 0.1 / 1000);
|
||||
let eX = sX - 0.1;
|
||||
let eY = sY - 0.1;
|
||||
let sizeMul = 0.08;
|
||||
let yMul = 1.8;
|
||||
|
||||
var receivedTradePrize;
|
||||
var receivedTradeItems = [[]];
|
||||
var receivedTradeGrid = [];
|
||||
receivedTradeGrid[0] = [0.3375, 0.5]
|
||||
receivedTradeGrid[1] = [0.4195, 0.5]
|
||||
receivedTradeGrid[2] = [0.5015, 0.5]
|
||||
receivedTradeGrid[3] = [0.5835, 0.5]
|
||||
receivedTradeGrid[4] = [0.6655, 0.5]
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
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;
|
||||
|
||||
mp.events.add("showPlayerInteraction", (nearPlayerArr) => {
|
||||
mp.gui.chat.activate(false);
|
||||
nearbyPlayers = JSON.parse(nearPlayerArr);
|
||||
globalData.Interaction = true;
|
||||
let playerInteractionMenu = new Menu("Spielerinteraktion", "", new Point(0, screenRes.y / 2));
|
||||
let playerSelect = new UIMenuListItem("Mit", "~y~W\u00e4hle den Spieler aus.", new ItemsCollection(nearbyPlayers));
|
||||
playerInteractionMenu.AddItem(playerSelect);
|
||||
playerInteractionMenu.AddItem(new UIMenuItem("Handeln", "Sende dem Spieler eine Handlungsanfrage"));
|
||||
|
||||
let cancelItem = new UIMenuItem("Schlie\u00dfen", "Schlie\u00dft die Spielerinteraktion");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
playerInteractionMenu.AddItem(cancelItem);
|
||||
|
||||
playerInteractionMenu.Visible = true;
|
||||
|
||||
playerInteractionMenu.ItemSelect.on((item) => {
|
||||
if (item.Text === "Handeln") {
|
||||
mp.events.callRemote("openTradeInventory", playerSelect.SelectedValue);
|
||||
playerInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
} else if (item.Text === "Schlie\u00dfen") {
|
||||
playerInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
}
|
||||
});
|
||||
|
||||
playerInteractionMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
});
|
||||
});
|
||||
|
||||
mp.events.add("showTradeRequest", (tradeRequesterName, tradeItemsArr, tradePrizeSent) => {
|
||||
receivedTradeItems = tradeItemsArr;
|
||||
receivedTradePrize = tradePrizeSent;
|
||||
mp.gui.cursor.show(true, true);
|
||||
tradeRequester = tradeRequesterName;
|
||||
tradeRequest = true;
|
||||
tradeTime = new Date().getTime();
|
||||
tradeTimeEnd = tradeTime + 30000;
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (tradeRequest) {
|
||||
var pos = mp.gui.cursor.position;
|
||||
var actualTime = new Date().getTime();
|
||||
|
||||
tradeTimeLeft = (tradeTimeEnd - actualTime) / 1000;
|
||||
|
||||
mp.game.graphics.set2dLayer(1);
|
||||
mp.game.graphics.drawRect(0.5, 0.5, 0.5, 0.3, 255, 255, 255, 200);
|
||||
|
||||
mp.game.graphics.drawText("Handelsanfrage von ~y~" + tradeRequester + " ~s~ für ~g~" + receivedTradePrize + "$", [0.5, 0.5 - 0.13], {
|
||||
font: 7,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.7, 0.7],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
mp.game.graphics.set2dLayer(2);
|
||||
for (var slots = 0; slots < receivedTradeGrid.length; slots++) {
|
||||
mp.game.graphics.drawRect(receivedTradeGrid[slots][0], receivedTradeGrid[slots][1], sizeMul, sizeMul * yMul, 112, 128, 144, 254);
|
||||
mp.game.graphics.drawText(tempSlot2 = slots + 1, [receivedTradeGrid[slots][0] - (sizeMul / 2) + 0.006, receivedTradeGrid[slots][1] - (sizeMul / 2 * yMul)], {
|
||||
font: 7,
|
||||
color: [69, 255, 0, 254],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true,
|
||||
});
|
||||
}
|
||||
|
||||
mp.game.graphics.set2dLayer(3);
|
||||
//SPRITES + ITEMANZAHL
|
||||
if (receivedTradeItems.length !== 0) {
|
||||
for (var currentItem = 0; currentItem < receivedTradeItems.length; currentItem++) {
|
||||
if (receivedTradeItems[currentItem][4] !== "-1") {
|
||||
mp.game.graphics.drawSprite("itemimages", receivedTradeItems[currentItem][0].toLowerCase(), receivedTradeGrid[parseInt(receivedTradeItems[currentItem][4] - 1)][0], receivedTradeGrid[parseInt(receivedTradeItems[currentItem][4] - 1)][1], rWidth / 8, rWidth / 5, 0, 255, 255, 255, 255);
|
||||
mp.game.graphics.drawText("(~y~" + receivedTradeItems[currentItem][3] + "~s~)", [receivedTradeGrid[parseInt(receivedTradeItems[currentItem][4] - 1)][0] + (sizeMul / 2) - 0.008, receivedTradeGrid[parseInt(receivedTradeItems[currentItem][4] - 1)][1] + 0.05], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.25, 0.25],
|
||||
outline: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
mp.game.graphics.set2dLayer(4);
|
||||
isMouseOverButton(pos[0], pos[1]);
|
||||
mp.game.graphics.drawRect(0.5 - 0.07, 0.5 + 0.1, 0.06, 0.04, 100, acceptColor, 100, 250);
|
||||
mp.game.graphics.drawRect(0.5 + 0.07, 0.5 + 0.1, 0.06, 0.04, declineColor, 100, 100, 250);
|
||||
|
||||
mp.game.graphics.set2dLayer(5);
|
||||
mp.game.graphics.drawText("~g~Annehmen", [0.5 - 0.07, 0.5 + 0.08], {
|
||||
font: 4,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.6, 0.6],
|
||||
outline: true,
|
||||
});
|
||||
mp.game.graphics.drawText("~r~Ablehnen", [0.5 + 0.07, 0.5 + 0.08], {
|
||||
font: 4,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.6, 0.6],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
mp.game.graphics.set2dLayer(6);
|
||||
if (isMouseOverTradeItem(pos[0], pos[1])) {
|
||||
mp.game.graphics.drawRect(pos[0] / screenX, pos[1] / screenY + 0.055, 0.14, 0.08, 0, 0, 0, 220);
|
||||
|
||||
var hoverItemP = [receivedTradeItems[hoverItem][0], receivedTradeItems[hoverItem][1], receivedTradeItems[hoverItem][2], receivedTradeItems[hoverItem][3]];
|
||||
|
||||
//NAME
|
||||
mp.game.graphics.drawText("~g~" + hoverItemP[0], [pos[0] / screenX, pos[1] / screenY + 0.02], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
//BESCHREIBUNG
|
||||
mp.game.graphics.drawText(hoverItemP[1], [pos[0] / screenX, pos[1] / screenY + 0.04], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
});
|
||||
|
||||
//EINZELGEWICHT
|
||||
mp.game.graphics.drawText("~y~" + hoverItemP[2] + "g~s~ * " + hoverItemP[3] + "~s~ = ~y~" + hoverItemP[2] * hoverItemP[3] + "g", [pos[0] / screenX, pos[1] / screenY + 0.06], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
});
|
||||
}
|
||||
|
||||
mp.game.graphics.set2dLayer(7);
|
||||
|
||||
timerBarSize = tradeTimeLeft / 30 * 0.5;
|
||||
if (tradeTimeLeft > 0) {
|
||||
mp.game.graphics.drawText(tradeTimeLeft.toFixed(0), [0.5, 0.5 + 0.1312], {
|
||||
font: 7,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
});
|
||||
mp.game.graphics.drawRect(0.5, 0.5 + 0.1412, timerBarSize, 0.018, 255, 0, 0, 250);
|
||||
} else {
|
||||
tradeSelection = "timeup";
|
||||
mp.events.callRemote('tradeDecision', tradeSelection, JSON.stringify(receivedTradeItems), tradeRequester);
|
||||
tradeRequest = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
function isMouseOverButton(cX, cY) {
|
||||
|
||||
if (tradeRequest) {
|
||||
var x = cX / screenX;
|
||||
var y = cY / screenY;
|
||||
|
||||
if (x > 0.5 - 0.07 - 0.03 && x < 0.5 - 0.07 + 0.03 && y > 0.5 + 0.1 - 0.02 && y < 0.5 + 0.1 + 0.02) {
|
||||
acceptColor = 255;
|
||||
tradeSelectHover = "accept";
|
||||
return true;
|
||||
} else if (x > 0.5 + 0.07 - 0.03 && x < 0.5 + 0.07 + 0.03 && y > 0.5 + 0.1 - 0.02 && y < 0.5 + 0.1 + 0.02) {
|
||||
declineColor = 255;
|
||||
tradeSelectHover = "decline";
|
||||
return true;
|
||||
} else {
|
||||
acceptColor = 100;
|
||||
declineColor = 100;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isMouseOverTradeItem(cX, cY) {
|
||||
|
||||
if (tradeRequest) {
|
||||
|
||||
var x = cX / screenX;
|
||||
var y = cY / screenY;
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
|
||||
for (var s = 0; s < 5; s++) {
|
||||
a = receivedTradeGrid[s][0] - x;
|
||||
b = receivedTradeGrid[s][1] - y;
|
||||
c = Math.sqrt(a * a + b * b);
|
||||
|
||||
var invSlot = (s + 1);
|
||||
|
||||
if (c < sizeMul / 2) {
|
||||
for (i = 0; i < receivedTradeItems.length; i++) {
|
||||
if (parseInt(receivedTradeItems[i][4]) === invSlot) {
|
||||
hoverItem = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => {
|
||||
|
||||
var cX = x / screenX;
|
||||
var cY = y / screenY;
|
||||
|
||||
if (tradeRequest) {
|
||||
//LINKE MAUSTASTE
|
||||
//RUNTER
|
||||
if (upOrDown === "down" && leftOrRight === "left") {
|
||||
if (isMouseOverButton(x, y)) {
|
||||
if (tradeSelectHover === "accept") {
|
||||
tradeSelection = "accept";
|
||||
} else if (tradeSelectHover === "decline") {
|
||||
tradeSelection = "decline";
|
||||
}
|
||||
mp.events.callRemote('tradeDecision', tradeSelection, JSON.stringify(receivedTradeItems), tradeRequester);
|
||||
tradeRequest = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
289
ReallifeGamemode.Client/Interaction/playerinteraction.ts
Normal file
289
ReallifeGamemode.Client/Interaction/playerinteraction.ts
Normal file
@@ -0,0 +1,289 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
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 { x: screenX, y: screenY } = mp.game.graphics.getScreenActiveResolution(0, 0);
|
||||
let rxC = 0.5;
|
||||
let ryC = 0.4;
|
||||
let rWidth = 0.4;
|
||||
let sX = (screenX * 0.1 / 1000);
|
||||
let sY = (screenY * 0.1 / 1000);
|
||||
let eX = sX - 0.1;
|
||||
let eY = sY - 0.1;
|
||||
let sizeMul = 0.08;
|
||||
let yMul = 1.8;
|
||||
|
||||
export default function playerInteraction(globalData: GlobalData) {
|
||||
|
||||
var nearbyPlayers = [];
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
var tradeRequest;
|
||||
var tradeRequester;
|
||||
var timerBarSize = 0.5;
|
||||
var tradeTimeLeft;
|
||||
var tradeTime;
|
||||
var tradeTimeEnd;
|
||||
var tradeSelection = "none";
|
||||
var tradeSelectHover = "none";
|
||||
var acceptColor = 100;
|
||||
var declineColor = 100;
|
||||
|
||||
var hoverItem;
|
||||
|
||||
var tempSlot2;
|
||||
|
||||
var receivedTradePrize;
|
||||
var receivedTradeItems = [[]];
|
||||
var receivedTradeGrid = [];
|
||||
receivedTradeGrid[0] = [0.3375, 0.5]
|
||||
receivedTradeGrid[1] = [0.4195, 0.5]
|
||||
receivedTradeGrid[2] = [0.5015, 0.5]
|
||||
receivedTradeGrid[3] = [0.5835, 0.5]
|
||||
receivedTradeGrid[4] = [0.6655, 0.5]
|
||||
|
||||
mp.events.add("showPlayerInteraction", (nearPlayerArr) => {
|
||||
mp.gui.chat.activate(false);
|
||||
nearbyPlayers = JSON.parse(nearPlayerArr);
|
||||
globalData.Interaction = true;
|
||||
let playerInteractionMenu = new Menu("Spielerinteraktion", "", new Point(0, screenRes.y / 2), null, null);
|
||||
let playerSelect = new UIMenuListItem("Mit", "~y~W\u00e4hle den Spieler aus.", new ItemsCollection(nearbyPlayers));
|
||||
playerInteractionMenu.AddItem(playerSelect);
|
||||
playerInteractionMenu.AddItem(new UIMenuItem("Handeln", "Sende dem Spieler eine Handlungsanfrage"));
|
||||
|
||||
let cancelItem = new UIMenuItem("Schlie\u00dfen", "Schlie\u00dft die Spielerinteraktion");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
playerInteractionMenu.AddItem(cancelItem);
|
||||
|
||||
playerInteractionMenu.Visible = true;
|
||||
|
||||
playerInteractionMenu.ItemSelect.on((item) => {
|
||||
if (item.Text === "Handeln") {
|
||||
mp.events.callRemote("openTradeInventory", playerSelect.SelectedValue);
|
||||
playerInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
} else if (item.Text === "Schlie\u00dfen") {
|
||||
playerInteractionMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
}
|
||||
});
|
||||
|
||||
playerInteractionMenu.MenuClose.on(() => {
|
||||
mp.gui.chat.activate(true);
|
||||
globalData.Interaction = false;
|
||||
});
|
||||
});
|
||||
|
||||
mp.events.add("showTradeRequest", (tradeRequesterName, tradeItemsArr, tradePrizeSent) => {
|
||||
receivedTradeItems = tradeItemsArr;
|
||||
receivedTradePrize = tradePrizeSent;
|
||||
mp.gui.cursor.show(true, true);
|
||||
tradeRequester = tradeRequesterName;
|
||||
tradeRequest = true;
|
||||
tradeTime = new Date().getTime();
|
||||
tradeTimeEnd = tradeTime + 30000;
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (tradeRequest) {
|
||||
var pos = mp.gui.cursor.position;
|
||||
var actualTime = new Date().getTime();
|
||||
|
||||
tradeTimeLeft = (tradeTimeEnd - actualTime) / 1000;
|
||||
|
||||
mp.game.graphics.set2dLayer(1);
|
||||
mp.game.graphics.drawRect(0.5, 0.5, 0.5, 0.3, 255, 255, 255, 200);
|
||||
|
||||
mp.game.graphics.drawText("Handelsanfrage von ~y~" + tradeRequester + " ~s~ für ~g~" + receivedTradePrize + "$", [0.5, 0.5 - 0.13], {
|
||||
font: 7,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.7, 0.7],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
mp.game.graphics.set2dLayer(2);
|
||||
for (var slots = 0; slots < receivedTradeGrid.length; slots++) {
|
||||
mp.game.graphics.drawRect(receivedTradeGrid[slots][0], receivedTradeGrid[slots][1], sizeMul, sizeMul * yMul, 112, 128, 144, 254);
|
||||
mp.game.graphics.drawText((tempSlot2 = slots + 1).toString(), [receivedTradeGrid[slots][0] - (sizeMul / 2) + 0.006, receivedTradeGrid[slots][1] - (sizeMul / 2 * yMul)], {
|
||||
font: 7,
|
||||
color: [69, 255, 0, 254],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
|
||||
mp.game.graphics.set2dLayer(3);
|
||||
//SPRITES + ITEMANZAHL
|
||||
if (receivedTradeItems.length !== 0) {
|
||||
for (var currentItem = 0; currentItem < receivedTradeItems.length; currentItem++) {
|
||||
if (receivedTradeItems[currentItem][4] !== "-1") {
|
||||
mp.game.graphics.drawSprite("itemimages", receivedTradeItems[currentItem][0].toLowerCase(), receivedTradeGrid[receivedTradeItems[currentItem][4] - 1][0], receivedTradeGrid[receivedTradeItems[currentItem][4] - 1][1], rWidth / 8, rWidth / 5, 0, 255, 255, 255, 255);
|
||||
mp.game.graphics.drawText("(~y~" + receivedTradeItems[currentItem][3] + "~s~)", [receivedTradeGrid[receivedTradeItems[currentItem][4] - 1][0] + (sizeMul / 2) - 0.008, receivedTradeGrid[receivedTradeItems[currentItem][4] - 1][1] + 0.05], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.25, 0.25],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
mp.game.graphics.set2dLayer(4);
|
||||
isMouseOverButton(pos[0], pos[1]);
|
||||
mp.game.graphics.drawRect(0.5 - 0.07, 0.5 + 0.1, 0.06, 0.04, 100, acceptColor, 100, 250);
|
||||
mp.game.graphics.drawRect(0.5 + 0.07, 0.5 + 0.1, 0.06, 0.04, declineColor, 100, 100, 250);
|
||||
|
||||
mp.game.graphics.set2dLayer(5);
|
||||
mp.game.graphics.drawText("~g~Annehmen", [0.5 - 0.07, 0.5 + 0.08], {
|
||||
font: 4,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.6, 0.6],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
mp.game.graphics.drawText("~r~Ablehnen", [0.5 + 0.07, 0.5 + 0.08], {
|
||||
font: 4,
|
||||
color: [112, 128, 144, 254],
|
||||
scale: [0.6, 0.6],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
mp.game.graphics.set2dLayer(6);
|
||||
if (isMouseOverTradeItem(pos[0], pos[1])) {
|
||||
mp.game.graphics.drawRect(pos[0] / screenX, pos[1] / screenY + 0.055, 0.14, 0.08, 0, 0, 0, 220);
|
||||
|
||||
var hoverItemP = [receivedTradeItems[hoverItem][0], receivedTradeItems[hoverItem][1], receivedTradeItems[hoverItem][2], receivedTradeItems[hoverItem][3]];
|
||||
|
||||
//NAME
|
||||
mp.game.graphics.drawText("~g~" + hoverItemP[0], [pos[0] / screenX, pos[1] / screenY + 0.02], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
//BESCHREIBUNG
|
||||
mp.game.graphics.drawText(hoverItemP[1], [pos[0] / screenX, pos[1] / screenY + 0.04], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
//EINZELGEWICHT
|
||||
mp.game.graphics.drawText("~y~" + hoverItemP[2] + "g~s~ * " + hoverItemP[3] + "~s~ = ~y~" + hoverItemP[2] * hoverItemP[3] + "g", [pos[0] / screenX, pos[1] / screenY + 0.06], {
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
|
||||
mp.game.graphics.set2dLayer(7);
|
||||
|
||||
timerBarSize = tradeTimeLeft / 30 * 0.5;
|
||||
if (tradeTimeLeft > 0) {
|
||||
mp.game.graphics.drawText(tradeTimeLeft.toFixed(0), [0.5, 0.5 + 0.1312], {
|
||||
font: 7,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
mp.game.graphics.drawRect(0.5, 0.5 + 0.1412, timerBarSize, 0.018, 255, 0, 0, 250);
|
||||
} else {
|
||||
tradeSelection = "timeup";
|
||||
mp.events.callRemote('tradeDecision', tradeSelection, JSON.stringify(receivedTradeItems), tradeRequester);
|
||||
tradeRequest = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
function isMouseOverButton(cX, cY) {
|
||||
|
||||
if (tradeRequest) {
|
||||
var x = cX / screenX;
|
||||
var y = cY / screenY;
|
||||
|
||||
if (x > 0.5 - 0.07 - 0.03 && x < 0.5 - 0.07 + 0.03 && y > 0.5 + 0.1 - 0.02 && y < 0.5 + 0.1 + 0.02) {
|
||||
acceptColor = 255;
|
||||
tradeSelectHover = "accept";
|
||||
return true;
|
||||
} else if (x > 0.5 + 0.07 - 0.03 && x < 0.5 + 0.07 + 0.03 && y > 0.5 + 0.1 - 0.02 && y < 0.5 + 0.1 + 0.02) {
|
||||
declineColor = 255;
|
||||
tradeSelectHover = "decline";
|
||||
return true;
|
||||
} else {
|
||||
acceptColor = 100;
|
||||
declineColor = 100;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isMouseOverTradeItem(cX, cY) {
|
||||
|
||||
if (tradeRequest) {
|
||||
|
||||
var x = cX / screenX;
|
||||
var y = cY / screenY;
|
||||
var a;
|
||||
var b;
|
||||
var c;
|
||||
|
||||
for (var s = 0; s < 5; s++) {
|
||||
a = receivedTradeGrid[s][0] - x;
|
||||
b = receivedTradeGrid[s][1] - y;
|
||||
c = Math.sqrt(a * a + b * b);
|
||||
|
||||
var invSlot = (s + 1);
|
||||
|
||||
if (c < sizeMul / 2) {
|
||||
for (var i = 0; i < receivedTradeItems.length; i++) {
|
||||
if (parseInt(receivedTradeItems[i][4]) === invSlot) {
|
||||
hoverItem = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, worldPosition, hitEntity) => {
|
||||
|
||||
var cX = x / screenX;
|
||||
var cY = y / screenY;
|
||||
|
||||
if (tradeRequest) {
|
||||
//LINKE MAUSTASTE
|
||||
//RUNTER
|
||||
if (upOrDown === "down" && leftOrRight === "left") {
|
||||
if (isMouseOverButton(x, y)) {
|
||||
if (tradeSelectHover === "accept") {
|
||||
tradeSelection = "accept";
|
||||
} else if (tradeSelectHover === "decline") {
|
||||
tradeSelection = "decline";
|
||||
}
|
||||
mp.events.callRemote('tradeDecision', tradeSelection, JSON.stringify(receivedTradeItems), tradeRequester);
|
||||
tradeRequest = false;
|
||||
mp.gui.cursor.show(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
|
||||
mp.events.add("SERVER:ShowAtmUi", (atmId, atmBalance) => {
|
||||
mp.gui.cursor.show(true, true);
|
||||
mp.gui.chat.show(false);
|
||||
mp.game.ui.displayHud(false);
|
||||
mp.game.ui.displayRadar(false);
|
||||
|
||||
atmBrowser = mp.browsers.new("package://assets/html/atm/index.html");
|
||||
});
|
||||
12
ReallifeGamemode.Client/Interaction/worldinteraction.ts
Normal file
12
ReallifeGamemode.Client/Interaction/worldinteraction.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export default function worldInteraction() {
|
||||
var atmBrowser: BrowserMp;
|
||||
|
||||
mp.events.add("SERVER:ShowAtmUi", (atmId, atmBalance) => {
|
||||
mp.gui.cursor.show(true, true);
|
||||
mp.gui.chat.show(false);
|
||||
mp.game.ui.displayHud(false);
|
||||
mp.game.ui.displayRadar(false);
|
||||
|
||||
atmBrowser = mp.browsers.new("package://assets/html/atm/index.html");
|
||||
});
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player DutyClothes dutyclothes.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
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;
|
||||
|
||||
var hats;
|
||||
var tops;
|
||||
var legs;
|
||||
var shoes;
|
||||
|
||||
var hat = -1;
|
||||
var top;
|
||||
var leg;
|
||||
var shoe;
|
||||
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
|
||||
var dutyMenu;
|
||||
let saveItem = new UIMenuItem("Speichern", "Speichert deine Dienstkleidung");
|
||||
saveItem.BackColor = new Color(13, 71, 161);
|
||||
saveItem.HighlightedBackColor = new Color(25, 118, 210);
|
||||
|
||||
let cancelItem = new UIMenuItem("Abbrechen", "");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
|
||||
|
||||
//Cloth Menu
|
||||
|
||||
mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => {
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
hats = hatsArr;
|
||||
tops = topsArr;
|
||||
legs = legsArr;
|
||||
shoes = shoesArr;
|
||||
|
||||
dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(0, screenRes.y/2));
|
||||
|
||||
dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Hose", "", new ItemsCollection(legs)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes)));
|
||||
dutyMenu.AddItem(saveItem);
|
||||
dutyMenu.AddItem(cancelItem);
|
||||
dutyMenu.Visible = true;
|
||||
|
||||
dutyMenu.ListChange.on((item, index) => {
|
||||
switch (item.Text) {
|
||||
case "Hut":
|
||||
if (item.SelectedItem.DisplayText === "Keinen") {
|
||||
hat = -1;
|
||||
mp.events.callRemote("updateDutyProp", 0, -1);
|
||||
} else {
|
||||
hat = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyProp", 0, hat);
|
||||
}
|
||||
break;
|
||||
case "Top":
|
||||
top = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 11, top);
|
||||
break;
|
||||
case "Hose":
|
||||
leg = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 4, leg);
|
||||
break;
|
||||
case "Schuhe":
|
||||
shoe = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 6, shoe);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
dutyMenu.ItemSelect.on((item) => {
|
||||
if (item.Text === "Speichern") {
|
||||
var slotType = [1, 0, 0, 0];
|
||||
var slotId = [0, 11, 4, 6];
|
||||
var clothId = [hat, top, leg, shoe];
|
||||
mp.events.callRemote("saveCharacterCloth", JSON.stringify(slotType), JSON.stringify(slotId), JSON.stringify(clothId));
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
} else if (item.Text === "Abbrechen") {
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.events.callRemote("defaultCharacterCloth");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dutyMenu.MenuClose.on(() => {
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.events.callRemote("defaultCharacterCloth");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
109
ReallifeGamemode.Client/Player/dutycloth.ts
Normal file
109
ReallifeGamemode.Client/Player/dutycloth.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player DutyClothes dutyclothes.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
import * as NativeUI from 'NativeUI';
|
||||
|
||||
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;
|
||||
|
||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||
let saveItem = new UIMenuItem("Speichern", "Speichert deine Dienstkleidung");
|
||||
saveItem.BackColor = new Color(13, 71, 161);
|
||||
saveItem.HighlightedBackColor = new Color(25, 118, 210);
|
||||
|
||||
let cancelItem = new UIMenuItem("Abbrechen", "");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
|
||||
export default function dutyCloth() {
|
||||
|
||||
var dutyMenu;
|
||||
|
||||
var hats;
|
||||
var tops;
|
||||
var legs;
|
||||
var shoes;
|
||||
|
||||
var hat = -1;
|
||||
var top;
|
||||
var leg;
|
||||
var shoe;
|
||||
|
||||
//Cloth Menu
|
||||
|
||||
mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => {
|
||||
|
||||
mp.gui.chat.activate(false);
|
||||
hats = hatsArr;
|
||||
tops = topsArr;
|
||||
legs = legsArr;
|
||||
shoes = shoesArr;
|
||||
|
||||
dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(0, screenRes.y / 2), null, null);
|
||||
|
||||
dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Hose", "", new ItemsCollection(legs)));
|
||||
dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes)));
|
||||
dutyMenu.AddItem(saveItem);
|
||||
dutyMenu.AddItem(cancelItem);
|
||||
dutyMenu.Visible = true;
|
||||
|
||||
dutyMenu.ListChange.on((item, index) => {
|
||||
switch (item.Text) {
|
||||
case "Hut":
|
||||
if (item.SelectedItem.DisplayText === "Keinen") {
|
||||
hat = -1;
|
||||
mp.events.callRemote("updateDutyProp", 0, -1);
|
||||
} else {
|
||||
hat = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyProp", 0, hat);
|
||||
}
|
||||
break;
|
||||
case "Top":
|
||||
top = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 11, top);
|
||||
break;
|
||||
case "Hose":
|
||||
leg = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 4, leg);
|
||||
break;
|
||||
case "Schuhe":
|
||||
shoe = parseInt(item.SelectedItem.DisplayText);
|
||||
mp.events.callRemote("updateDutyCloth", 6, shoe);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
dutyMenu.ItemSelect.on((item) => {
|
||||
if (item.Text === "Speichern") {
|
||||
var slotType = [1, 0, 0, 0];
|
||||
var slotId = [0, 11, 4, 6];
|
||||
var clothId = [hat, top, leg, shoe];
|
||||
mp.events.callRemote("saveCharacterCloth", JSON.stringify(slotType), JSON.stringify(slotId), JSON.stringify(clothId));
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
} else if (item.Text === "Abbrechen") {
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.events.callRemote("defaultCharacterCloth");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dutyMenu.MenuClose.on(() => {
|
||||
dutyMenu.Visible = false;
|
||||
mp.gui.chat.activate(true);
|
||||
mp.events.callRemote("defaultCharacterCloth");
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
const controlsIds = {
|
||||
F5: 327,
|
||||
W: 32, // 232
|
||||
S: 33, // 31, 219, 233, 268, 269
|
||||
A: 34, // 234
|
||||
D: 35, // 30, 218, 235, 266, 267
|
||||
Space: 321,
|
||||
LCtrl: 326,
|
||||
};
|
||||
|
||||
global.fly = {
|
||||
flying: false, f: 2.0, w: 2.0, h: 2.0, point_distance: 1000,
|
||||
};
|
||||
global.gameplayCam = mp.cameras.new('gameplay');
|
||||
|
||||
mp.game.graphics.notify('~r~Fly script loaded!');
|
||||
mp.game.graphics.notify('~r~F5~w~ - enable/disable\n~r~F5+Space~w~ - disable without warping to ground\n~r~W/A/S/D/Space/LCtrl~w~ - move');
|
||||
mp.game.graphics.notify('~r~/savecam~w~ - save Camera position.');
|
||||
|
||||
let direction = null;
|
||||
let coords = null;
|
||||
|
||||
function pointingAt(distance) {
|
||||
const farAway = new mp.Vector3((direction.x * distance) + (coords.x), (direction.y * distance) + (coords.y), (direction.z * distance) + (coords.z));
|
||||
|
||||
const result = mp.raycasting.testPointToPoint(coords, farAway, [1, 16]);
|
||||
if (result === undefined) {
|
||||
return 'undefined';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
mp.events.add('render', () => {
|
||||
const controls = mp.game.controls;
|
||||
const fly = global.fly;
|
||||
direction = global.gameplayCam.getDirection();
|
||||
coords = global.gameplayCam.getCoord();
|
||||
|
||||
coords.x = coords.x.toFixed(2);
|
||||
coords.y = coords.y.toFixed(2);
|
||||
coords.z = coords.z.toFixed(2);
|
||||
|
||||
direction.x = direction.x.toFixed(2);
|
||||
direction.y = direction.y.toFixed(2);
|
||||
direction.z = direction.z.toFixed(2);
|
||||
|
||||
mp.game.graphics.drawText(`Coords: ${JSON.stringify(coords)}`, [0.5, 0.005], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 185],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true
|
||||
});
|
||||
mp.game.graphics.drawText(`pointAtCoord: ${JSON.stringify(pointingAt(fly.point_distance).position)}`, [0.5, 0.025], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 185],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true
|
||||
});
|
||||
|
||||
if (controls.isControlJustPressed(0, controlsIds.F5)) {
|
||||
fly.flying = !fly.flying;
|
||||
|
||||
const player = mp.players.local;
|
||||
|
||||
player.setInvincible(fly.flying);
|
||||
player.freezePosition(fly.flying);
|
||||
player.setAlpha(fly.flying ? 0 : 255);
|
||||
|
||||
if (!fly.flying && !controls.isControlPressed(0, controlsIds.Space)) {
|
||||
const position = mp.players.local.position;
|
||||
position.z = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, 0.0, false);
|
||||
mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, false, false, false);
|
||||
}
|
||||
|
||||
mp.game.graphics.notify(fly.flying ? 'Fly: ~g~Enabled' : 'Fly: ~r~Disabled');
|
||||
} else if (fly.flying) {
|
||||
let updated = false;
|
||||
const position = mp.players.local.position;
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.W)) {
|
||||
if (fly.f < 8.0) { fly.f *= 1.025; }
|
||||
|
||||
position.x += direction.x * fly.f;
|
||||
position.y += direction.y * fly.f;
|
||||
position.z += direction.z * fly.f;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.S)) {
|
||||
if (fly.f < 8.0) { fly.f *= 1.025; }
|
||||
|
||||
position.x -= direction.x * fly.f;
|
||||
position.y -= direction.y * fly.f;
|
||||
position.z -= direction.z * fly.f;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.f = 2.0;
|
||||
}
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.A)) {
|
||||
if (fly.l < 8.0) { fly.l *= 1.025; }
|
||||
|
||||
position.x += (-direction.y) * fly.l;
|
||||
position.y += direction.x * fly.l;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.D)) {
|
||||
if (fly.l < 8.0) { fly.l *= 1.05; }
|
||||
|
||||
position.x -= (-direction.y) * fly.l;
|
||||
position.y -= direction.x * fly.l;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.l = 2.0;
|
||||
}
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.Space)) {
|
||||
if (fly.h < 8.0) { fly.h *= 1.025; }
|
||||
|
||||
position.z += fly.h;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.LCtrl)) {
|
||||
if (fly.h < 8.0) { fly.h *= 1.05; }
|
||||
|
||||
position.z -= fly.h;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.h = 2.0;
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, false, false, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
134
ReallifeGamemode.Client/Player/freecam.ts
Normal file
134
ReallifeGamemode.Client/Player/freecam.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
export default function freeCam() {
|
||||
const controlsIds = {
|
||||
F5: 327,
|
||||
W: 32, // 232
|
||||
S: 33, // 31, 219, 233, 268, 269
|
||||
A: 34, // 234
|
||||
D: 35, // 30, 218, 235, 266, 267
|
||||
Space: 321,
|
||||
LCtrl: 326
|
||||
};
|
||||
|
||||
var global = {
|
||||
gameplayCam: undefined,
|
||||
fly: undefined
|
||||
};
|
||||
|
||||
global.fly = {
|
||||
flying: false, f: 2.0, w: 2.0, h: 2.0, point_distance: 1000, l:0
|
||||
};
|
||||
global.gameplayCam = mp.cameras.new('gameplay');
|
||||
|
||||
mp.game.graphics.notify('~r~Fly script loaded!');
|
||||
mp.game.graphics.notify('~r~F5~w~ - enable/disable\n~r~F5+Space~w~ - disable without warping to ground\n~r~W/A/S/D/Space/LCtrl~w~ - move');
|
||||
mp.game.graphics.notify('~r~/savecam~w~ - save Camera position.');
|
||||
|
||||
let direction = null;
|
||||
let coords = null;
|
||||
|
||||
function pointingAt(distance) {
|
||||
const farAway = new mp.Vector3((direction.x * distance) + (coords.x), (direction.y * distance) + (coords.y), (direction.z * distance) + (coords.z));
|
||||
|
||||
const result = mp.raycasting.testPointToPoint(coords, farAway, 16);
|
||||
if (result === undefined) {
|
||||
return 'undefined';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
mp.events.add('render', () => {
|
||||
const controls = mp.game.controls;
|
||||
const fly = global.fly;
|
||||
direction = global.gameplayCam.getDirection();
|
||||
coords = global.gameplayCam.getCoord();
|
||||
|
||||
coords.x = coords.x.toFixed(2);
|
||||
coords.y = coords.y.toFixed(2);
|
||||
coords.z = coords.z.toFixed(2);
|
||||
|
||||
direction.x = direction.x.toFixed(2);
|
||||
direction.y = direction.y.toFixed(2);
|
||||
direction.z = direction.z.toFixed(2);
|
||||
|
||||
mp.game.graphics.drawText(`Coords: ${JSON.stringify(coords)}`, [0.5, 0.005], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 185],
|
||||
scale: [0.3, 0.3],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
if (controls.isControlJustPressed(0, controlsIds.F5)) {
|
||||
fly.flying = !fly.flying;
|
||||
|
||||
const player = mp.players.local;
|
||||
|
||||
player.setInvincible(fly.flying);
|
||||
player.freezePosition(fly.flying);
|
||||
player.setAlpha(fly.flying ? 0 : 255);
|
||||
|
||||
if (!fly.flying && !controls.isControlPressed(0, controlsIds.Space)) {
|
||||
const position = mp.players.local.position;
|
||||
position.z = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, 0.0, false);
|
||||
mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, 0, 0, 0);
|
||||
}
|
||||
|
||||
mp.game.graphics.notify(fly.flying ? 'Fly: ~g~Enabled' : 'Fly: ~r~Disabled');
|
||||
} else if (fly.flying) {
|
||||
let updated = false;
|
||||
const position = mp.players.local.position;
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.W)) {
|
||||
if (fly.f < 8.0) { fly.f *= 1.025; }
|
||||
|
||||
position.x += direction.x * fly.f;
|
||||
position.y += direction.y * fly.f;
|
||||
position.z += direction.z * fly.f;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.S)) {
|
||||
if (fly.f < 8.0) { fly.f *= 1.025; }
|
||||
|
||||
position.x -= direction.x * fly.f;
|
||||
position.y -= direction.y * fly.f;
|
||||
position.z -= direction.z * fly.f;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.f = 2.0;
|
||||
}
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.A)) {
|
||||
if (fly.l < 8.0) { fly.l *= 1.025; }
|
||||
|
||||
position.x += (-direction.y) * fly.l;
|
||||
position.y += direction.x * fly.l;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.D)) {
|
||||
if (fly.l < 8.0) { fly.l *= 1.05; }
|
||||
|
||||
position.x -= -direction.y * fly.l;
|
||||
position.y -= direction.x * fly.l;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.l = 2.0;
|
||||
}
|
||||
|
||||
if (controls.isControlPressed(0, controlsIds.Space)) {
|
||||
if (fly.h < 8.0) { fly.h *= 1.025; }
|
||||
|
||||
position.z += fly.h;
|
||||
updated = true;
|
||||
} else if (controls.isControlPressed(0, controlsIds.LCtrl)) {
|
||||
if (fly.h < 8.0) { fly.h *= 1.05; }
|
||||
|
||||
position.z -= fly.h;
|
||||
updated = true;
|
||||
} else {
|
||||
fly.h = 2.0;
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
mp.players.local.setCoordsNoOffset(position.x, position.y, position.z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Keys keys.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
|
||||
|
||||
var showInventory = false;
|
||||
var showGui = true;
|
||||
var showInv = false;
|
||||
|
||||
const player = mp.players.local;
|
||||
|
||||
//ENTER
|
||||
mp.keys.bind(0x0D, false, function () {
|
||||
if (globalData.InChat) {
|
||||
globalData.InChat = false;
|
||||
}
|
||||
});
|
||||
|
||||
//LEFT ARROW (Interaktion mit anderen Spielern)
|
||||
mp.keys.bind(0x25, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:LEFT_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//UP ARROW (Interaktion mit Spielwelt)
|
||||
//mp.keys.bind(0x26, false, function () {
|
||||
// if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
// mp.events.callRemote("keyPress:UP_ARROW");
|
||||
// }
|
||||
//});
|
||||
|
||||
//RIGHT ARROW (Fraktionsinteraktion)
|
||||
mp.keys.bind(0x27, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:RIGHT_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//DOWN ARROW (Eigeninteraktion)
|
||||
mp.keys.bind(0x28, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:DOWN_ARROW");
|
||||
}
|
||||
});
|
||||
//F7 //Unshowalles
|
||||
mp.keys.bind(0x76, false, function () {
|
||||
if (showGui === true) {
|
||||
showGui = false;
|
||||
mp.events.call("toggleUi", false);
|
||||
} else {
|
||||
showGui = true;
|
||||
mp.events.call("toggleUi", true);
|
||||
}
|
||||
});
|
||||
|
||||
//NUM2 //Save Blips in Edit Mode
|
||||
mp.keys.bind(0x62, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:NUM2");
|
||||
}
|
||||
});
|
||||
|
||||
//NUM5 //Fraktionsinteraktion (Tasks sortieren)
|
||||
//mp.keys.bind(0x65, false, function () {
|
||||
// if (!globalData.InChat && globalData.Interaction) {
|
||||
// mp.events.call("sortFactionTasks", true);
|
||||
// }
|
||||
//});
|
||||
|
||||
//E
|
||||
mp.keys.bind(0x45, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:E");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//I //Inventar
|
||||
mp.keys.bind(0x49, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
if (showInv === false) {
|
||||
showInv = true;
|
||||
} else {
|
||||
showInv = false;
|
||||
}
|
||||
mp.events.callRemote("keyPress:I");
|
||||
}
|
||||
});
|
||||
|
||||
//J //Spielerliste
|
||||
mp.keys.bind(0x4A, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:J");
|
||||
//mp.events.call("showPlayerlist");
|
||||
}
|
||||
});
|
||||
|
||||
//K //Dienstkleidung
|
||||
mp.keys.bind(0x4B, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:K");
|
||||
}
|
||||
});
|
||||
|
||||
//L //Türen auf / zuschließen
|
||||
mp.keys.bind(0x4C, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:L");
|
||||
}
|
||||
});
|
||||
|
||||
//N //Motor Starten
|
||||
mp.keys.bind(0x4E, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
if (!player.vehicle) return;
|
||||
if (player.vehicle.getSpeed() > 5) return;
|
||||
mp.events.callRemote("keyPress:N");
|
||||
}
|
||||
});
|
||||
|
||||
//T
|
||||
mp.keys.bind(0x54, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
globalData.InChat = true;
|
||||
}
|
||||
});
|
||||
|
||||
//X //Anschnallen
|
||||
mp.keys.bind(0x58, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:X");
|
||||
}
|
||||
});
|
||||
|
||||
141
ReallifeGamemode.Client/Player/keys.ts
Normal file
141
ReallifeGamemode.Client/Player/keys.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Keys keys.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
|
||||
|
||||
|
||||
const player = mp.players.local;
|
||||
|
||||
export default function keys(globalData: GlobalData) {
|
||||
|
||||
var showInventory = false;
|
||||
var showGui = true;
|
||||
var showInv = false;
|
||||
|
||||
//ENTER
|
||||
mp.keys.bind(0x0D, false, function () {
|
||||
if (globalData.InChat) {
|
||||
globalData.InChat = false;
|
||||
}
|
||||
});
|
||||
|
||||
//LEFT ARROW (Interaktion mit anderen Spielern)
|
||||
mp.keys.bind(0x25, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:LEFT_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//UP ARROW (Interaktion mit Spielwelt)
|
||||
//mp.keys.bind(0x26, false, function () {
|
||||
// if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
// mp.events.callRemote("keyPress:UP_ARROW");
|
||||
// }
|
||||
//});
|
||||
|
||||
//RIGHT ARROW (Fraktionsinteraktion)
|
||||
mp.keys.bind(0x27, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:RIGHT_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//DOWN ARROW (Eigeninteraktion)
|
||||
mp.keys.bind(0x28, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:DOWN_ARROW");
|
||||
}
|
||||
});
|
||||
//F7 //Unshowalles
|
||||
mp.keys.bind(0x76, false, function () {
|
||||
if (showGui === true) {
|
||||
showGui = false;
|
||||
mp.events.call("toggleUi", false);
|
||||
} else {
|
||||
showGui = true;
|
||||
mp.events.call("toggleUi", true);
|
||||
}
|
||||
});
|
||||
|
||||
//NUM2 //Save Blips in Edit Mode
|
||||
mp.keys.bind(0x62, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:NUM2");
|
||||
}
|
||||
});
|
||||
|
||||
//NUM5 //Fraktionsinteraktion (Tasks sortieren)
|
||||
//mp.keys.bind(0x65, false, function () {
|
||||
// if (!globalData.InChat && globalData.Interaction) {
|
||||
// mp.events.call("sortFactionTasks", true);
|
||||
// }
|
||||
//});
|
||||
|
||||
//E
|
||||
mp.keys.bind(0x45, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:E");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//I //Inventar
|
||||
mp.keys.bind(0x49, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
if (showInv === false) {
|
||||
showInv = true;
|
||||
} else {
|
||||
showInv = false;
|
||||
}
|
||||
mp.events.callRemote("keyPress:I");
|
||||
}
|
||||
});
|
||||
|
||||
//J //Spielerliste
|
||||
mp.keys.bind(0x4A, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:J");
|
||||
//mp.events.call("showPlayerlist");
|
||||
}
|
||||
});
|
||||
|
||||
//K //Dienstkleidung
|
||||
mp.keys.bind(0x4B, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:K");
|
||||
}
|
||||
});
|
||||
|
||||
//L //Türen auf / zuschließen
|
||||
mp.keys.bind(0x4C, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:L");
|
||||
}
|
||||
});
|
||||
|
||||
//N //Motor Starten
|
||||
mp.keys.bind(0x4E, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
if (!player.vehicle) return;
|
||||
if (player.vehicle.getSpeed() > 5) return;
|
||||
mp.events.callRemote("keyPress:N");
|
||||
}
|
||||
});
|
||||
|
||||
//T
|
||||
mp.keys.bind(0x54, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
globalData.InChat = true;
|
||||
}
|
||||
});
|
||||
|
||||
//X //Anschnallen
|
||||
mp.keys.bind(0x58, false, function () {
|
||||
if (!globalData.InChat) {
|
||||
mp.events.callRemote("keyPress:X");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Quit quit.js
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
mp.events.add('playerQuit', (player, exitType, reason) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
});
|
||||
10
ReallifeGamemode.Client/Player/quit.ts
Normal file
10
ReallifeGamemode.Client/Player/quit.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Player Quit quit.js
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
export default function quitHandler() {
|
||||
mp.events.add('playerQuit', (player, exitType, reason) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
});
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Save Main main.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
var saveBrowser;
|
||||
|
||||
mp.events.add('saveBlip', () => {
|
||||
|
||||
saveBrowser = mp.browsers.new('package://Save/blip/save.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
});
|
||||
|
||||
mp.events.add('saveBlipData', (blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension) => {
|
||||
if (saveBrowser) {
|
||||
saveBrowser.destroy();
|
||||
}
|
||||
|
||||
mp.events.callRemote('OnSaveBlipData', blipSprite, blipName, blipScale, blipColor, blipAlpha,
|
||||
blipDrawDistance, blipShortRange, blipRotation, blipDimension);
|
||||
mp.gui.chat.push(blipShortRange);
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
});
|
||||
|
||||
mp.events.add('cancelData', () => {
|
||||
if (saveBrowser) {
|
||||
saveBrowser.destroy();
|
||||
}
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
});
|
||||
36
ReallifeGamemode.Client/Save/main.ts
Normal file
36
ReallifeGamemode.Client/Save/main.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Save Main main.js
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
export default function saveData() {
|
||||
var saveBrowser: BrowserMp;
|
||||
|
||||
mp.events.add('saveBlip', () => {
|
||||
|
||||
saveBrowser = mp.browsers.new('package://assets/html/save/blip/index.html');
|
||||
mp.gui.chat.activate(false);
|
||||
mp.gui.cursor.show(true, true);
|
||||
});
|
||||
|
||||
mp.events.add('saveBlipData', (blipSprite, blipName, blipScale, blipColor, blipAlpha, blipDrawDistance, blipShortRange, blipRotation, blipDimension) => {
|
||||
if (saveBrowser) {
|
||||
saveBrowser.destroy();
|
||||
}
|
||||
|
||||
mp.events.callRemote('OnSaveBlipData', blipSprite, blipName, blipScale, blipColor, blipAlpha,
|
||||
blipDrawDistance, blipShortRange, blipRotation, blipDimension);
|
||||
mp.gui.chat.push(blipShortRange);
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
});
|
||||
|
||||
mp.events.add('cancelData', () => {
|
||||
if (saveBrowser) {
|
||||
saveBrowser.destroy();
|
||||
}
|
||||
mp.gui.cursor.show(false, false);
|
||||
mp.gui.chat.activate(true);
|
||||
});
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
let player = mp.players.local;
|
||||
var dictLoaded = false;
|
||||
|
||||
var lockStatus = false;
|
||||
|
||||
mp.events.add('render', () =>
|
||||
{
|
||||
if (player.vehicle && player.vehicle.getPedInSeat(-1) === player.handle && !globalData.HideGui) // Check if player is in vehicle and is driver
|
||||
{
|
||||
if (!dictLoaded) {
|
||||
mp.game.graphics.requestStreamedTextureDict("vehicleimages", true);
|
||||
dictLoaded = true;
|
||||
}
|
||||
|
||||
mp.game.graphics.drawRect(0.5, 0.995, 0.35, 0.05, 0, 0, 0, 170);
|
||||
|
||||
var { x, y } = mp.game.graphics.getScreenActiveResolution(0, 0);
|
||||
|
||||
var engineR = 255;
|
||||
var engineG = 255;
|
||||
var engineB = 255;
|
||||
|
||||
if (player.vehicle.getIsEngineRunning()) {
|
||||
engineR = 104;
|
||||
engineG = 212;
|
||||
engineB = 42;
|
||||
} else {
|
||||
engineR = 188;
|
||||
engineG = 25;
|
||||
engineB = 25;
|
||||
}
|
||||
|
||||
let speed = (player.vehicle.getSpeed() * 3.6).toFixed(0);
|
||||
|
||||
var lockSprite = "";
|
||||
var lockR = 255;
|
||||
var lockG = 255;
|
||||
var lockB = 255;
|
||||
|
||||
if (lockStatus) {
|
||||
lockR = 104;
|
||||
lockG = 212;
|
||||
lockB = 42;
|
||||
lockSprite = "lockclosed";
|
||||
} else {
|
||||
lockSprite = "lockopen";
|
||||
lockR = 188;
|
||||
lockG = 25;
|
||||
lockB = 25;
|
||||
}
|
||||
|
||||
mp.game.graphics.drawSprite("vehicleimages", "engine", 0.343, 0.985, 0.015, 0.015 * (x / y), 0, engineR, engineG, engineB, 255);
|
||||
|
||||
mp.game.graphics.drawSprite("vehicleimages", lockSprite, 0.37, 0.985, 0.015, 0.015 * (x / y), 0, lockR, lockG, lockB, 255);
|
||||
|
||||
mp.game.graphics.drawText(speed.toString() + " KM/H", [0.41, 0.973], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
var drivenDistance = player.vehicle.getVariable("drivenDistance");
|
||||
var drivenDistanceStr = "0";
|
||||
if (drivenDistance) drivenDistanceStr = parseFloat(drivenDistance).toFixed(3).toString().replace(".", ",");
|
||||
mp.game.graphics.drawText(drivenDistanceStr + " KM", [0.48, 0.973], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (dictLoaded) {
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("vehicleimages");
|
||||
dictLoaded = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("Vehicle_setLockStatus", (status) => {
|
||||
lockStatus = status;
|
||||
});
|
||||
87
ReallifeGamemode.Client/Speedometer/index.ts
Normal file
87
ReallifeGamemode.Client/Speedometer/index.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
let player = mp.players.local;
|
||||
|
||||
export default function speedometer(globalData: GlobalData) {
|
||||
var dictLoaded = false;
|
||||
|
||||
var lockStatus = false;
|
||||
|
||||
mp.events.add('render', () => {
|
||||
if (player.vehicle && player.vehicle.getPedInSeat(-1) === player.handle && !globalData.HideGui) // Check if player is in vehicle and is driver
|
||||
{
|
||||
if (!dictLoaded) {
|
||||
mp.game.graphics.requestStreamedTextureDict("vehicleimages", true);
|
||||
dictLoaded = true;
|
||||
}
|
||||
|
||||
mp.game.graphics.drawRect(0.5, 0.995, 0.35, 0.05, 0, 0, 0, 170);
|
||||
|
||||
var { x, y } = mp.game.graphics.getScreenActiveResolution(0, 0);
|
||||
|
||||
var engineR = 255;
|
||||
var engineG = 255;
|
||||
var engineB = 255;
|
||||
|
||||
if (player.vehicle.getIsEngineRunning()) {
|
||||
engineR = 104;
|
||||
engineG = 212;
|
||||
engineB = 42;
|
||||
} else {
|
||||
engineR = 188;
|
||||
engineG = 25;
|
||||
engineB = 25;
|
||||
}
|
||||
|
||||
let speed = (player.vehicle.getSpeed() * 3.6).toFixed(0);
|
||||
|
||||
var lockSprite = "";
|
||||
var lockR = 255;
|
||||
var lockG = 255;
|
||||
var lockB = 255;
|
||||
|
||||
if (lockStatus) {
|
||||
lockR = 104;
|
||||
lockG = 212;
|
||||
lockB = 42;
|
||||
lockSprite = "lockclosed";
|
||||
} else {
|
||||
lockSprite = "lockopen";
|
||||
lockR = 188;
|
||||
lockG = 25;
|
||||
lockB = 25;
|
||||
}
|
||||
|
||||
mp.game.graphics.drawSprite("vehicleimages", "engine", 0.343, 0.985, 0.015, 0.015 * (x / y), 0, engineR, engineG, engineB, 255);
|
||||
|
||||
mp.game.graphics.drawSprite("vehicleimages", lockSprite, 0.37, 0.985, 0.015, 0.015 * (x / y), 0, lockR, lockG, lockB, 255);
|
||||
|
||||
mp.game.graphics.drawText(speed.toString() + " KM/H", [0.41, 0.973], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
|
||||
var drivenDistance = player.vehicle.getVariable("drivenDistance");
|
||||
var drivenDistanceStr = "0";
|
||||
if (drivenDistance) drivenDistanceStr = parseFloat(drivenDistance).toFixed(3).toString().replace(".", ",");
|
||||
mp.game.graphics.drawText(drivenDistanceStr + " KM", [0.48, 0.973], {
|
||||
font: 0,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.35, 0.35],
|
||||
outline: true,
|
||||
centre: false
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (dictLoaded) {
|
||||
mp.game.graphics.setStreamedTextureDictAsNoLongerNeeded("vehicleimages");
|
||||
dictLoaded = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("Vehicle_setLockStatus", (status) => {
|
||||
lockStatus = status;
|
||||
});
|
||||
}
|
||||
@@ -1,570 +0,0 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Tuning tuning.js
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
var keyBound = false;
|
||||
|
||||
var disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
|
||||
|
||||
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48, 69];
|
||||
|
||||
var carModSlotName = [
|
||||
{ Slot: 0, Name: "Spoiler" },
|
||||
{ Slot: 1, Name: "Frontstoßstange"},
|
||||
{ Slot: 2, Name: "Heckstoßstange"},
|
||||
{ Slot: 3, Name: "Seitenschweller"},
|
||||
{ Slot: 4, Name: "Auspuff"},
|
||||
{ Slot: 5, Name: "Rahmen"},
|
||||
{ Slot: 6, Name: "Kühlergrill"},
|
||||
{ Slot: 7, Name: "Motorhaube"},
|
||||
{ Slot: 8, Name: "Kotflügel"},
|
||||
{ Slot: 9, Name: "Rechter Kotflügel"},
|
||||
{ Slot: 10, Name: "Dach"},
|
||||
{ Slot: 11, Name: "Motor" },
|
||||
{ Slot: 12, Name: "Bremsen"},
|
||||
{ Slot: 13, Name: "Getriebe"},
|
||||
{ Slot: 14, Name: "Hupe"},
|
||||
{ Slot: 15, Name: "Federung"},
|
||||
{ Slot: 18, Name: "Turbo"},
|
||||
{ Slot: 22, Name: "Licht"},
|
||||
{ Slot: 23, Name: "Reifen" },
|
||||
{ Slot: 25, Name: "Nummernschildhalter" },
|
||||
{ Slot: 27, Name: "Innenausstatung" },
|
||||
{ Slot: 28, Name: "Wackelkopf" },
|
||||
{ Slot: 33, Name: "Lenkrad" },
|
||||
{ Slot: 34, Name: "Schalthebel" },
|
||||
{ Slot: 35, Name: "Schild" },
|
||||
{ Slot: 38, Name: "Hydraulik" },
|
||||
{ Slot: 39, Name: "Motorabdeckung" },
|
||||
{ Slot: 40, Name: "Luftfilter" },
|
||||
{ Slot: 46, Name: "Fenster" },
|
||||
{ Slot: 48, Name: "Design" }
|
||||
];
|
||||
|
||||
var customPartNames = [
|
||||
{
|
||||
Model: 1093792632,
|
||||
Names: [
|
||||
{
|
||||
Slot: 8,
|
||||
Name: "Lüftungsschlitze"
|
||||
},
|
||||
{
|
||||
Slot: 43,
|
||||
Name: "Motorhaubenstifte"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 223240013,
|
||||
Names: [
|
||||
{
|
||||
Slot: 9,
|
||||
Name: "Heckkotflügel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 1031562256,
|
||||
Names: [
|
||||
{
|
||||
Slot: 5,
|
||||
Name: "Stoßdämpfer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 3308022675,
|
||||
Names: [
|
||||
{
|
||||
Slot: 9,
|
||||
Name: "Kotflügel"
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
var doorOpeners = [
|
||||
{
|
||||
Model: 3308022675,
|
||||
Doors: [
|
||||
{
|
||||
Slot: 5,
|
||||
Door: 4
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
var bikeModTypes = [];
|
||||
|
||||
const NativeUI = require("../nativeui");
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
|
||||
var mainMenu;
|
||||
var modMenu;
|
||||
var closeMenu = false;
|
||||
|
||||
mp.events.add('showTuningInfo', () => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren');
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
mp.events.add('hideTuningInfo', (unbind) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
mp.gui.chat.show(true);
|
||||
|
||||
if (mp.players.local.vehicle) {
|
||||
mp.players.local.vehicle.setLights(0);
|
||||
}
|
||||
|
||||
if (typeof mainMenu !== "undefined" && unbind) {
|
||||
mainMenu.Close();
|
||||
globalData.InTuning = false;
|
||||
}
|
||||
|
||||
if (typeof modMenu !== "undefined" && modMenu.Visible && unbind) {
|
||||
closeMenu = true;
|
||||
modMenu.Close();
|
||||
globalData.InTuning = false;
|
||||
}
|
||||
|
||||
if (keyBound && unbind) {
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
mp.events.callRemote("startPlayerTuning");
|
||||
}
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (globalData.InTuning) {
|
||||
disableInput.forEach((input) => {
|
||||
mp.game.controls.disableControlAction(1, input, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("showTuningMenu", () => {
|
||||
mp.events.call("hideTuningInfo" , false);
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
var localPlayer = mp.players.local;
|
||||
var localVehicle = localPlayer.vehicle;
|
||||
|
||||
localVehicle.setHalt(1.0, 1, false);
|
||||
|
||||
if (typeof mainMenu !== "undefined" && mainMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof modMenu !== "undefined" && modMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
globalData.InTuning = true;
|
||||
|
||||
localVehicle.setLights(1);
|
||||
|
||||
var carName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(localVehicle.model));
|
||||
|
||||
mainMenu = new Menu("Fahrzeugwerkstatt", carName, new Point(50, 50));
|
||||
|
||||
if (localVehicle.getBodyHealth() !== 1000) {
|
||||
|
||||
var repairItem = new UIMenuItem("Fahrzeug reparieren");
|
||||
mainMenu.AddItem(repairItem);
|
||||
|
||||
mainMenu.ItemSelect.on((selectedItem, index) => {
|
||||
if (selectedItem === repairItem) {
|
||||
mp.events.callRemote("repairVehicle");
|
||||
mainMenu.Close();
|
||||
setTimeout(() => {
|
||||
mp.events.call("showTuningMenu");
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
globalData.InTuning = false;
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
});
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
carModTypes.forEach((modType) => {
|
||||
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
||||
var slotName = mp.game.ui.getLabelText(localVehicle.getModSlotName(modType));
|
||||
|
||||
if (slotName === "NULL") {
|
||||
slotName = getCustomName(localVehicle.model, modType);
|
||||
if (slotName === undefined) slotName = getSlotName(modType);
|
||||
}
|
||||
|
||||
if (slotName === "undefined") slotName = "Slot " + modType;
|
||||
|
||||
var menuItem = new UIMenuItem(slotName);
|
||||
var num = localVehicle.getNumMods(modType);
|
||||
if (num === undefined && modType !== 18 && modType !== 22) return;
|
||||
if (num !== 0 || modType === 18 || modType === 22) mainMenu.AddItem(menuItem);
|
||||
}
|
||||
});
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
mainMenu.ItemSelect.on((item) => {
|
||||
var modSlot = getSlotId(item.Text);
|
||||
if (item.Text.startsWith("Slot")) {
|
||||
restStr = item.Text.substring(5);
|
||||
modSlot = parseInt(restStr);
|
||||
}
|
||||
if (modSlot === undefined) return;
|
||||
|
||||
if (modSlot === 38) {
|
||||
localVehicle.setDoorOpen(5, false, false);
|
||||
} else if (modSlot === 39 || modSlot === 40 || modSlot === 41) {
|
||||
localVehicle.setDoorOpen(4, false, false);
|
||||
}
|
||||
|
||||
var door = getDoor(localVehicle.model, modSlot);
|
||||
if (door !== undefined) {
|
||||
localVehicle.setDoorOpen(door, false, false);
|
||||
}
|
||||
|
||||
var currentMod = localVehicle.getMod(modSlot);
|
||||
var oldToggleValue;
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = localVehicle.isToggleModOn(modSlot);
|
||||
currentMod = oldToggleValue ? 0 : -1;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
localVehicle.setLights(2);
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) {
|
||||
currentMod = -1;
|
||||
} else if (hlColor === 13) currentMod = 0;
|
||||
else currentMod = hlColor + 2;
|
||||
}
|
||||
|
||||
var currentModItem;
|
||||
|
||||
var modNum = localVehicle.getNumMods(modSlot);
|
||||
if (modSlot === 18) modNum = 1;
|
||||
if (modSlot === 22) modNum = 14;
|
||||
|
||||
modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
|
||||
|
||||
for (var i = -1; i < modNum; i++) {
|
||||
var modItem;
|
||||
|
||||
if (i === -1) {
|
||||
modItem = new UIMenuItem("Serie", "");
|
||||
} else {
|
||||
var modName = getModName(localVehicle, modSlot, i);
|
||||
|
||||
modItem = new UIMenuItem(modName, "");
|
||||
}
|
||||
|
||||
if (i === currentMod - (modSlot === 22 ? 1 : 0)) {
|
||||
modItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentModItem = modItem;
|
||||
}
|
||||
|
||||
modMenu.AddItem(modItem);
|
||||
}
|
||||
|
||||
modMenu.ItemSelect.on((selectedItem, index) => {
|
||||
if (currentModItem !== undefined) {
|
||||
currentModItem.SetRightBadge(BadgeStyle.None);
|
||||
}
|
||||
if (selectedItem !== undefined) {
|
||||
selectedItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentModItem = selectedItem;
|
||||
}
|
||||
mp.events.callRemote("setVehicleMod", modSlot, index);
|
||||
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
currentMod = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (index === 0) index = -1;
|
||||
currentMod = index - 1;
|
||||
});
|
||||
|
||||
modMenu.IndexChange.on((index) => {
|
||||
if (modSlot === 18) return;
|
||||
if (modSlot === 22) {
|
||||
setHeadlightsColor(localVehicle, index);
|
||||
return;
|
||||
}
|
||||
if (index === 0) index = -1;
|
||||
localVehicle.setMod(modSlot, index - 1);
|
||||
});
|
||||
|
||||
modMenu.MenuClose.on(() => {
|
||||
if (modSlot === 38) {
|
||||
localVehicle.setDoorShut(5, false);
|
||||
} else if (modSlot === 39 || modSlot === 40 || modSlot === 41) {
|
||||
localVehicle.setDoorShut(4, false);
|
||||
}
|
||||
|
||||
if (door !== undefined) {
|
||||
localVehicle.setDoorShut(door, false);
|
||||
}
|
||||
|
||||
if (closeMenu) {
|
||||
closeMenu = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mainMenu.Visible = true;
|
||||
modMenu.Visible = false;
|
||||
|
||||
if (modSlot === 18) return;
|
||||
else if (modSlot === 22) {
|
||||
localVehicle.setLights(1);
|
||||
setHeadlightsColor(localVehicle, currentMod);
|
||||
return;
|
||||
}
|
||||
localVehicle.setMod(modSlot, currentMod);
|
||||
});
|
||||
|
||||
mainMenu.Visible = false;
|
||||
modMenu.Visible = true;
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
localVehicle.setLights(0);
|
||||
globalData.InTuning = false;
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("playerLeaveVehicle", () => {
|
||||
if (keyBound) {
|
||||
mp.events.call("hideTuningInfo", true);
|
||||
}
|
||||
});
|
||||
|
||||
function getSlotName(slot) {
|
||||
var toReturn = "undefined";
|
||||
|
||||
carModSlotName.forEach((name) => {
|
||||
if (name.Slot === slot) toReturn = name.Name;
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getSlotId(slotName) {
|
||||
var toReturn = "undefined";
|
||||
|
||||
carModSlotName.forEach((name) => {
|
||||
if (name.Name === slotName) toReturn = name.Slot;
|
||||
});
|
||||
|
||||
if (toReturn === "undefined") {
|
||||
|
||||
toReturn = getCustomId(mp.players.local.vehicle.model, slotName);
|
||||
|
||||
if (toReturn === undefined) {
|
||||
carModTypes.forEach((modType) => {
|
||||
if (mp.game.ui.getLabelText(mp.players.local.vehicle.getModSlotName(modType)) === slotName) toReturn = getSlotId(getSlotName(modType));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getCustomName(model, slot) {
|
||||
var toReturn = undefined;
|
||||
|
||||
customPartNames.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Names.forEach((names) => {
|
||||
if (names.Slot === slot) toReturn = names.Name;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getCustomId(model, name) {
|
||||
var toReturn = undefined;
|
||||
|
||||
customPartNames.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Names.forEach((names) => {
|
||||
if (names.Name === name) toReturn = names.Slot;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getDoor(model, slot) {
|
||||
var toReturn = undefined;
|
||||
|
||||
doorOpeners.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Doors.forEach((door) => {
|
||||
if (door.Slot === slot) toReturn = door.Door;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getModName(vehicle, slot, mod) {
|
||||
var modName = vehicle.getModTextLabel(slot, mod);
|
||||
var realModName = mp.game.ui.getLabelText(modName);
|
||||
|
||||
if (slot === 11) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "EMS Verbesserung 1";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "EMS Verbesserung 2";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "EMS Verbesserung 3";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "EMS Verbesserung 4";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 12) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Straßenbremsen";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Sportbremsen";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Rennbremsen";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 13) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Straßengetriebe";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Sportgetriebe";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Renngetriebe";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 15) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Tiefere Federung";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Straßenfederung";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Sportfederung";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Rennfederung";
|
||||
break;
|
||||
case 4:
|
||||
realModName = "Wettkampffederung";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 18) {
|
||||
realModName = "Turbotuning";
|
||||
} else if (slot === 22) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Xenon Licht";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Weißes Licht";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Blaues Licht";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Hell-blaues Licht";
|
||||
break;
|
||||
case 4:
|
||||
realModName = "Grünes Licht";
|
||||
break;
|
||||
case 5:
|
||||
realModName = "Hell-grünes Licht";
|
||||
break;
|
||||
case 6:
|
||||
realModName = "Hell-gelbes Licht";
|
||||
break;
|
||||
case 7:
|
||||
realModName = "Gelbes Licht";
|
||||
break;
|
||||
case 8:
|
||||
realModName = "Orangenes Licht";
|
||||
break;
|
||||
case 9:
|
||||
realModName = "Rotes Licht";
|
||||
break;
|
||||
case 10:
|
||||
realModName = "Hell-pinkes Licht";
|
||||
break;
|
||||
case 11:
|
||||
realModName = "Pinkes Licht";
|
||||
break;
|
||||
case 12:
|
||||
realModName = "Lila Licht";
|
||||
break;
|
||||
case 13:
|
||||
realModName = "Hell-lila Licht";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return realModName;
|
||||
}
|
||||
|
||||
function setHeadlightsColor(vehicle, index) {
|
||||
var color = index - 2;
|
||||
if (index === 0) color = -1;
|
||||
if (index === 1) color = 13;
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
572
ReallifeGamemode.Client/Tuning/main.ts
Normal file
572
ReallifeGamemode.Client/Tuning/main.ts
Normal file
@@ -0,0 +1,572 @@
|
||||
/**
|
||||
* @overview Life of German Reallife - Tuning tuning.js
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
import * as NativeUI from 'NativeUI';
|
||||
const Menu = NativeUI.Menu;
|
||||
const UIMenuItem = NativeUI.UIMenuItem;
|
||||
const BadgeStyle = NativeUI.BadgeStyle;
|
||||
const Point = NativeUI.Point;
|
||||
|
||||
export default function tuning(globalData: GlobalData) {
|
||||
var keyBound = false;
|
||||
|
||||
var disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
|
||||
|
||||
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 33, 34, 35, 38, 39, 40, 41, 42, 43, 44, 46, 48, 69];
|
||||
|
||||
var carModSlotName = [
|
||||
{ Slot: 0, Name: "Spoiler" },
|
||||
{ Slot: 1, Name: "Frontstoßstange" },
|
||||
{ Slot: 2, Name: "Heckstoßstange" },
|
||||
{ Slot: 3, Name: "Seitenschweller" },
|
||||
{ Slot: 4, Name: "Auspuff" },
|
||||
{ Slot: 5, Name: "Rahmen" },
|
||||
{ Slot: 6, Name: "Kühlergrill" },
|
||||
{ Slot: 7, Name: "Motorhaube" },
|
||||
{ Slot: 8, Name: "Kotflügel" },
|
||||
{ Slot: 9, Name: "Rechter Kotflügel" },
|
||||
{ Slot: 10, Name: "Dach" },
|
||||
{ Slot: 11, Name: "Motor" },
|
||||
{ Slot: 12, Name: "Bremsen" },
|
||||
{ Slot: 13, Name: "Getriebe" },
|
||||
{ Slot: 14, Name: "Hupe" },
|
||||
{ Slot: 15, Name: "Federung" },
|
||||
{ Slot: 18, Name: "Turbo" },
|
||||
{ Slot: 22, Name: "Licht" },
|
||||
{ Slot: 23, Name: "Reifen" },
|
||||
{ Slot: 25, Name: "Nummernschildhalter" },
|
||||
{ Slot: 27, Name: "Innenausstatung" },
|
||||
{ Slot: 28, Name: "Wackelkopf" },
|
||||
{ Slot: 33, Name: "Lenkrad" },
|
||||
{ Slot: 34, Name: "Schalthebel" },
|
||||
{ Slot: 35, Name: "Schild" },
|
||||
{ Slot: 38, Name: "Hydraulik" },
|
||||
{ Slot: 39, Name: "Motorabdeckung" },
|
||||
{ Slot: 40, Name: "Luftfilter" },
|
||||
{ Slot: 46, Name: "Fenster" },
|
||||
{ Slot: 48, Name: "Design" }
|
||||
];
|
||||
|
||||
var customPartNames = [
|
||||
{
|
||||
Model: 1093792632,
|
||||
Names: [
|
||||
{
|
||||
Slot: 8,
|
||||
Name: "Lüftungsschlitze"
|
||||
},
|
||||
{
|
||||
Slot: 43,
|
||||
Name: "Motorhaubenstifte"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 223240013,
|
||||
Names: [
|
||||
{
|
||||
Slot: 9,
|
||||
Name: "Heckkotflügel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 1031562256,
|
||||
Names: [
|
||||
{
|
||||
Slot: 5,
|
||||
Name: "Stoßdämpfer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Model: 3308022675,
|
||||
Names: [
|
||||
{
|
||||
Slot: 9,
|
||||
Name: "Kotflügel"
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
var doorOpeners = [
|
||||
{
|
||||
Model: 3308022675,
|
||||
Doors: [
|
||||
{
|
||||
Slot: 5,
|
||||
Door: 4
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
var bikeModTypes = [];
|
||||
|
||||
var mainMenu;
|
||||
var modMenu;
|
||||
var closeMenu = false;
|
||||
|
||||
mp.events.add('showTuningInfo', () => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um dein Fahrzeug zu modifizieren');
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
keyBound = true;
|
||||
});
|
||||
|
||||
mp.events.add('hideTuningInfo', (unbind) => {
|
||||
mp.game.ui.clearHelp(true);
|
||||
mp.gui.chat.show(true);
|
||||
|
||||
if (mp.players.local.vehicle) {
|
||||
mp.players.local.vehicle.setLights(0);
|
||||
}
|
||||
|
||||
if (typeof mainMenu !== "undefined" && unbind) {
|
||||
mainMenu.Close();
|
||||
globalData.InTuning = false;
|
||||
}
|
||||
|
||||
if (typeof modMenu !== "undefined" && modMenu.Visible && unbind) {
|
||||
closeMenu = true;
|
||||
modMenu.Close();
|
||||
globalData.InTuning = false;
|
||||
}
|
||||
|
||||
if (keyBound && unbind) {
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
function keyPressHandler() {
|
||||
mp.events.callRemote("startPlayerTuning");
|
||||
}
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (globalData.InTuning) {
|
||||
disableInput.forEach((input) => {
|
||||
mp.game.controls.disableControlAction(1, input, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("showTuningMenu", () => {
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
var localPlayer = mp.players.local;
|
||||
var localVehicle = localPlayer.vehicle;
|
||||
|
||||
localVehicle.setHalt(1.0, true, false);
|
||||
|
||||
if (typeof mainMenu !== "undefined" && mainMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof modMenu !== "undefined" && modMenu.Visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
globalData.InTuning = true;
|
||||
|
||||
localVehicle.setLights(1);
|
||||
|
||||
var carName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(localVehicle.model));
|
||||
|
||||
mainMenu = new Menu("Fahrzeugwerkstatt", carName, new Point(50, 50), null, null);
|
||||
|
||||
if (localVehicle.getBodyHealth() !== 1000) {
|
||||
|
||||
var repairItem = new UIMenuItem("Fahrzeug reparieren");
|
||||
mainMenu.AddItem(repairItem);
|
||||
|
||||
mainMenu.ItemSelect.on((selectedItem, index) => {
|
||||
if (selectedItem === repairItem) {
|
||||
mp.events.callRemote("repairVehicle");
|
||||
mainMenu.Close();
|
||||
setTimeout(() => {
|
||||
mp.events.call("showTuningMenu");
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
globalData.InTuning = false;
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
});
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
carModTypes.forEach((modType) => {
|
||||
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
||||
var slotName = mp.game.ui.getLabelText(localVehicle.getModSlotName(modType));
|
||||
|
||||
if (slotName === "NULL") {
|
||||
slotName = getCustomName(localVehicle.model, modType);
|
||||
if (slotName === undefined) slotName = getSlotName(modType);
|
||||
}
|
||||
|
||||
if (slotName === "undefined") slotName = "Slot " + modType;
|
||||
|
||||
var menuItem = new UIMenuItem(slotName);
|
||||
var num = localVehicle.getNumMods(modType);
|
||||
if (num === undefined && modType !== 18 && modType !== 22) return;
|
||||
if (num !== 0 || modType === 18 || modType === 22) mainMenu.AddItem(menuItem);
|
||||
}
|
||||
});
|
||||
|
||||
mainMenu.Open();
|
||||
|
||||
mainMenu.ItemSelect.on((item) => {
|
||||
var modSlot: number = getSlotId(item.Text);
|
||||
if (item.Text.startsWith("Slot")) {
|
||||
var restStr = item.Text.substring(5);
|
||||
modSlot = parseInt(restStr);
|
||||
}
|
||||
if (modSlot === undefined) return;
|
||||
|
||||
if (modSlot === 38) {
|
||||
localVehicle.setDoorOpen(5, false, false);
|
||||
} else if (modSlot === 39 || modSlot === 40 || modSlot === 41) {
|
||||
localVehicle.setDoorOpen(4, false, false);
|
||||
}
|
||||
|
||||
var door = getDoor(localVehicle.model, modSlot);
|
||||
if (door !== undefined) {
|
||||
localVehicle.setDoorOpen(door, false, false);
|
||||
}
|
||||
|
||||
var currentMod = localVehicle.getMod(modSlot);
|
||||
var oldToggleValue;
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = localVehicle.isToggleModOn(modSlot);
|
||||
currentMod = oldToggleValue ? 0 : -1;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
localVehicle.setLights(2);
|
||||
var hlColor = localVehicle.getVariable("headlightColor");
|
||||
if (typeof hlColor !== "number" || isNaN(hlColor) || hlColor < 0 || hlColor === 255) {
|
||||
currentMod = -1;
|
||||
} else if (hlColor === 13) currentMod = 0;
|
||||
else currentMod = hlColor + 2;
|
||||
}
|
||||
|
||||
var currentModItem;
|
||||
|
||||
var modNum = localVehicle.getNumMods(modSlot);
|
||||
if (modSlot === 18) modNum = 1;
|
||||
if (modSlot === 22) modNum = 14;
|
||||
|
||||
modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50), null, null);
|
||||
|
||||
for (var i = -1; i < modNum; i++) {
|
||||
var modItem;
|
||||
|
||||
if (i === -1) {
|
||||
modItem = new UIMenuItem("Serie", "");
|
||||
} else {
|
||||
var modName = getModName(localVehicle, modSlot, i);
|
||||
|
||||
modItem = new UIMenuItem(modName, "");
|
||||
}
|
||||
|
||||
if (i === currentMod - (modSlot === 22 ? 1 : 0)) {
|
||||
modItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentModItem = modItem;
|
||||
}
|
||||
|
||||
modMenu.AddItem(modItem);
|
||||
}
|
||||
|
||||
modMenu.ItemSelect.on((selectedItem, index) => {
|
||||
if (currentModItem !== undefined) {
|
||||
currentModItem.SetRightBadge(BadgeStyle.None);
|
||||
}
|
||||
if (selectedItem !== undefined) {
|
||||
selectedItem.SetRightBadge(BadgeStyle.Car);
|
||||
currentModItem = selectedItem;
|
||||
}
|
||||
mp.events.callRemote("setVehicleMod", modSlot, index);
|
||||
|
||||
if (modSlot === 18) {
|
||||
oldToggleValue = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (modSlot === 22) {
|
||||
currentMod = index;
|
||||
return;
|
||||
}
|
||||
|
||||
if (index === 0) index = -1;
|
||||
currentMod = index - 1;
|
||||
});
|
||||
|
||||
modMenu.IndexChange.on((index) => {
|
||||
if (modSlot === 18) return;
|
||||
if (modSlot === 22) {
|
||||
setHeadlightsColor(localVehicle, index);
|
||||
return;
|
||||
}
|
||||
if (index === 0) index = -1;
|
||||
localVehicle.setMod(modSlot, index - 1);
|
||||
});
|
||||
|
||||
modMenu.MenuClose.on(() => {
|
||||
if (modSlot === 38) {
|
||||
localVehicle.setDoorShut(5, false);
|
||||
} else if (modSlot === 39 || modSlot === 40 || modSlot === 41) {
|
||||
localVehicle.setDoorShut(4, false);
|
||||
}
|
||||
|
||||
if (door !== undefined) {
|
||||
localVehicle.setDoorShut(door, false);
|
||||
}
|
||||
|
||||
if (closeMenu) {
|
||||
closeMenu = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mainMenu.Visible = true;
|
||||
modMenu.Visible = false;
|
||||
|
||||
if (modSlot === 18) return;
|
||||
else if (modSlot === 22) {
|
||||
localVehicle.setLights(1);
|
||||
setHeadlightsColor(localVehicle, currentMod);
|
||||
return;
|
||||
}
|
||||
localVehicle.setMod(modSlot, currentMod);
|
||||
});
|
||||
|
||||
mainMenu.Visible = false;
|
||||
modMenu.Visible = true;
|
||||
});
|
||||
|
||||
mainMenu.MenuClose.on(() => {
|
||||
localVehicle.setLights(0);
|
||||
globalData.InTuning = false;
|
||||
mp.events.call("hideTuningInfo", false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("playerLeaveVehicle", () => {
|
||||
if (keyBound) {
|
||||
mp.events.call("hideTuningInfo", true);
|
||||
}
|
||||
});
|
||||
|
||||
function getSlotName(slot) {
|
||||
var toReturn = "undefined";
|
||||
|
||||
carModSlotName.forEach((name) => {
|
||||
if (name.Slot === slot) toReturn = name.Name;
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getSlotId(slotName): number {
|
||||
var toReturn = undefined;
|
||||
|
||||
carModSlotName.forEach((name) => {
|
||||
if (name.Name === slotName) toReturn = name.Slot;
|
||||
});
|
||||
|
||||
if (toReturn === "undefined") {
|
||||
|
||||
toReturn = getCustomId(mp.players.local.vehicle.model, slotName);
|
||||
|
||||
if (toReturn === undefined) {
|
||||
carModTypes.forEach((modType) => {
|
||||
if (mp.game.ui.getLabelText(mp.players.local.vehicle.getModSlotName(modType)) === slotName) toReturn = getSlotId(getSlotName(modType));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getCustomName(model, slot) {
|
||||
var toReturn = undefined;
|
||||
|
||||
customPartNames.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Names.forEach((names) => {
|
||||
if (names.Slot === slot) toReturn = names.Name;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getCustomId(model, name) {
|
||||
var toReturn = undefined;
|
||||
|
||||
customPartNames.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Names.forEach((names) => {
|
||||
if (names.Name === name) toReturn = names.Slot;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getDoor(model, slot) {
|
||||
var toReturn = undefined;
|
||||
|
||||
doorOpeners.forEach((cpn) => {
|
||||
if (cpn.Model === model) {
|
||||
cpn.Doors.forEach((door) => {
|
||||
if (door.Slot === slot) toReturn = door.Door;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
function getModName(vehicle, slot, mod) {
|
||||
var modName = vehicle.getModTextLabel(slot, mod);
|
||||
var realModName = mp.game.ui.getLabelText(modName);
|
||||
|
||||
if (slot === 11) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "EMS Verbesserung 1";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "EMS Verbesserung 2";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "EMS Verbesserung 3";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "EMS Verbesserung 4";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 12) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Straßenbremsen";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Sportbremsen";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Rennbremsen";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 13) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Straßengetriebe";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Sportgetriebe";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Renngetriebe";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 15) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Tiefere Federung";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Straßenfederung";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Sportfederung";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Rennfederung";
|
||||
break;
|
||||
case 4:
|
||||
realModName = "Wettkampffederung";
|
||||
break;
|
||||
}
|
||||
} else if (slot === 18) {
|
||||
realModName = "Turbotuning";
|
||||
} else if (slot === 22) {
|
||||
switch (mod) {
|
||||
case 0:
|
||||
realModName = "Xenon Licht";
|
||||
break;
|
||||
case 1:
|
||||
realModName = "Weißes Licht";
|
||||
break;
|
||||
case 2:
|
||||
realModName = "Blaues Licht";
|
||||
break;
|
||||
case 3:
|
||||
realModName = "Hell-blaues Licht";
|
||||
break;
|
||||
case 4:
|
||||
realModName = "Grünes Licht";
|
||||
break;
|
||||
case 5:
|
||||
realModName = "Hell-grünes Licht";
|
||||
break;
|
||||
case 6:
|
||||
realModName = "Hell-gelbes Licht";
|
||||
break;
|
||||
case 7:
|
||||
realModName = "Gelbes Licht";
|
||||
break;
|
||||
case 8:
|
||||
realModName = "Orangenes Licht";
|
||||
break;
|
||||
case 9:
|
||||
realModName = "Rotes Licht";
|
||||
break;
|
||||
case 10:
|
||||
realModName = "Hell-pinkes Licht";
|
||||
break;
|
||||
case 11:
|
||||
realModName = "Pinkes Licht";
|
||||
break;
|
||||
case 12:
|
||||
realModName = "Lila Licht";
|
||||
break;
|
||||
case 13:
|
||||
realModName = "Hell-lila Licht";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return realModName;
|
||||
}
|
||||
|
||||
function setHeadlightsColor(vehicle, index) {
|
||||
var color = index - 2;
|
||||
if (index === 0) color = -1;
|
||||
if (index === 1) color = 13;
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
mp.keys.bind(0x42, true, _ => {
|
||||
mp.events.callRemote("keyPress:B:toggleSiren");
|
||||
});
|
||||
|
||||
mp.events.add('toggleVehicleSiren', (vehicle, state) => {
|
||||
vehicle.setSirenSound(state);
|
||||
});
|
||||
|
||||
mp.events.add('entityStreamIn', (entity) => {
|
||||
if (entity.isAVehicle()) {
|
||||
var state = entity.getVariable("sirenSound");
|
||||
if (state === undefined) return;
|
||||
entity.setSirenSound(state);
|
||||
}
|
||||
});
|
||||
17
ReallifeGamemode.Client/Tuning/sirensilence.ts
Normal file
17
ReallifeGamemode.Client/Tuning/sirensilence.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export default function sirenSilence() {
|
||||
mp.keys.bind(0x42, true, _ => {
|
||||
mp.events.callRemote("keyPress:B:toggleSiren");
|
||||
});
|
||||
|
||||
mp.events.add('toggleVehicleSiren', (vehicle, state) => {
|
||||
vehicle.setSirenSound(state);
|
||||
});
|
||||
|
||||
mp.events.add('entityStreamIn', (entity) => {
|
||||
if (entity.isAVehicle()) {
|
||||
var state = entity.getVariable("sirenSound");
|
||||
if (state === undefined) return;
|
||||
entity.setSirenSound(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
mp.events.add('entityStreamIn', (entity) => {
|
||||
if (entity.isAVehicle()) {
|
||||
var mod18 = entity.getVariable('mod18');
|
||||
|
||||
if (mod18 !== undefined) {
|
||||
entity.toggleMod(18, mod18);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('vehicleToggleMod', (veh, slot, newval) => {
|
||||
veh.toggleMod(slot, newval);
|
||||
});
|
||||
15
ReallifeGamemode.Client/Tuning/sync.ts
Normal file
15
ReallifeGamemode.Client/Tuning/sync.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export default function tuningSync() {
|
||||
mp.events.add('entityStreamIn', (entity) => {
|
||||
if (entity.isAVehicle()) {
|
||||
var mod18 = entity.getVariable('mod18');
|
||||
|
||||
if (mod18 !== undefined) {
|
||||
entity.toggleMod(18, mod18);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('vehicleToggleMod', (veh, slot, newval) => {
|
||||
veh.toggleMod(slot, newval);
|
||||
});
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<link rel="stylesheet" href="package://assets/css/save/blip/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -66,7 +66,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="package:///Dependencies/jquery-3.3.1.min.js"></script>
|
||||
<script src="save.js" type="text/javascript"></script>
|
||||
<script src="package://assets/js/jquery-3.3.1.min.js"></script>
|
||||
<script src="package://assets/js/save/blip/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +0,0 @@
|
||||
function setHeadlightsColor(vehicle, color) {
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add("entityStreamIn", (entity) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, parseInt(entity.getVariable("headlightColor")));
|
||||
});
|
||||
|
||||
mp.events.addDataHandler("headlightColor", (entity, value) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, value);
|
||||
});
|
||||
21
ReallifeGamemode.Client/coloredhlights/index.ts
Normal file
21
ReallifeGamemode.Client/coloredhlights/index.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export default function coloredHeadLights() {
|
||||
function setHeadlightsColor(vehicle, color) {
|
||||
if (typeof color !== "number" || isNaN(color) || color < 0 || color === 255) {
|
||||
// Disable
|
||||
vehicle.toggleMod(22, false);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, 255);
|
||||
} else {
|
||||
// Enable
|
||||
vehicle.toggleMod(22, true);
|
||||
mp.game.invoke("0xE41033B25D003A07", vehicle.handle, color);
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add("entityStreamIn", (entity) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, parseInt(entity.getVariable("headlightColor")));
|
||||
});
|
||||
|
||||
mp.events.addDataHandler("headlightColor", (entity, value) => {
|
||||
if (entity.type === "vehicle") setHeadlightsColor(entity, value);
|
||||
});
|
||||
}
|
||||
9
ReallifeGamemode.Client/global.d.ts
vendored
9
ReallifeGamemode.Client/global.d.ts
vendored
@@ -4,3 +4,12 @@
|
||||
Interaction: boolean,
|
||||
InChat: boolean
|
||||
}
|
||||
|
||||
declare interface FactionRanks {
|
||||
factionId: number,
|
||||
ranks: FactionRank[]
|
||||
}
|
||||
|
||||
declare interface FactionRank {
|
||||
|
||||
}
|
||||
@@ -8,54 +8,92 @@ let globalData: GlobalData = {
|
||||
InTuning: false,
|
||||
HideGui: false,
|
||||
Interaction: false,
|
||||
InChat: false
|
||||
InChat: false,
|
||||
};
|
||||
|
||||
//ALPHABETISCH SORTIERT UND ZUSAMMENGEFÜGT
|
||||
import business from './Business/main';
|
||||
business();
|
||||
|
||||
//require('./Business/main.js');
|
||||
//require('./Business/cardealer.js');
|
||||
import cardealer from './Business/cardealer';
|
||||
cardealer();
|
||||
|
||||
//require('./CharCreator/index.js');
|
||||
//import charCreator from './CharCreator/main';
|
||||
//charCreator();
|
||||
|
||||
//require('./coloredhlights');
|
||||
import coloredHeadLights from './coloredhlights/index';
|
||||
coloredHeadLights();
|
||||
|
||||
//require('./DoorManager/doormanager.js');
|
||||
import doorManager from './DoorManager/doormanager';
|
||||
doorManager();
|
||||
|
||||
//require('./FactionManagement/main.js');
|
||||
import factionManagement from './FactionManagement/main';
|
||||
factionManagement();
|
||||
|
||||
//require('./Gui/deathscreen.js');
|
||||
import deathScreen from './Gui/deathscreen';
|
||||
deathScreen();
|
||||
|
||||
import Infobox from './Gui/infobox';
|
||||
Infobox(globalData);
|
||||
|
||||
//require('./Gui/nametags.js');
|
||||
//require('./Gui/playerlist.js');
|
||||
//require('./Gui/Inventory/inventory.js');
|
||||
//require('./Gui/vehiclemenu/main.js');
|
||||
//require('./Gui/interiors.js');
|
||||
import nametags from './Gui/nametags';
|
||||
nametags();
|
||||
|
||||
//require('./Interaction/factioninteraction.js');
|
||||
//require('./Interaction/playerinteraction.js');
|
||||
import playerList from './Gui/playerlist';
|
||||
playerList();
|
||||
|
||||
import inventory from './Gui/Inventory/inventory';
|
||||
inventory();
|
||||
|
||||
import vehicleMenu from './Gui/vehiclemenu/main';
|
||||
vehicleMenu();
|
||||
|
||||
import interiors from './Gui/interiors';
|
||||
interiors(globalData);
|
||||
|
||||
import factionInteraction from './Interaction/factioninteraction';
|
||||
factionInteraction(globalData);
|
||||
|
||||
import playerInteraction from './Interaction/playerinteraction';
|
||||
playerInteraction(globalData);
|
||||
|
||||
import Login from './Login/main';
|
||||
Login();
|
||||
|
||||
//require('./Player/dutycloth.js');
|
||||
//require('./Player/keys.js');
|
||||
//require('./Player/quit.js');
|
||||
//require('./Player/freecam.js');
|
||||
import dutyCloth from './Player/dutycloth';
|
||||
dutyCloth();
|
||||
|
||||
//require('./Save/main.js');
|
||||
import keys from './Player/keys';
|
||||
keys(globalData);
|
||||
|
||||
//require('./Speedometer/index.js');
|
||||
import quitHandler from './Player/quit';
|
||||
quitHandler();
|
||||
|
||||
//require('./Tuning/main.js');
|
||||
//require('./Tuning/sync.js');
|
||||
//require('./Tuning/sirensilence.js');
|
||||
import freecam from './Player/freecam';
|
||||
freecam();
|
||||
|
||||
//require('./util/waypoint.js');
|
||||
import saveManager from './Save/main';
|
||||
saveManager();
|
||||
|
||||
//require('./vehiclesync/vehiclesync.js');
|
||||
//require('./vehiclesync/smoothtrottle.js');
|
||||
//require('./vehiclesync/vehicleindicators.js');
|
||||
import speedometer from './Speedometer';
|
||||
speedometer(globalData);
|
||||
|
||||
import tuning from './Tuning/main';
|
||||
tuning(globalData);
|
||||
|
||||
import tuningSync from './Tuning/sync';
|
||||
tuningSync();
|
||||
|
||||
import sirenSilence from './Tuning/sirensilence';
|
||||
sirenSilence();
|
||||
|
||||
import waypointUtil from './util/waypoint';
|
||||
waypointUtil();
|
||||
|
||||
import vehicleSync from './vehiclesync/vehiclesync';
|
||||
vehicleSync();
|
||||
|
||||
import smoothThrottle from './vehiclesync/smoothtrottle';
|
||||
smoothThrottle();
|
||||
|
||||
import vehicleIndicators from './vehiclesync/vehicleindicators';
|
||||
vehicleIndicators();
|
||||
@@ -1,5 +1,10 @@
|
||||
class InputHelper {
|
||||
constructor(title) {
|
||||
export default class InputHelper {
|
||||
title: string;
|
||||
value: string;
|
||||
created: boolean;
|
||||
browser: BrowserMp;
|
||||
|
||||
constructor(title: string) {
|
||||
this.title = title;
|
||||
|
||||
this.cefTitleCall = this.cefTitleCall.bind(this);
|
||||
@@ -57,7 +62,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
async getValue(callback) {
|
||||
async getValue(callback: Function) {
|
||||
var getVal = await this.valueGetter();
|
||||
callback(getVal);
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function (money, digits = 0) {
|
||||
export default function (money: number, digits: number = 0) {
|
||||
return money.toLocaleString("de-DE", { minimumFractionDigits: digits });
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
8
ReallifeGamemode.Client/package-lock.json
generated
8
ReallifeGamemode.Client/package-lock.json
generated
@@ -176,8 +176,8 @@
|
||||
"integrity": "sha512-vVjM0SVzgaOUpflq4GYBvCpozes8OgIIS5gVXVka+OfK3hvnkC1i93U8WiY2OtNE4XUWyyy/86Kf6e0IHTQw1Q=="
|
||||
},
|
||||
"@types/ragemp-c": {
|
||||
"version": "github:CocaColaBear/types-ragemp-c#22f1d92d2b1e20abcfa5ecd6178b68bf3cc48e33",
|
||||
"from": "github:CocaColaBear/types-ragemp-c#master",
|
||||
"version": "git+https://github.com/sprayzcs/types-ragemp-c.git#cf1bca57f525e48157f1b38af2369127cb31ea51",
|
||||
"from": "git+https://github.com/sprayzcs/types-ragemp-c.git#master",
|
||||
"dev": true
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
@@ -348,6 +348,10 @@
|
||||
"resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
|
||||
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ=="
|
||||
},
|
||||
"NativeUI": {
|
||||
"version": "git+https://github.com/sprayzcs/RageMP-NativeUI.git#0ca40b56d9124056ceb9ca016d209aa4e3ecfeb3",
|
||||
"from": "git+https://github.com/sprayzcs/RageMP-NativeUI.git#master"
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
"name": "reallifegamemode.client",
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"@types/ragemp-c": "github:CocaColaBear/types-ragemp-c#master",
|
||||
"@types/ragemp-c": "git+https://github.com/sprayzcs/types-ragemp-c.git#master",
|
||||
"uglifyjs-webpack-plugin": "^2.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.3.4",
|
||||
"@types/node": "^11.9.5",
|
||||
"NativeUI": "git+https://github.com/sprayzcs/RageMP-NativeUI.git#master",
|
||||
"babel-loader": "^8.0.5",
|
||||
"ts-loader": "^5.3.3",
|
||||
"typescript": "^3.3.3333",
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": [
|
||||
"**/*"
|
||||
"**/*",
|
||||
"node_modules/NativeUI/index.ts"
|
||||
],
|
||||
"files": [
|
||||
"node_modules/NativeUI/index.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
mp.events.add("SERVER:Util_setWaypoint", (x, y) => {
|
||||
mp.game.ui.setNewWaypoint(x, y);
|
||||
});
|
||||
5
ReallifeGamemode.Client/util/waypoint.ts
Normal file
5
ReallifeGamemode.Client/util/waypoint.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function waypointUtil() {
|
||||
mp.events.add("SERVER:Util_setWaypoint", (x, y) => {
|
||||
mp.game.ui.setNewWaypoint(x, y);
|
||||
});
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
//This script will make vehicles have smoother acceleration.
|
||||
//To disable the script call an event and set "GlobalDisable" to true.
|
||||
//To disable individual sections, set "DisableAntiReverse" or "DisableSmoothThrottle" to true.
|
||||
|
||||
//This script includes an anti-reverse brake system with automatic brake lights.
|
||||
|
||||
//When you brake, while holding brake you will come to a complete stop and won't reverse until you
|
||||
//release the brake button and press it again.
|
||||
|
||||
mp.events.add("SmoothThrottle_PlayerEnterVehicle", (entity, seat) =>
|
||||
{
|
||||
BrakeSystem = true;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_PlayerExitVehicle", (entity) =>
|
||||
{
|
||||
BrakeSystem = false;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetSmoothThrottle", (turnedOn) =>
|
||||
{
|
||||
DisableSmoothThrottle = !turnedOn;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetAntiReverse", (turnedOn) =>
|
||||
{
|
||||
DisableAntiReverse = !turnedOn;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetGlobal", (turnedOn) =>
|
||||
{
|
||||
GlobalDisable = !turnedOn;
|
||||
});
|
||||
|
||||
let GlobalDisable = false;
|
||||
let DisableAntiReverse = false;
|
||||
let DisableSmoothThrottle = false;
|
||||
|
||||
let BrakeSystem = false;
|
||||
let vehicleStopped = false;
|
||||
let vehicleStoppedOnOwn = false;
|
||||
let constantStart = 0.25; //starts at 0.25 and increases to 1
|
||||
let constantStep = 0.135; //You can change this for a faster throttle response (Will cause more skidding)
|
||||
|
||||
let deltaAmount = constantStart;
|
||||
let prevTime = mp.game.invoke('0x9CD27B0045628463');
|
||||
let diffToggle = false;
|
||||
|
||||
mp.events.add("render", () =>
|
||||
{
|
||||
if(GlobalDisable)
|
||||
return;
|
||||
|
||||
if(BrakeSystem)
|
||||
{
|
||||
if(mp.players.local.vehicle !== null)
|
||||
{
|
||||
if(!mp.players.local.vehicle.isSeatFree(-1)) //only do this if the vehicle has a driver (doesn't have to be the player who is rendering this)
|
||||
{
|
||||
//Optimize function calls to variables (probably doesn't make a difference)
|
||||
let vehClass = mp.players.local.vehicle.getClass();
|
||||
let isControl71Pressed = mp.game.controls.isControlPressed(0, 71); //accelerate
|
||||
let isControl72Pressed = mp.game.controls.isControlPressed(0, 72); //brake
|
||||
let isControl76Pressed = mp.game.controls.isControlPressed(0, 76); //handbrake
|
||||
let speed = mp.players.local.vehicle.getSpeed();
|
||||
|
||||
//Only do it to car classes
|
||||
if(!DisableSmoothThrottle && ((vehClass >= 0 && vehClass <= 12) || vehClass === 18 || vehClass === 19 || vehClass === 20))
|
||||
{
|
||||
if(isControl71Pressed || isControl72Pressed)
|
||||
{
|
||||
if(isControl76Pressed)
|
||||
{
|
||||
deltaAmount = 1.0; //If people are buffering their throttle up
|
||||
}
|
||||
|
||||
mp.players.local.vehicle.setEngineTorqueMultiplier(deltaAmount);
|
||||
|
||||
//Calculate tick time and step every 250ms
|
||||
if (mp.game.invoke('0x9CD27B0045628463') - prevTime > 250)
|
||||
{
|
||||
prevTime = mp.game.invoke('0x9CD27B0045628463');
|
||||
deltaAmount += constantStep * speed; //Curve
|
||||
if(deltaAmount > 1.0)
|
||||
{
|
||||
deltaAmount = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deltaAmount = constantStart; //Reset when they let go of throttle
|
||||
//mp.game.controls.setControlNormal(0, 71, amount);
|
||||
}
|
||||
}
|
||||
|
||||
//THIS IS THE BRAKE LIGHT SYSTEM WITH ANTI-REVERSE
|
||||
if(DisableAntiReverse)
|
||||
return;
|
||||
|
||||
if(speed < 1)
|
||||
{
|
||||
vehicleStopped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
vehicleStopped = false;
|
||||
vehicleStoppedOnOwn = false;
|
||||
diffToggle = false;
|
||||
}
|
||||
|
||||
if((!isControl72Pressed && mp.game.controls.isControlEnabled(0, 72)) && !isControl76Pressed && vehicleStopped)
|
||||
{
|
||||
vehicleStoppedOnOwn = true;
|
||||
mp.players.local.vehicle.setBrakeLights(true);
|
||||
}
|
||||
|
||||
if(vehicleStopped && !vehicleStoppedOnOwn && !mp.players.local.vehicle.isInBurnout() && !diffToggle)
|
||||
{
|
||||
mp.players.local.vehicle.setBrakeLights(true);
|
||||
mp.game.controls.disableControlAction(0, 72, true);
|
||||
}
|
||||
|
||||
if((isControl71Pressed && !isControl72Pressed) || isControl76Pressed)
|
||||
{
|
||||
mp.players.local.vehicle.setBrakeLights(false);
|
||||
}
|
||||
|
||||
if(mp.game.controls.isDisabledControlJustReleased(0, 72) && vehicleStopped)
|
||||
{
|
||||
mp.game.controls.enableControlAction(0, 72, true);
|
||||
diffToggle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
119
ReallifeGamemode.Client/vehiclesync/smoothtrottle.ts
Normal file
119
ReallifeGamemode.Client/vehiclesync/smoothtrottle.ts
Normal file
@@ -0,0 +1,119 @@
|
||||
//This script will make vehicles have smoother acceleration.
|
||||
//To disable the script call an event and set "GlobalDisable" to true.
|
||||
//To disable individual sections, set "DisableAntiReverse" or "DisableSmoothThrottle" to true.
|
||||
|
||||
//This script includes an anti-reverse brake system with automatic brake lights.
|
||||
|
||||
//When you brake, while holding brake you will come to a complete stop and won't reverse until you
|
||||
//release the brake button and press it again.
|
||||
|
||||
export default function smoothThrottle() {
|
||||
let GlobalDisable = false;
|
||||
let DisableAntiReverse = false;
|
||||
let DisableSmoothThrottle = false;
|
||||
|
||||
let BrakeSystem = false;
|
||||
let vehicleStopped = false;
|
||||
let vehicleStoppedOnOwn = false;
|
||||
let constantStart = 0.25; //starts at 0.25 and increases to 1
|
||||
let constantStep = 0.135; //You can change this for a faster throttle response (Will cause more skidding)
|
||||
|
||||
let deltaAmount = constantStart;
|
||||
let prevTime = mp.game.invoke('0x9CD27B0045628463');
|
||||
let diffToggle = false;
|
||||
|
||||
mp.events.add("SmoothThrottle_PlayerEnterVehicle", (entity, seat) => {
|
||||
BrakeSystem = true;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_PlayerExitVehicle", (entity) => {
|
||||
BrakeSystem = false;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetSmoothThrottle", (turnedOn) => {
|
||||
DisableSmoothThrottle = !turnedOn;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetAntiReverse", (turnedOn) => {
|
||||
DisableAntiReverse = !turnedOn;
|
||||
});
|
||||
|
||||
mp.events.add("SmoothThrottle_SetGlobal", (turnedOn) => {
|
||||
GlobalDisable = !turnedOn;
|
||||
});
|
||||
|
||||
mp.events.add("render", () => {
|
||||
if (GlobalDisable)
|
||||
return;
|
||||
|
||||
if (BrakeSystem) {
|
||||
if (mp.players.local.vehicle !== null) {
|
||||
if (!mp.players.local.vehicle.isSeatFree(-1)) //only do this if the vehicle has a driver (doesn't have to be the player who is rendering this)
|
||||
{
|
||||
//Optimize function calls to variables (probably doesn't make a difference)
|
||||
let vehClass = mp.players.local.vehicle.getClass();
|
||||
let isControl71Pressed = mp.game.controls.isControlPressed(0, 71); //accelerate
|
||||
let isControl72Pressed = mp.game.controls.isControlPressed(0, 72); //brake
|
||||
let isControl76Pressed = mp.game.controls.isControlPressed(0, 76); //handbrake
|
||||
let speed = mp.players.local.vehicle.getSpeed();
|
||||
|
||||
//Only do it to car classes
|
||||
if (!DisableSmoothThrottle && ((vehClass >= 0 && vehClass <= 12) || vehClass === 18 || vehClass === 19 || vehClass === 20)) {
|
||||
if (isControl71Pressed || isControl72Pressed) {
|
||||
if (isControl76Pressed) {
|
||||
deltaAmount = 1.0; //If people are buffering their throttle up
|
||||
}
|
||||
|
||||
mp.players.local.vehicle.setEngineTorqueMultiplier(deltaAmount);
|
||||
|
||||
//Calculate tick time and step every 250ms
|
||||
if (mp.game.invoke('0x9CD27B0045628463') - prevTime > 250) {
|
||||
prevTime = mp.game.invoke('0x9CD27B0045628463');
|
||||
deltaAmount += constantStep * speed; //Curve
|
||||
if (deltaAmount > 1.0) {
|
||||
deltaAmount = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
deltaAmount = constantStart; //Reset when they let go of throttle
|
||||
//mp.game.controls.setControlNormal(0, 71, amount);
|
||||
}
|
||||
}
|
||||
|
||||
//THIS IS THE BRAKE LIGHT SYSTEM WITH ANTI-REVERSE
|
||||
if (DisableAntiReverse)
|
||||
return;
|
||||
|
||||
if (speed < 1) {
|
||||
vehicleStopped = true;
|
||||
}
|
||||
else {
|
||||
vehicleStopped = false;
|
||||
vehicleStoppedOnOwn = false;
|
||||
diffToggle = false;
|
||||
}
|
||||
|
||||
if ((!isControl72Pressed && mp.game.controls.isControlEnabled(0, 72)) && !isControl76Pressed && vehicleStopped) {
|
||||
vehicleStoppedOnOwn = true;
|
||||
mp.players.local.vehicle.setBrakeLights(true);
|
||||
}
|
||||
|
||||
if (vehicleStopped && !vehicleStoppedOnOwn && !mp.players.local.vehicle.isInBurnout() && !diffToggle) {
|
||||
mp.players.local.vehicle.setBrakeLights(true);
|
||||
mp.game.controls.disableControlAction(0, 72, true);
|
||||
}
|
||||
|
||||
if ((isControl71Pressed && !isControl72Pressed) || isControl76Pressed) {
|
||||
mp.players.local.vehicle.setBrakeLights(false);
|
||||
}
|
||||
|
||||
if (mp.game.controls.isDisabledControlJustReleased(0, 72) && vehicleStopped) {
|
||||
mp.game.controls.enableControlAction(0, 72, true);
|
||||
diffToggle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
var player = mp.players.local;
|
||||
|
||||
mp.keys.bind(0x64, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleLeftIndicator");
|
||||
});
|
||||
|
||||
mp.keys.bind(0x66, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleRightIndicator");
|
||||
});
|
||||
|
||||
mp.keys.bind(0x65, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleWarningIndicator");
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:setIndicatorStatus", (vehicle, left, right) => {
|
||||
var veh = mp.vehicles.atRemoteId(vehicle);
|
||||
|
||||
veh.setIndicatorLights(0, right);
|
||||
veh.setIndicatorLights(1, left);
|
||||
});
|
||||
|
||||
mp.events.add("entityStreamIn", entity => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
|
||||
var data = entity.getVariable("indicatorData");
|
||||
if (data) {
|
||||
entity.setIndicatorLights(0, data.Right);
|
||||
entity.setIndicatorLights(1, data.Left);
|
||||
}
|
||||
});
|
||||
36
ReallifeGamemode.Client/vehiclesync/vehicleindicators.ts
Normal file
36
ReallifeGamemode.Client/vehiclesync/vehicleindicators.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
const player = mp.players.local;
|
||||
|
||||
export default function vehicleIndicators() {
|
||||
|
||||
mp.keys.bind(0x64, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleLeftIndicator");
|
||||
});
|
||||
|
||||
mp.keys.bind(0x66, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleRightIndicator");
|
||||
});
|
||||
|
||||
mp.keys.bind(0x65, true, function () {
|
||||
if (!player.vehicle) return;
|
||||
mp.events.callRemote("CLIENT:toggleWarningIndicator");
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:setIndicatorStatus", (vehicle, left, right) => {
|
||||
var veh = mp.vehicles.atRemoteId(vehicle);
|
||||
|
||||
veh.setIndicatorLights(0, right);
|
||||
veh.setIndicatorLights(1, left);
|
||||
});
|
||||
|
||||
mp.events.add("entityStreamIn", entity => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
|
||||
var data = entity.getVariable("indicatorData");
|
||||
if (data) {
|
||||
entity.setIndicatorLights(0, data.Right);
|
||||
entity.setIndicatorLights(1, data.Left);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,548 +0,0 @@
|
||||
//Disapproved by the entire planet
|
||||
//You don't need to worry about anything here
|
||||
|
||||
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on
|
||||
{
|
||||
veh.setEngineOn(status, true, false);
|
||||
veh.setUndriveable(true);
|
||||
}
|
||||
else {
|
||||
veh.setEngineOn(status, false, true);
|
||||
veh.setUndriveable(!status);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetLockStatus", (veh, status) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (status)
|
||||
veh.setDoorsLocked(2);
|
||||
else
|
||||
veh.setDoorsLocked(1);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||
var toggle = entity.getVariable("VehicleSyncData");
|
||||
entity.setEngineOn(toggle.Engine, false, true);
|
||||
entity.setUndriveable(!toggle.Engine);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity !== undefined) {
|
||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||
var toggle = entity.getVariable("VehicleSyncData");
|
||||
entity.setEngineOn(toggle.Engine, true, false);
|
||||
entity.setUndriveable(!toggle.Engine);
|
||||
}
|
||||
|
||||
var level = entity.getDirtLevel();
|
||||
mp.events.callRemote("VehStream_SetDirtLevel", entity, level);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
var Status = [];
|
||||
let y = 0;
|
||||
for (y = 0; y < 8; y++) {
|
||||
if (entity.isDoorDamaged(y)) {
|
||||
Status.push(2);
|
||||
}
|
||||
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
||||
|
||||
Status = [];
|
||||
if (entity.isWindowIntact(0)) {
|
||||
if (entity.getBoneIndexByName("window_rf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(1)) {
|
||||
if (entity.getBoneIndexByName("window_lf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(2)) {
|
||||
if (entity.getBoneIndexByName("window_rr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(3)) {
|
||||
if (entity.getBoneIndexByName("window_lr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
||||
|
||||
Status = [];
|
||||
if (!entity.isTyreBurst(0, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(0, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(1, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(1, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(2, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(2, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(3, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(3, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(4, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(4, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(5, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(5, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(6, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(6, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(7, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(7, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(45, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(45, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(47, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(47, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
|
||||
}, 2500);
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
setTimeout(() => {
|
||||
var Status = [];
|
||||
let y = 0;
|
||||
for (y = 0; y < 8; y++) {
|
||||
if (entity.isDoorDamaged(y)) {
|
||||
Status.push(2);
|
||||
}
|
||||
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
//mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
||||
|
||||
Status = [];
|
||||
if (entity.isWindowIntact(0)) {
|
||||
if (entity.getBoneIndexByName("window_rf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(1)) {
|
||||
if (entity.getBoneIndexByName("window_lf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(2)) {
|
||||
if (entity.getBoneIndexByName("window_rr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(3)) {
|
||||
if (entity.getBoneIndexByName("window_lr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity !== undefined) {
|
||||
entity.setDirtLevel(dirt);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (state === 0) {
|
||||
veh.setDoorShut(door, false);
|
||||
}
|
||||
else if (state === 1) {
|
||||
veh.setDoorOpen(door, false, false);
|
||||
}
|
||||
else {
|
||||
veh.setDoorBroken(door, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < args.length; y++) {
|
||||
if (args[y] === 0) {
|
||||
args[0].setDoorShut(y - 1, false);
|
||||
}
|
||||
else if (args[y] === 1) {
|
||||
args[0].setDoorOpen(y - 1, false, false);
|
||||
}
|
||||
else {
|
||||
args[0].setDoorBroken(y - 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (state === 1) {
|
||||
veh.rollDownWindow(windw);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.fixWindow(windw);
|
||||
veh.rollUpWindow(windw);
|
||||
}
|
||||
else {
|
||||
veh.smashWindow(windw);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < 4; y++) {
|
||||
if (args[y] === 1) {
|
||||
args[0].rollDownWindow(y - 1);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].fixWindow(y - 1);
|
||||
args[0].rollUpWindow(y - 1);
|
||||
}
|
||||
else {
|
||||
args[0].smashWindow(y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (wheel === 9) {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(45, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(45);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(45, true, 1000);
|
||||
}
|
||||
}
|
||||
else if (wheel === 10) {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(47, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(47);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(wheel, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(wheel);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(wheel, true, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < args.length; y++) {
|
||||
if (y === 9) {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(45, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(45);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(45, true, 1000);
|
||||
}
|
||||
}
|
||||
else if (y === 10) {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(47, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(47);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(y - 1, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(y - 1);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(y - 1, true, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Sync data on stream in
|
||||
mp.events.add("entityStreamIn", (entity) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity.type === "vehicle") {
|
||||
let typeor = typeof entity.getVariable('VehicleSyncData');
|
||||
let actualData = entity.getVariable('VehicleSyncData');
|
||||
|
||||
//Needed to stop vehicles from freaking out
|
||||
mp.game.streaming.requestCollisionAtCoord(entity.position.x, entity.position.y, entity.position.z);
|
||||
//mp.game.invoke('0x199640F55E0F7596', entity.position.x, entity.position.y, entity.position.z);
|
||||
entity.setLoadCollisionFlag(true);
|
||||
entity.trackVisibility();
|
||||
|
||||
if (typeor !== 'undefined' && entity.isSeatFree(-1)) //Only if there is no driver
|
||||
{
|
||||
entity.position = actualData.Position;
|
||||
entity.rotation = actualData.Rotation;
|
||||
}
|
||||
|
||||
//Set doors unbreakable for a moment
|
||||
let x = 0;
|
||||
for (x = 0; x < 8; x++) {
|
||||
entity.setDoorBreakable(x, false);
|
||||
}
|
||||
|
||||
//Do it anyway
|
||||
entity.setUndriveable(true);
|
||||
|
||||
if (typeor !== 'undefined') {
|
||||
entity.setEngineOn(actualData.Engine, true, false);
|
||||
entity.setUndriveable(true);
|
||||
|
||||
if (actualData.Locked)
|
||||
entity.setDoorsLocked(2);
|
||||
else
|
||||
entity.setDoorsLocked(1);
|
||||
|
||||
entity.setDirtLevel(actualData.Dirt);
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
if (actualData.Door[x] === 1)
|
||||
entity.setDoorOpen(x, false, false);
|
||||
else if (actualData.Door[x] === 0)
|
||||
entity.setDoorShut(x, true);
|
||||
else
|
||||
entity.setDoorBroken(x, true);
|
||||
}
|
||||
|
||||
for (x = 0; x < 4; x++) {
|
||||
if (actualData.Window[x] === 0) {
|
||||
entity.fixWindow(x);
|
||||
}
|
||||
else if (actualData.Window[x] === 1) {
|
||||
entity.rollDownWindow(x);
|
||||
}
|
||||
else {
|
||||
entity.smashWindow(x);
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
if (actualData.Wheel[x] === 0) {
|
||||
entity.setTyreFixed(x);
|
||||
}
|
||||
else if (actualData.Wheel[x] === 1) {
|
||||
entity.setTyreBurst(x, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(x, true, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
//For trailer mid wheels
|
||||
if (actualData.Wheel[8] === 0) {
|
||||
entity.setTyreFixed(45);
|
||||
}
|
||||
else if (actualData.Wheel[8] === 1) {
|
||||
entity.setTyreBurst(45, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(45, true, 1000);
|
||||
}
|
||||
|
||||
if (actualData.Wheel[9] === 0) {
|
||||
entity.setTyreFixed(47);
|
||||
}
|
||||
else if (actualData.Wheel[9] === 1) {
|
||||
entity.setTyreBurst(47, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
//Make doors breakable again
|
||||
setTimeout(() => {
|
||||
for (x = 0; x < 8; x++) {
|
||||
entity.setDoorBreakable(x, true);
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
549
ReallifeGamemode.Client/vehiclesync/vehiclesync.ts
Normal file
549
ReallifeGamemode.Client/vehiclesync/vehiclesync.ts
Normal file
@@ -0,0 +1,549 @@
|
||||
//Disapproved by the entire planet
|
||||
//You don't need to worry about anything here
|
||||
export default function vehicleSync() {
|
||||
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on
|
||||
{
|
||||
veh.setEngineOn(status, true, false);
|
||||
veh.setUndriveable(true);
|
||||
}
|
||||
else {
|
||||
veh.setEngineOn(status, false, true);
|
||||
veh.setUndriveable(!status);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetLockStatus", (veh, status) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (status)
|
||||
veh.setDoorsLocked(2);
|
||||
else
|
||||
veh.setDoorsLocked(1);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||
var toggle = entity.getVariable("VehicleSyncData");
|
||||
entity.setEngineOn(toggle.Engine, false, true);
|
||||
entity.setUndriveable(!toggle.Engine);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity !== undefined) {
|
||||
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
|
||||
var toggle = entity.getVariable("VehicleSyncData");
|
||||
entity.setEngineOn(toggle.Engine, true, false);
|
||||
entity.setUndriveable(!toggle.Engine);
|
||||
}
|
||||
|
||||
var level = entity.getDirtLevel();
|
||||
mp.events.callRemote("VehStream_SetDirtLevel", entity, level);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
var Status = [];
|
||||
let y = 0;
|
||||
for (y = 0; y < 8; y++) {
|
||||
if (entity.isDoorDamaged(y)) {
|
||||
Status.push(2);
|
||||
}
|
||||
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
||||
|
||||
Status = [];
|
||||
if (entity.isWindowIntact(0)) {
|
||||
if (entity.getBoneIndexByName("window_rf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(1)) {
|
||||
if (entity.getBoneIndexByName("window_lf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(2)) {
|
||||
if (entity.getBoneIndexByName("window_rr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(3)) {
|
||||
if (entity.getBoneIndexByName("window_lr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
||||
|
||||
Status = [];
|
||||
if (!entity.isTyreBurst(0, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(0, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(1, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(1, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(2, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(2, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(3, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(3, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(4, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(4, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(5, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(5, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(6, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(6, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(7, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(7, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(45, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(45, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
if (!entity.isTyreBurst(47, false)) {
|
||||
Status.push(0);
|
||||
}
|
||||
else if (entity.isTyreBurst(47, false)) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
|
||||
mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]);
|
||||
}, 2500);
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => {
|
||||
entity = mp.vehicles.atRemoteId(entity);
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
setTimeout(() => {
|
||||
var Status = [];
|
||||
let y = 0;
|
||||
for (y = 0; y < 8; y++) {
|
||||
if (entity.isDoorDamaged(y)) {
|
||||
Status.push(2);
|
||||
}
|
||||
else if (entity.getDoorAngleRatio(y) > 0.15) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
//mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]);
|
||||
|
||||
Status = [];
|
||||
if (entity.isWindowIntact(0)) {
|
||||
if (entity.getBoneIndexByName("window_rf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(1)) {
|
||||
if (entity.getBoneIndexByName("window_lf") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(2)) {
|
||||
if (entity.getBoneIndexByName("window_rr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
if (entity.isWindowIntact(3)) {
|
||||
if (entity.getBoneIndexByName("window_lr") === -1) {
|
||||
Status.push(1);
|
||||
}
|
||||
else {
|
||||
Status.push(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Status.push(2);
|
||||
}
|
||||
mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]);
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity !== undefined) {
|
||||
entity.setDirtLevel(dirt);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (state === 0) {
|
||||
veh.setDoorShut(door, false);
|
||||
}
|
||||
else if (state === 1) {
|
||||
veh.setDoorOpen(door, false, false);
|
||||
}
|
||||
else {
|
||||
veh.setDoorBroken(door, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < args.length; y++) {
|
||||
if (args[y] === 0) {
|
||||
args[0].setDoorShut(y - 1, false);
|
||||
}
|
||||
else if (args[y] === 1) {
|
||||
args[0].setDoorOpen(y - 1, false, false);
|
||||
}
|
||||
else {
|
||||
args[0].setDoorBroken(y - 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (state === 1) {
|
||||
veh.rollDownWindow(windw);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.fixWindow(windw);
|
||||
veh.rollUpWindow(windw);
|
||||
}
|
||||
else {
|
||||
veh.smashWindow(windw);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < 4; y++) {
|
||||
if (args[y] === 1) {
|
||||
args[0].rollDownWindow(y - 1);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].fixWindow(y - 1);
|
||||
args[0].rollUpWindow(y - 1);
|
||||
}
|
||||
else {
|
||||
args[0].smashWindow(y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => {
|
||||
if (veh === undefined || veh === null || !veh.isAVehicle()) return;
|
||||
if (veh !== undefined) {
|
||||
if (wheel === 9) {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(45, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(45);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(45, true, 1000);
|
||||
}
|
||||
}
|
||||
else if (wheel === 10) {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(47, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(47);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state === 1) {
|
||||
veh.setTyreBurst(wheel, false, 1000);
|
||||
}
|
||||
else if (state === 0) {
|
||||
veh.setTyreFixed(wheel);
|
||||
}
|
||||
else {
|
||||
veh.setTyreBurst(wheel, true, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => {
|
||||
if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) {
|
||||
let y = 0;
|
||||
for (y = 1; y < args.length; y++) {
|
||||
if (y === 9) {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(45, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(45);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(45, true, 1000);
|
||||
}
|
||||
}
|
||||
else if (y === 10) {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(47, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(47);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (args[y] === 1) {
|
||||
args[0].setTyreBurst(y - 1, false, 1000);
|
||||
}
|
||||
else if (args[y] === 0) {
|
||||
args[0].setTyreFixed(y - 1);
|
||||
}
|
||||
else {
|
||||
args[0].setTyreBurst(y - 1, true, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Sync data on stream in
|
||||
mp.events.add("entityStreamIn", (entity) => {
|
||||
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||
if (entity.type === "vehicle") {
|
||||
let typeor = typeof entity.getVariable('VehicleSyncData');
|
||||
let actualData = entity.getVariable('VehicleSyncData');
|
||||
|
||||
//Needed to stop vehicles from freaking out
|
||||
mp.game.streaming.requestCollisionAtCoord(entity.position.x, entity.position.y, entity.position.z);
|
||||
//mp.game.invoke('0x199640F55E0F7596', entity.position.x, entity.position.y, entity.position.z);
|
||||
entity.setLoadCollisionFlag(true);
|
||||
entity.trackVisibility();
|
||||
|
||||
if (typeor !== 'undefined' && entity.isSeatFree(-1)) //Only if there is no driver
|
||||
{
|
||||
entity.position = actualData.Position;
|
||||
entity.rotation = actualData.Rotation;
|
||||
}
|
||||
|
||||
//Set doors unbreakable for a moment
|
||||
let x = 0;
|
||||
for (x = 0; x < 8; x++) {
|
||||
entity.setDoorBreakable(x, false);
|
||||
}
|
||||
|
||||
//Do it anyway
|
||||
entity.setUndriveable(true);
|
||||
|
||||
if (typeor !== 'undefined') {
|
||||
entity.setEngineOn(actualData.Engine, true, false);
|
||||
entity.setUndriveable(true);
|
||||
|
||||
if (actualData.Locked)
|
||||
entity.setDoorsLocked(2);
|
||||
else
|
||||
entity.setDoorsLocked(1);
|
||||
|
||||
entity.setDirtLevel(actualData.Dirt);
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
if (actualData.Door[x] === 1)
|
||||
entity.setDoorOpen(x, false, false);
|
||||
else if (actualData.Door[x] === 0)
|
||||
entity.setDoorShut(x, true);
|
||||
else
|
||||
entity.setDoorBroken(x, true);
|
||||
}
|
||||
|
||||
for (x = 0; x < 4; x++) {
|
||||
if (actualData.Window[x] === 0) {
|
||||
entity.fixWindow(x);
|
||||
}
|
||||
else if (actualData.Window[x] === 1) {
|
||||
entity.rollDownWindow(x);
|
||||
}
|
||||
else {
|
||||
entity.smashWindow(x);
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < 8; x++) {
|
||||
if (actualData.Wheel[x] === 0) {
|
||||
entity.setTyreFixed(x);
|
||||
}
|
||||
else if (actualData.Wheel[x] === 1) {
|
||||
entity.setTyreBurst(x, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(x, true, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
//For trailer mid wheels
|
||||
if (actualData.Wheel[8] === 0) {
|
||||
entity.setTyreFixed(45);
|
||||
}
|
||||
else if (actualData.Wheel[8] === 1) {
|
||||
entity.setTyreBurst(45, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(45, true, 1000);
|
||||
}
|
||||
|
||||
if (actualData.Wheel[9] === 0) {
|
||||
entity.setTyreFixed(47);
|
||||
}
|
||||
else if (actualData.Wheel[9] === 1) {
|
||||
entity.setTyreBurst(47, false, 0);
|
||||
}
|
||||
else {
|
||||
entity.setTyreBurst(47, true, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
//Make doors breakable again
|
||||
setTimeout(() => {
|
||||
for (x = 0; x < 8; x++) {
|
||||
entity.setDoorBreakable(x, true);
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
mode: 'production',
|
||||
entry: './index.ts',
|
||||
output: {
|
||||
path: path.resolve(__dirname),
|
||||
path: path.resolve(__dirname, '..', '..', 'client_packages'),
|
||||
filename: 'index.js'
|
||||
},
|
||||
module: {
|
||||
@@ -15,7 +15,12 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: { loader: 'ts-loader' }
|
||||
use: {
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
allowTsInNodeModules: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -57,22 +57,23 @@ namespace ReallifeGamemode.Server.Events
|
||||
var userItems = loginUser.UserItems.ToList().FindAll(u => u.UserId == user.Id);
|
||||
player.SetData("items", userItems);
|
||||
|
||||
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);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
}
|
||||
//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);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
//}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
|
||||
@@ -45,11 +45,14 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("isLoggedIn", true);
|
||||
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");
|
||||
//var currentPlayerCreatorDimension = (uint) NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
//currentPlayerCreatorDimension++;
|
||||
//NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
//player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
//player.TriggerEvent("toggleCreator");
|
||||
|
||||
player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
|
||||
}
|
||||
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user