Changed whole project structure (split client and server into separat projects)
This commit is contained in:
108
ReallifeGamemode.Client/Player/dutycloth.js
Normal file
108
ReallifeGamemode.Client/Player/dutycloth.js
Normal file
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @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");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
132
ReallifeGamemode.Client/Player/freecam.js
Normal file
132
ReallifeGamemode.Client/Player/freecam.js
Normal file
@@ -0,0 +1,132 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
138
ReallifeGamemode.Client/Player/keys.js
Normal file
138
ReallifeGamemode.Client/Player/keys.js
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @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 anderen Spielern)
|
||||
mp.keys.bind(0x26, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:UP_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//RIGHT ARROW (Interaktion mit anderen Spielern)
|
||||
mp.keys.bind(0x27, false, function () {
|
||||
if (!globalData.InChat && !showInv && !globalData.Interaction) {
|
||||
mp.events.callRemote("keyPress:RIGHT_ARROW");
|
||||
}
|
||||
});
|
||||
|
||||
//DOWN ARROW (Interaktion mit anderen Spielern)
|
||||
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) {
|
||||
mp.events.call("sortFactionTasks");
|
||||
}
|
||||
});
|
||||
|
||||
//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");
|
||||
}
|
||||
});
|
||||
|
||||
9
ReallifeGamemode.Client/Player/quit.js
Normal file
9
ReallifeGamemode.Client/Player/quit.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @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);
|
||||
});
|
||||
Reference in New Issue
Block a user