Merge branch 'feature/tuning-system' into develop
This commit is contained in:
9
Client/Player/quit.js
Normal file
9
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);
|
||||||
|
});
|
||||||
139
Client/Tuning/main.js
Normal file
139
Client/Tuning/main.js
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Tuning tuning.js
|
||||||
|
* @author hydrant
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
var keyBound = false;
|
||||||
|
|
||||||
|
var carModTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 22, 23];
|
||||||
|
var modSlotName = [
|
||||||
|
{ 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
|
||||||
|
];
|
||||||
|
|
||||||
|
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('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', () => {
|
||||||
|
mp.game.ui.clearHelp(true);
|
||||||
|
mp.gui.chat.show(true);
|
||||||
|
|
||||||
|
if (keyBound) {
|
||||||
|
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||||
|
keyBound = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function keyPressHandler() {
|
||||||
|
mp.events.callRemote("startPlayerTuning");
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.events.add("showTuningMenu", () => {
|
||||||
|
mp.events.call("hideTuningInfo");
|
||||||
|
mp.gui.chat.show(false);
|
||||||
|
|
||||||
|
var localPlayer = mp.players.local;
|
||||||
|
var localVehicle = localPlayer.vehicle;
|
||||||
|
|
||||||
|
var mainMenu = new Menu("Fahrzeugwerkstatt", "Modifiziere dein Fahrzeug", new Point(50, 50));
|
||||||
|
|
||||||
|
carModTypes.forEach((modType) => {
|
||||||
|
if (localVehicle.getModSlotName(modType) !== "undefined") {
|
||||||
|
var slotName = getSlotName(modType);
|
||||||
|
|
||||||
|
var menuItem = new UIMenuItem(slotName);
|
||||||
|
menuItem.ModSlot = modType;
|
||||||
|
|
||||||
|
mainMenu.AddItem(menuItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mainMenu.Visible = true;
|
||||||
|
|
||||||
|
mainMenu.ItemSelect.on(item => {
|
||||||
|
var modSlot = getSlotId(item.Text);
|
||||||
|
|
||||||
|
var modNum = localVehicle.getNumMods(modSlot);
|
||||||
|
|
||||||
|
var modMenu = new Menu(item.Text, "Änderung: " + item.Text, new Point(50, 50));
|
||||||
|
|
||||||
|
modMenu.AddItem(new UIMenuItem("Serie", ""));
|
||||||
|
|
||||||
|
for (var i = 0; i < modNum; i++) {
|
||||||
|
var modName = localVehicle.getModTextLabel(modSlot, i);
|
||||||
|
var realModName = mp.game.ui.getLabelText(modName)
|
||||||
|
var modItem = new UIMenuItem(realModName, "");
|
||||||
|
|
||||||
|
modMenu.AddItem(modItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
modMenu.IndexChange.on(index => {
|
||||||
|
mp.events.callRemote("setVehicleMod", modSlot, index);
|
||||||
|
});
|
||||||
|
|
||||||
|
modMenu.MenuClose.on(() => {
|
||||||
|
mainMenu.Visible = true;
|
||||||
|
modMenu.Visible = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
mainMenu.Visible = false;
|
||||||
|
modMenu.Visible = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function getSlotName(slot) {
|
||||||
|
var toReturn = "undefined";
|
||||||
|
|
||||||
|
modSlotName.forEach((name) => {
|
||||||
|
if (name.Slot === slot) toReturn = name.Name;
|
||||||
|
});
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSlotId(slotName) {
|
||||||
|
var toReturn = "undefined";
|
||||||
|
|
||||||
|
modSlotName.forEach((name) => {
|
||||||
|
if (name.Name === slotName) toReturn = name.Slot;
|
||||||
|
});
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
@@ -17,3 +17,4 @@ require('./Player/keys.js');
|
|||||||
|
|
||||||
require('./FactionManagement/main.js');
|
require('./FactionManagement/main.js');
|
||||||
|
|
||||||
|
require('./Tuning/main.js');
|
||||||
1
Client/nativeui/index.js
Normal file
1
Client/nativeui/index.js
Normal file
File diff suppressed because one or more lines are too long
6
Main.cs
6
Main.cs
@@ -4,6 +4,7 @@ using GTANetworkAPI;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using reallife_gamemode.Model;
|
using reallife_gamemode.Model;
|
||||||
using reallife_gamemode.Server.Entities;
|
using reallife_gamemode.Server.Entities;
|
||||||
|
using reallife_gamemode.Server.Managers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Main Class (Main.cs)
|
* @overview Life of German Reallife - Main Class (Main.cs)
|
||||||
@@ -26,6 +27,8 @@ namespace reallife_gamemode
|
|||||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
|
|
||||||
|
TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5), new Vector3(-334, -143, 41));
|
||||||
|
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
context.Bans.FirstOrDefault();
|
context.Bans.FirstOrDefault();
|
||||||
@@ -35,5 +38,8 @@ namespace reallife_gamemode
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("dim")]
|
||||||
|
public void dim(Client player) => player.SendChatMessage(player.Dimension.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
54
Server/Managers/TuningManager.cs
Normal file
54
Server/Managers/TuningManager.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Server.Util;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Managers
|
||||||
|
{
|
||||||
|
class TuningManager : Script
|
||||||
|
{
|
||||||
|
private static List<ColShape> tuningGarages = new List<ColShape>();
|
||||||
|
|
||||||
|
public static void AddTuningGarage(Vector3 pos1, Vector3 pos2)
|
||||||
|
{
|
||||||
|
// DEBUG
|
||||||
|
|
||||||
|
NAPI.TextLabel.CreateTextLabel("Pos1", pos1, 100, 1, 0, new Color(255, 255, 255), true, 0);
|
||||||
|
NAPI.TextLabel.CreateTextLabel("Pos2", pos2, 100, 1, 0, new Color(255, 255, 255), true, 0);
|
||||||
|
|
||||||
|
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos1, 10, 0);
|
||||||
|
|
||||||
|
colShape.OnEntityEnterColShape += (cs, c) =>
|
||||||
|
{
|
||||||
|
if(c.IsInVehicle)
|
||||||
|
{
|
||||||
|
c.TriggerEvent("showTuningInfo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
colShape.OnEntityExitColShape += (cs, c) =>
|
||||||
|
{
|
||||||
|
c.TriggerEvent("hideTuningInfo");
|
||||||
|
};
|
||||||
|
|
||||||
|
tuningGarages.Add(colShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("startPlayerTuning")]
|
||||||
|
public void StartPlayerTuning(Client player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle) return;
|
||||||
|
|
||||||
|
player.TriggerEvent("showTuningMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("setVehicleMod")]
|
||||||
|
public void SetVehicleMod(Client player, int slot, int index)
|
||||||
|
{
|
||||||
|
if (index == 0) index--;
|
||||||
|
player.Vehicle.SetMod(slot, index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user