Merging into feature/inventory-system

This commit is contained in:
VegaZ
2018-12-08 23:17:28 +01:00
35 changed files with 848 additions and 168 deletions

View File

@@ -15,7 +15,6 @@ var inventoryWeight;
var items = [[]];
var grid = [];
grid[0] = [0.3375, 0.305]
grid[1] = [0.4195, 0.305]
grid[2] = [0.5015, 0.305]
@@ -65,20 +64,6 @@ mp.events.add("showInventory", (invWeight, itemArr) => {
mp.events.add("render", () => {
if (show === true) {
var pos = mp.gui.cursor.position;
//DEBUG 2D-SCREEN-KOORDINATEN
//mp.game.graphics.drawText("~r~X: " + pos[0] + " ~g~Y: " + pos[1] + "~s~ ---~b~" + parseFloat(pos[0] / screenX).toFixed(3) + " ~y~" + parseFloat(pos[1] / screenY).toFixed(3) + " " + mouseLDown, [pos[0] / screenX, (pos[1] / screenY) - 0.02], {
// font: 0,
// color: [255, 255, 255, 185],
// scale: [0.3, 0.3],
// outline: true,
//});
//mp.game.graphics.drawText("~r~drag: " + dragItem + "~s~... ~b~hover:" + hoverItem + "~y~....FREESLOT: " + isMouseOverFreeSlot(pos[0], pos[1]) + "..." + isItemOverSameItem(pos[0], pos[1]), [0.5, 0.02], {
// font: 0,
// color: [255, 255, 255, 185],
// scale: [0.3, 0.3],
// outline: true,
//});
mp.game.graphics.set2dLayer(1);
//INVENTARHINTERGRUND
@@ -339,10 +324,4 @@ mp.events.add('click', (x, y, upOrDown, leftOrRight, relativeX, relativeY, world
}
}
}
});
//items[userItems.IndexOf(item)][0] = iItem.Name;
//items[userItems.IndexOf(item)][1] = iItem.Description;
//items[userItems.IndexOf(item)][2] = iItem.Gewicht.ToString();
//items[userItems.IndexOf(item)][3] = item.Amount.ToString();
//items[userItems.IndexOf(item)][4] = item.Slot.ToString();
});

View File

@@ -49,14 +49,7 @@ mp.events.add("respawnDeathPlayer", () => {
});
mp.events.add("updateDutyMedics", (count) => {
if (count === true)
{
dutyMedics++;
}
else
{
dutyMedics--;
}
dutyMedics = count;
});
@@ -68,7 +61,13 @@ mp.events.add("render", () => {
var medicString;
if (dutyMedics > 0) {
medicString = "Derzeit sind ~g~" + dutyMedics + " Medics ~s~im Dienst ~c~und versuchen dich wiederzubeleben...";
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.";
}
@@ -76,6 +75,7 @@ mp.events.add("render", () => {
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],
{
@@ -91,6 +91,7 @@ mp.events.add("render", () => {
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 {

View File

@@ -69,7 +69,7 @@ mp.events.add("toggleUi", (show) => {
//}
mp.events.add("updateMoney", (money) => {
playerMoney = money;
playerMoney = money.toLocaleString("de-DE", { minimumFractionDigits: 0 });
});
mp.events.add("render", () => {

124
Client/Player/freecam.js Normal file
View File

@@ -0,0 +1,124 @@
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();
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);
}
}
});

View File

@@ -6,28 +6,36 @@
var keyBound = false;
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 25, 27, 28, 30, 33, 34, 35, 38, 46, 48];
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, 46, 48];
var carModSlotName = [
{ Slot: 0, Name: "Spoiler" }, // 0
{ Slot: 1, Name: "Frontstoßstange"}, // 1
{ Slot: 2, Name: "Heckstoßstange"}, // 2
{ Slot: 3, Name: "Seitenschweller"}, // 3
{ Slot: 4, Name: "Auspuff"}, // 4
{ Slot: 5, Name: "Rahmen"}, // 5
{ Slot: 6, Name: "Kühlergrill"}, // 6
{ Slot: 7, Name: "Motorhaube"}, // 7
{ Slot: 8, Name: "Linker Kotflügel"}, // 8
{ Slot: 9, Name: "Rechter Kotflügel"}, // 9
{ Slot: 10, Name: "Dach"}, // 10
{ Slot: 11, Name: "Motor" }, // 11
{ Slot: 12, Name: "Bremsen"}, // 12
{ Slot: 13, Name: "Getriebe"}, // 13
{ Slot: 14, Name: "Hupe"}, // 14
{ Slot: 15, Name: "Federung"}, // 15
{ Slot: 18, Name: "Turbo"}, // 18
{ Slot: 22, Name: "Licht"}, // 22
{ Slot: 23, Name: "Reifen"} // 23
{ 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: 48, Name: "Design" }
];
var customPartNames = [
@@ -40,15 +48,6 @@ var customPartNames = [
}
]
},
{
Model: 159274291,
Names: [
{
Slot: 8,
Name: "Kotflügel"
}
]
},
{
Model: 223240013,
Names: [
@@ -66,6 +65,27 @@ var customPartNames = [
Name: "Stoßdämpfer"
}
]
},
{
Model: 3308022675,
Names: [
{
Slot: 9,
Name: "Kotflügel"
}
]
}
];
var doorOpeners = [
{
Model: 3308022675,
Doors: [
{
Slot: 5,
Door: 4
}
]
}
];
@@ -74,16 +94,12 @@ var bikeModTypes = [];
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;
var mainMenu;
var modMenu;
var closeMenu = false;
mp.events.add('showTuningInfo', () => {
mp.game.ui.setTextComponentFormat('STRING');
@@ -99,7 +115,13 @@ mp.events.add('hideTuningInfo', (unbind) => {
mp.gui.chat.show(true);
if (typeof mainMenu !== "undefined" && unbind) {
mainMenu.Visible = false;
mainMenu.Close();
globalData.InTuning = false;
}
if (typeof modMenu !== "undefined" && modMenu.Visible && unbind) {
closeMenu = true;
modMenu.Close();
globalData.InTuning = false;
}
@@ -124,9 +146,40 @@ mp.events.add("showTuningMenu", () => {
return;
}
if (typeof modMenu !== "undefined" && modMenu.Visible) {
return;
}
globalData.InTuning = true;
mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50));
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") {
@@ -145,7 +198,7 @@ mp.events.add("showTuningMenu", () => {
}
});
mainMenu.Visible = true;
mainMenu.Open();
mainMenu.ItemSelect.on((item) => {
var modSlot = getSlotId(item.Text);
@@ -154,12 +207,21 @@ mp.events.add("showTuningMenu", () => {
modSlot = parseInt(restStr);
}
if (modSlot === 38) {
localVehicle.setDoorOpen(5, false, false);
}
var door = getDoor(localVehicle.model, modSlot);
if (door !== undefined) {
localVehicle.setDoorOpen(door, false, false);
}
var currentMod = localVehicle.getMod(modSlot);
var currentModItem;
var modNum = localVehicle.getNumMods(modSlot);
var modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
for (var i = -1; i < modNum; i++) {
var modItem;
@@ -167,9 +229,8 @@ mp.events.add("showTuningMenu", () => {
if (i === -1) {
modItem = new UIMenuItem("Serie", "");
} else {
var modName = localVehicle.getModTextLabel(modSlot, i);
var realModName = mp.game.ui.getLabelText(modName);
modItem = new UIMenuItem(realModName, "");
var modName = getModName(localVehicle, modSlot, i);
modItem = new UIMenuItem(modName, "");
}
if (i === currentMod) {
@@ -200,7 +261,21 @@ mp.events.add("showTuningMenu", () => {
});
modMenu.MenuClose.on(() => {
if (modSlot === 38) {
localVehicle.setDoorShut(5, false);
}
if (door !== undefined) {
localVehicle.setDoorShut(door, false);
}
localVehicle.setMod(modSlot, currentMod);
if (closeMenu) {
closeMenu = false;
return;
}
mainMenu.Visible = true;
modMenu.Visible = false;
});
@@ -277,4 +352,81 @@ function getCustomId(model, name) {
});
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;
}
}
return realModName;
}

4
Client/Tuning/sync.js Normal file
View File

@@ -0,0 +1,4 @@
mp.events.add('entityStreamIn', (entity) => {
mp.gui.chat.push("streamed in:");
mp.gui.chat.push(entity.Model);
});

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dba019dfe6643a9825df882fe92ac77605a85feffcff226d70ce5351f12b8180
size 24064

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4583d08eb98355d8640aac132b305e16504c9886fbd319aa44f10c3b7b099987
size 13824

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b0c2b1815e1add21f0cae50c575fe2232dc5e875321462bd092a5e0957303e9
size 41567232

View File

@@ -9,6 +9,8 @@ let globalData = {
HideGui: false
};
mp.game.gameplay.enableMpDlcMaps(true);
require('./CharCreator/index.js');
require('./FactionManagement/main.js');
@@ -25,11 +27,14 @@ require('./Login/main.js');
require('./Player/dutycloth.js');
require('./Player/keys.js');
require('./Player/quit.js');
require('./Player/freecam.js');
require('./Save/main.js');
require('./Speedometer/index.js');
require('./Tuning/main.js');
require('./Tuning/sync.js');
require('./Business/main.js');