Merged group system into develop
This commit is contained in:
@@ -14,9 +14,9 @@ import moneyFormat from '../moneyformat';
|
||||
|
||||
export default function carDealer() {
|
||||
|
||||
var shopMenu;
|
||||
var shopMenu: NativeUI.Menu;
|
||||
|
||||
mp.events.add('ShopVehicle_OpenMenu', (businessName, price) => {
|
||||
mp.events.add('ShopVehicle_OpenMenu', (businessName, price, availableOptions: string[]) => {
|
||||
var veh = mp.players.local.vehicle;
|
||||
if (!veh) return;
|
||||
mp.gui.chat.show(false);
|
||||
@@ -34,6 +34,10 @@ export default function carDealer() {
|
||||
priceItem.SetRightLabel("~g~$~s~ " + moneyFormat(price));
|
||||
shopMenu.AddItem(priceItem);
|
||||
|
||||
var targetsCollection = new ItemsCollection(availableOptions);
|
||||
var targetItem = new UIMenuListItem("Kaufen f<>r", "W<>hle den Besitzer aus", targetsCollection);
|
||||
shopMenu.AddItem(targetItem);
|
||||
|
||||
var saveItem = new UIMenuItem("Kaufen");
|
||||
saveItem.BackColor = new Color(0, 100, 0);
|
||||
saveItem.HighlightedBackColor = new Color(0, 150, 0);
|
||||
@@ -48,7 +52,7 @@ export default function carDealer() {
|
||||
if (item === cancelItem) {
|
||||
shopMenu.Close();
|
||||
} else if (item === saveItem) {
|
||||
mp.events.callRemote("VehShop_BuyVehicle");
|
||||
mp.events.callRemote("VehShop_BuyVehicle", targetItem.SelectedValue);
|
||||
shopMenu.Close();
|
||||
}
|
||||
});
|
||||
|
||||
70
ReallifeGamemode.Client/Gui/cityhall.ts
Normal file
70
ReallifeGamemode.Client/Gui/cityhall.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
|
||||
import InputHelper from '../inputhelper';
|
||||
|
||||
export default function (globalData: GlobalData) {
|
||||
|
||||
var keyBound = false;
|
||||
var menu: NativeUI.Menu = null;
|
||||
|
||||
mp.events.add("SERVER:CityHall_ShowHelpText", () => {
|
||||
mp.game.ui.setTextComponentFormat('STRING');
|
||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um das Stadthallen-Menü zu öffnen');
|
||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||
|
||||
if (!keyBound) {
|
||||
keyBound = true;
|
||||
mp.keys.bind(0x45, false, keyPressHandler);
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:CityHall_ClearHelpText", () => {
|
||||
mp.game.ui.clearHelp(false);
|
||||
if (keyBound) {
|
||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
||||
keyBound = false;
|
||||
}
|
||||
});
|
||||
|
||||
function keyPressHandler(): void {
|
||||
if (globalData.InChat || globalData.Interaction) return;
|
||||
menu = new Menu("Stadthalle", "", new Point(50, 50), null, null);
|
||||
|
||||
globalData.Interaction = true;
|
||||
mp.gui.chat.show(false);
|
||||
|
||||
var groupCreateItem = new UIMenuItem("Gruppe erstellen", "Erstelle eine neue Gruppe");
|
||||
groupCreateItem.SetRightLabel("~g~50.000$");
|
||||
menu.AddItem(groupCreateItem);
|
||||
|
||||
var cancelItem = new UIMenuItem("Schließen");
|
||||
cancelItem.BackColor = new Color(213, 0, 0);
|
||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||
menu.AddItem(cancelItem);
|
||||
|
||||
menu.ItemSelect.on((item, index) => {
|
||||
if (index === 0) { // Gruppe
|
||||
var input = new InputHelper("Wie soll die Gruppe heißen?");
|
||||
input.show();
|
||||
input.getValue((name: string) => {
|
||||
mp.events.callRemote("CLIENT:CityHall_CreateGroup", name);
|
||||
});
|
||||
}
|
||||
menu.Close();
|
||||
});
|
||||
|
||||
menu.MenuClose.on(() => {
|
||||
globalData.Interaction = false;
|
||||
mp.gui.chat.show(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
133
ReallifeGamemode.Client/Interaction/interactionmenu.ts
Normal file
133
ReallifeGamemode.Client/Interaction/interactionmenu.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
import * as NativeUI from 'NativeUI';
|
||||
import InputHelper from '../inputhelper';
|
||||
|
||||
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 (globalData: GlobalData) {
|
||||
|
||||
var menuClose = false;
|
||||
|
||||
var accountItem = new UIMenuItem("Account", "Account Informationen");
|
||||
|
||||
var factionItem = new UIMenuItem("Fraktion", "Verwalte deine Fraktion");
|
||||
var groupItem = new UIMenuItem("Gruppe", "Verwalte deine Gruppe");
|
||||
|
||||
|
||||
mp.events.add("SERVER:InteractionMenu_OpenMenu", (accountDataJson: string, faction: string, group: string, factionInvite: boolean, groupInvite: boolean) => {
|
||||
var accountData: AccountData = JSON.parse(accountDataJson);
|
||||
|
||||
var menu = getInteractionMenu();
|
||||
|
||||
menu.AddItem(accountItem);
|
||||
menu.BindMenuToItem(getAccountMenu(accountData), accountItem);
|
||||
|
||||
if (faction) {
|
||||
factionItem.SetRightLabel(faction);
|
||||
menu.AddItem(factionItem);
|
||||
menu.BindMenuToItem(getFactionMenu(faction, menu), factionItem);
|
||||
}
|
||||
|
||||
if (group) {
|
||||
groupItem.SetRightLabel(group);
|
||||
menu.AddItem(groupItem);
|
||||
menu.BindMenuToItem(getGroupMenu(group), groupItem);
|
||||
}
|
||||
|
||||
var items: Array<string> = new Array<string>();
|
||||
if (factionInvite) items.push("Fraktion");
|
||||
if (groupInvite) items.push("Gruppe");
|
||||
var acceptItem: NativeUI.UIMenuListItem;
|
||||
|
||||
if (items.length !== 0) {
|
||||
acceptItem = new UIMenuListItem("Einladung annehmen", "", new ItemsCollection(items));
|
||||
menu.AddItem(acceptItem);
|
||||
}
|
||||
|
||||
menu.Visible = true;
|
||||
mp.gui.chat.show(false);
|
||||
globalData.Interaction = true;
|
||||
|
||||
menu.ItemSelect.on((item, index) => {
|
||||
if (item === acceptItem) {
|
||||
mp.events.callRemote("CLIENT:InteractionMenu_AcceptInvite", acceptItem.SelectedValue);
|
||||
}
|
||||
});
|
||||
|
||||
menu.MenuClose.on(() => {
|
||||
globalData.Interaction = false;
|
||||
mp.gui.chat.show(true);
|
||||
})
|
||||
});
|
||||
|
||||
function getInteractionMenu(): NativeUI.Menu {
|
||||
return new Menu("Hauptmenü", "Interaktionen | " + mp.players.local.name, new Point(50, 50), null, null);
|
||||
}
|
||||
|
||||
function getAccountMenu(data: AccountData): NativeUI.Menu {
|
||||
var accountMenu = new NativeUI.Menu("Account", mp.players.local.name, new Point(50, 50), null, null);
|
||||
|
||||
var menuItem = new UIMenuItem("Fraktion");
|
||||
menuItem.SetRightLabel(data.faction);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
menuItem = new UIMenuItem("Fraktionsrang");
|
||||
menuItem.SetRightLabel(data.factionRank);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
menuItem = new UIMenuItem("Gruppe");
|
||||
menuItem.SetRightLabel(data.group);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
menuItem = new UIMenuItem("Gruppenrang");
|
||||
menuItem.SetRightLabel(data.groupRank);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
menuItem = new UIMenuItem("Registrierungsdatum");
|
||||
menuItem.SetRightLabel(data.regDate);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
menuItem = new UIMenuItem("Adminrang");
|
||||
menuItem.SetRightLabel(data.adminLevel);
|
||||
accountMenu.AddItem(menuItem);
|
||||
|
||||
accountMenu.Visible = false;
|
||||
return accountMenu;
|
||||
}
|
||||
|
||||
function getFactionMenu(faction: string, parentMenu: NativeUI.Menu): NativeUI.Menu {
|
||||
var factionMenu = new NativeUI.Menu("Fraktion", faction, new Point(50, 50), null, null);
|
||||
factionMenu.AddItem(new UIMenuItem("Spieler einladen"));
|
||||
factionMenu.AddItem(new UIMenuItem("Spieler rauswerfen"));
|
||||
factionMenu.Visible = false;
|
||||
|
||||
factionMenu.ItemSelect.on((item, index) => {
|
||||
if (index === 0) { // Inviten
|
||||
var input = new InputHelper("Welchen Spieler möchtest du inviten (Name / ID)?");
|
||||
input.show();
|
||||
input.getValue(name => {
|
||||
mp.events.callRemote("CLIENT:InteractionMenu_InviteFaction", name);
|
||||
parentMenu.Close();
|
||||
});
|
||||
} else if (index === 1) { // Uninviten
|
||||
}
|
||||
})
|
||||
|
||||
return factionMenu;
|
||||
}
|
||||
|
||||
function getGroupMenu(group: string): NativeUI.Menu {
|
||||
var groupMenu = new NativeUI.Menu("Gruppe", group, new Point(50, 50), null, null);
|
||||
groupMenu.AddItem(new UIMenuItem("Spieler einladen"));
|
||||
groupMenu.AddItem(new UIMenuItem("Spieler rauswerfen"));
|
||||
groupMenu.Visible = false;
|
||||
|
||||
return groupMenu;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,131 @@
|
||||
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
|
||||
export default function () {
|
||||
var getNormalizedVector = function (vector) {
|
||||
var mag = Math.sqrt(
|
||||
vector.x * vector.x + vector.y * vector.y + vector.z * vector.z
|
||||
);
|
||||
vector.x = vector.x / mag;
|
||||
vector.y = vector.y / mag;
|
||||
vector.z = vector.z / mag;
|
||||
return vector;
|
||||
};
|
||||
|
||||
var global = {
|
||||
gameplayCam: undefined,
|
||||
fly: undefined
|
||||
var getCrossProduct = function (v1, v2) {
|
||||
var vector = new mp.Vector3(0, 0, 0);
|
||||
vector.x = v1.y * v2.z - v1.z * v2.y;
|
||||
vector.y = v1.z * v2.x - v1.x * v2.z;
|
||||
vector.z = v1.x * v2.y - v1.y * v2.x;
|
||||
return vector;
|
||||
};
|
||||
|
||||
global.fly = {
|
||||
flying: false, f: 2.0, w: 2.0, h: 2.0, point_distance: 1000, l:0
|
||||
var bindVirtualKeys = {
|
||||
F2: 0x71
|
||||
};
|
||||
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);
|
||||
}
|
||||
var bindASCIIKeys = {
|
||||
Q: 69,
|
||||
E: 81,
|
||||
LCtrl: 17,
|
||||
Shift: 16
|
||||
};
|
||||
mp.game.graphics.notify('~r~NoClip ~w~by ~b~Morbo');
|
||||
var isNoClip = false;
|
||||
var noClipCamera;
|
||||
var shiftModifier = false;
|
||||
var controlModifier = false;
|
||||
var localPlayer = mp.players.local;
|
||||
mp.keys.bind(bindVirtualKeys.F2, true, function () {
|
||||
isNoClip = !isNoClip;
|
||||
mp.game.ui.displayRadar(!isNoClip);
|
||||
if (isNoClip) {
|
||||
startNoClip();
|
||||
} else {
|
||||
stopNoClip();
|
||||
}
|
||||
});
|
||||
function startNoClip() {
|
||||
mp.game.graphics.notify('NoClip ~g~activated');
|
||||
var camPos = new mp.Vector3(
|
||||
localPlayer.position.x,
|
||||
localPlayer.position.y,
|
||||
localPlayer.position.z
|
||||
);
|
||||
var camRot = mp.game.cam.getGameplayCamRot(2);
|
||||
noClipCamera = mp.cameras.new('default', camPos, camRot, 45);
|
||||
noClipCamera.setActive(true);
|
||||
mp.game.cam.renderScriptCams(true, false, 0, true, false);
|
||||
localPlayer.freezePosition(true);
|
||||
localPlayer.setInvincible(true);
|
||||
localPlayer.setVisible(false, false);
|
||||
localPlayer.setCollision(false, false);
|
||||
}
|
||||
function stopNoClip() {
|
||||
mp.game.graphics.notify('NoClip ~r~disabled');
|
||||
if (noClipCamera) {
|
||||
localPlayer.position = noClipCamera.getCoord();
|
||||
localPlayer.setHeading(noClipCamera.getRot(2).z);
|
||||
noClipCamera.destroy(true);
|
||||
noClipCamera = null;
|
||||
}
|
||||
mp.game.cam.renderScriptCams(false, false, 0, true, false);
|
||||
localPlayer.freezePosition(false);
|
||||
localPlayer.setInvincible(false);
|
||||
localPlayer.setVisible(true, false);
|
||||
localPlayer.setCollision(true, false);
|
||||
}
|
||||
mp.events.add('render', function () {
|
||||
if (!noClipCamera || mp.gui.cursor.visible) {
|
||||
return;
|
||||
}
|
||||
controlModifier = mp.keys.isDown(bindASCIIKeys.LCtrl);
|
||||
shiftModifier = mp.keys.isDown(bindASCIIKeys.Shift);
|
||||
var rot = noClipCamera.getRot(2);
|
||||
var fastMult = 1;
|
||||
var slowMult = 1;
|
||||
if (shiftModifier) {
|
||||
fastMult = 3;
|
||||
} else if (controlModifier) {
|
||||
slowMult = 0.5;
|
||||
}
|
||||
var rightAxisX = mp.game.controls.getDisabledControlNormal(0, 220);
|
||||
var rightAxisY = mp.game.controls.getDisabledControlNormal(0, 221);
|
||||
var leftAxisX = mp.game.controls.getDisabledControlNormal(0, 218);
|
||||
var leftAxisY = mp.game.controls.getDisabledControlNormal(0, 219);
|
||||
var pos = noClipCamera.getCoord();
|
||||
var rr = noClipCamera.getDirection();
|
||||
var vector = new mp.Vector3(0, 0, 0);
|
||||
vector.x = rr.x * leftAxisY * fastMult * slowMult;
|
||||
vector.y = rr.y * leftAxisY * fastMult * slowMult;
|
||||
vector.z = rr.z * leftAxisY * fastMult * slowMult;
|
||||
var upVector = new mp.Vector3(0, 0, 1);
|
||||
var rightVector = getCrossProduct(
|
||||
getNormalizedVector(rr),
|
||||
getNormalizedVector(upVector)
|
||||
);
|
||||
rightVector.x *= leftAxisX * 0.5;
|
||||
rightVector.y *= leftAxisX * 0.5;
|
||||
rightVector.z *= leftAxisX * 0.5;
|
||||
var upMovement = 0.0;
|
||||
if (mp.keys.isDown(bindASCIIKeys.Q)) {
|
||||
upMovement = 0.5;
|
||||
}
|
||||
var downMovement = 0.0;
|
||||
if (mp.keys.isDown(bindASCIIKeys.E)) {
|
||||
downMovement = 0.5;
|
||||
}
|
||||
mp.players.local.position = new mp.Vector3(
|
||||
pos.x + vector.x + 1,
|
||||
pos.y + vector.y + 1,
|
||||
pos.z + vector.z + 1
|
||||
);
|
||||
mp.players.local.heading = rr.z;
|
||||
noClipCamera.setCoord(
|
||||
pos.x - vector.x + rightVector.x,
|
||||
pos.y - vector.y + rightVector.y,
|
||||
pos.z - vector.z + rightVector.z + upMovement - downMovement
|
||||
);
|
||||
noClipCamera.setRot(
|
||||
rot.x + rightAxisY * -5.0,
|
||||
0.0,
|
||||
rot.z + rightAxisX * -5.0,
|
||||
2
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
9
ReallifeGamemode.Client/global.d.ts
vendored
9
ReallifeGamemode.Client/global.d.ts
vendored
@@ -6,6 +6,15 @@
|
||||
LoggedIn: boolean
|
||||
}
|
||||
|
||||
declare interface AccountData {
|
||||
regDate: string;
|
||||
adminLevel: string;
|
||||
faction: string;
|
||||
factionRank: string;
|
||||
group: string;
|
||||
groupRank: string;
|
||||
}
|
||||
|
||||
declare interface FactionRanks {
|
||||
factionId: number,
|
||||
ranks: FactionRank[]
|
||||
|
||||
@@ -12,6 +12,9 @@ let globalData: GlobalData = {
|
||||
LoggedIn: false
|
||||
};
|
||||
|
||||
import cityHall from './Gui/cityhall';
|
||||
cityHall(globalData);
|
||||
|
||||
import adminSpeed from './admin/aspeed';
|
||||
adminSpeed();
|
||||
|
||||
@@ -69,6 +72,9 @@ worldInteraction();
|
||||
import playerInteraction from './Interaction/playerinteraction';
|
||||
playerInteraction(globalData);
|
||||
|
||||
import interactionMenu from './Interaction/interactionmenu';
|
||||
interactionMenu(globalData);
|
||||
|
||||
import Login from './Login/main';
|
||||
Login(globalData);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export default class InputHelper {
|
||||
title: string;
|
||||
value: string;
|
||||
created: boolean;
|
||||
browser: BrowserMp;
|
||||
private title: string;
|
||||
private value: string;
|
||||
private created: boolean;
|
||||
private browser: BrowserMp;
|
||||
|
||||
constructor(title: string) {
|
||||
this.title = title;
|
||||
@@ -23,7 +23,7 @@
|
||||
mp.events.add('render', this.disableControls);
|
||||
}
|
||||
|
||||
disableControls() {
|
||||
private disableControls() {
|
||||
for (var i = 0; i <= 33; i++) {
|
||||
mp.game.controls.disableAllControlActions(i);
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
this.browser = mp.browsers.new('package://assets/html/inputhelper/index.html');
|
||||
}
|
||||
|
||||
finish() {
|
||||
private finish() {
|
||||
if (this.browser) {
|
||||
mp.events.remove('cef_inputhelper_sendvalue');
|
||||
mp.events.remove('cef_request_title');
|
||||
@@ -45,16 +45,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
cefTitleCall() {
|
||||
private cefTitleCall() {
|
||||
this.browser.execute(`setTitle('${this.title}')`);
|
||||
}
|
||||
|
||||
cefCallback(val) {
|
||||
private cefCallback(val) {
|
||||
this.value = val;
|
||||
this.finish();
|
||||
}
|
||||
|
||||
valueGetter() {
|
||||
private valueGetter(): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
setInterval(() => {
|
||||
if (this.value !== undefined) resolve(this.value);
|
||||
|
||||
33
ReallifeGamemode.Client/package-lock.json
generated
33
ReallifeGamemode.Client/package-lock.json
generated
@@ -349,8 +349,9 @@
|
||||
"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"
|
||||
"version": "https://github.com/sprayzcs/RageMP-NativeUI/tarball/master",
|
||||
"integrity": "sha512-iG7Cym2lnzuiwNBY6ATvSoaQ5Pfs4p8hW0s2EYL7MhPYrCpVhr/5zZOvQHijTV4gv5bipPtnuT0c1k4pkrlFZA==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.1.1",
|
||||
@@ -1565,13 +1566,11 @@
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -1584,18 +1583,15 @@
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -1698,8 +1694,7 @@
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -1709,7 +1704,6 @@
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -1722,20 +1716,17 @@
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@@ -1752,7 +1743,6 @@
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@@ -1825,8 +1815,7 @@
|
||||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
"bundled": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -1836,7 +1825,6 @@
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -1942,7 +1930,6 @@
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"@types/ragemp-c": "git+https://github.com/sprayzcs/types-ragemp-c.git#master",
|
||||
"NativeUI": "https://github.com/sprayzcs/RageMP-NativeUI/tarball/master",
|
||||
"copy-webpack-plugin": "^5.0.1",
|
||||
"uglifyjs-webpack-plugin": "^2.1.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"uglifyjs-webpack-plugin": "^2.1.2",
|
||||
"@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",
|
||||
@@ -19,5 +17,10 @@
|
||||
"scripts": {
|
||||
"watch": "webpack --watch --config webpack.config.development.js",
|
||||
"build:server": "webpack --config webpack.config.build.js"
|
||||
},
|
||||
"-vs-binding": {
|
||||
"ProjectOpened": [
|
||||
"watch"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Business
|
||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
|
||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||
{
|
||||
BusinessId = Id,
|
||||
@@ -81,7 +81,7 @@ namespace ReallifeGamemode.Server.Business
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if(dbContext == null)
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
IItem iItem = InventoryManager.GetItemByName(item);
|
||||
|
||||
if(iItem == null)
|
||||
if (iItem == null)
|
||||
{
|
||||
player.SendChatMessage("Dieses Essen existiert nicht.");
|
||||
return;
|
||||
@@ -46,15 +46,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
List<UserItem> itemList = player.GetUser().GetItems();
|
||||
UserItem eatItem = itemList.FirstOrDefault(i => i.ItemId == iItem.Id);
|
||||
|
||||
if(eatItem == null)
|
||||
if (eatItem == null)
|
||||
{
|
||||
player.SendChatMessage("Du hast dieses Item nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
if(iItem is IUsableItem usableItemObj)
|
||||
if (iItem is IUsableItem usableItemObj)
|
||||
{
|
||||
usableItemObj.Use(eatItem);
|
||||
usableItemObj.Use(eatItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (receiverUser == null)
|
||||
{
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht.");
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -227,9 +227,9 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (target == player)
|
||||
if (target == player)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst dir nicht selber zuflüstern.");
|
||||
ChatService.Error(player, "Du kannst dir nicht selber zuflüstern");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
var gotoString = "";
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (GotoPoint point in dbContext.GotoPoints)
|
||||
{
|
||||
@@ -610,20 +610,20 @@ namespace ReallifeGamemode.Server.Commands
|
||||
user = dbContext.Users.FirstOrDefault(u => u.Name == userName);
|
||||
if (user == null)
|
||||
{
|
||||
ChatService.Error(admin, "Dieser Spieler existiert nicht.");
|
||||
ChatService.Error(admin, "Dieser Spieler existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.BanId == null)
|
||||
{
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt.");
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt");
|
||||
return;
|
||||
}
|
||||
|
||||
Ban ban = dbContext.Bans.FirstOrDefault(b => b.Id == user.BanId);
|
||||
if (ban == null)
|
||||
{
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt.");
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
int currentTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
if (ban.UntilDateTime < currentTimestamp)
|
||||
{
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt.");
|
||||
ChatService.Error(admin, "Dieser Spieler ist nicht gebannt");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -659,9 +659,9 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location);
|
||||
|
||||
if(p == null)
|
||||
if (p == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht.");
|
||||
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
if (target == player)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst dich nicht selber spectaten.");
|
||||
ChatService.Error(player, "Du kannst dich nicht selber spectaten");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -757,9 +757,9 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
|
||||
Vehicle v = VehicleManager.GetVehicleFromId(vehid);
|
||||
if(v == null)
|
||||
if (v == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -778,7 +778,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
Vehicle v = VehicleManager.GetVehicleFromId(vehid);
|
||||
if (v == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -864,7 +864,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
public void CmdAdminVeh(Client player, string hash, int color1 = 111, int color2 = 111)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? true)
|
||||
//TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3.
|
||||
//TODO: Bestimmte Autos nur ab Adminlevel 1337, "normale Fahrzeuge" schon ab Adminlevel 3.
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -872,16 +872,16 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (player.IsInVehicle) // Man darf keine Autos erstellen, wenn man selbst in einem sitzt (verhindert Bugs)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan schon in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan schon in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!uint.TryParse(hash, out uint uHash))
|
||||
if (!uint.TryParse(hash, out uint uHash))
|
||||
uHash = NAPI.Util.GetHashKey(hash);
|
||||
|
||||
if(!VehicleManager.IsValidHash(uHash))
|
||||
if (!VehicleManager.IsValidHash(uHash))
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
player.Vehicle.Repair();
|
||||
@@ -931,15 +931,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
else
|
||||
{
|
||||
targetVeh = VehicleManager.GetVehicleFromId(vid);
|
||||
if(targetVeh == null)
|
||||
if (targetVeh == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Fahrzeug existiert nicht");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ServerVehicle veh = VehicleManager.GetServerVehicleFromVehicle(targetVeh);
|
||||
if(veh != null)
|
||||
if (veh != null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug wird von einem Server-System benutzt: ~m~" + veh.GetType().Name);
|
||||
return;
|
||||
@@ -959,7 +959,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -979,7 +979,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan in keinem Fahrzeug!");
|
||||
ChatService.Error(player, "Du sitzt momentan in keinem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -999,7 +999,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (ammo <= 0)
|
||||
{
|
||||
ChatService.Error(player, "Es muss mindestens 1 Munition vergeben werden.");
|
||||
ChatService.Error(player, "Es muss mindestens 1 Munition vergeben werden");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (wHash == default)
|
||||
{
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht.");
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1040,7 +1040,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
if (target.Health != 0)
|
||||
{
|
||||
ChatService.Error(player, "Der Spieler ist nicht tot.");
|
||||
ChatService.Error(player, "Der Spieler ist nicht tot");
|
||||
return;
|
||||
}
|
||||
target.TriggerEvent("onPlayerRevived");
|
||||
@@ -1120,7 +1120,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
user.Handmoney += amount;
|
||||
context.SaveChanges();
|
||||
target.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Command("quicksavemode", "~m~Benutzung: ~s~/quicksavemode [Modus]: ~g~blip, ~g~atm")]
|
||||
@@ -1155,7 +1155,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<UserItem> userItems = context.UserItems.ToList().FindAll(i => i.UserId == target.GetUser().Id);
|
||||
foreach(var uItem in userItems)
|
||||
foreach (var uItem in userItems)
|
||||
{
|
||||
invWeight += uItem.Amount * InventoryManager.GetItemById(uItem.ItemId).Gewicht;
|
||||
}
|
||||
@@ -1169,7 +1169,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = itemId, UserId = target.GetUser().Id, Amount = amount };
|
||||
InventoryManager.AddItemToInventory(target, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Command("inventory", "~m~Benutzung: ~s~/inventory [Spieler]")]
|
||||
@@ -1192,7 +1192,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
InventoryManager.GetUserItemsAsAdmin(player, user);
|
||||
}
|
||||
|
||||
|
||||
[Command("editmode", "~m~Benutzung: ~s~/editmode")]
|
||||
public void CmdAdminToggleEditMode(Client player)
|
||||
{
|
||||
@@ -1201,8 +1201,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.GetData("editmode") == false)
|
||||
|
||||
if (player.GetData("editmode") == false)
|
||||
{
|
||||
player.SetData("editmode", true);
|
||||
player.SendNotification("Edit-Mode ~g~aktiviert");
|
||||
@@ -1250,7 +1250,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1268,7 +1268,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1288,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1409,7 +1409,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (wHash == default)
|
||||
{
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht.");
|
||||
ChatService.Error(player, "Diese Waffe existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1433,13 +1433,13 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if(hour > 23 || min > 59 || sec > 59)
|
||||
if (hour > 23 || min > 59 || sec > 59)
|
||||
{
|
||||
ChatService.Error(player, "Es wurde eine ungültige Zeit eingegeben.");
|
||||
ChatService.Error(player, "Es wurde eine ungültige Zeit eingegeben");
|
||||
return;
|
||||
}
|
||||
|
||||
if(hour == -1)
|
||||
if (hour == -1)
|
||||
{
|
||||
player.SendChatMessage("Es wird nun wieder die Echtzeit genutzt.");
|
||||
TimeManager.StartTimeManager();
|
||||
@@ -1475,7 +1475,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
Entities.Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == faction);
|
||||
if (f == null && faction != 0)
|
||||
{
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist).");
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1526,7 +1526,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
Entities.Faction f = dbContext.Factions.FirstOrDefault(x => x.Id == faction);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist).");
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1618,28 +1618,28 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case "svehicle":
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
if(option1 == null || option2 == null)
|
||||
if (option1 == null || option2 == null)
|
||||
{
|
||||
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
|
||||
if (!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
|
||||
{
|
||||
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
|
||||
return;
|
||||
}
|
||||
|
||||
BusinessBase business = BusinessManager.GetBusiness(businessId);
|
||||
if(business == null)
|
||||
if (business == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Business existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Business existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(business is CarDealerBusinessBase))
|
||||
if (!(business is CarDealerBusinessBase))
|
||||
{
|
||||
ChatService.Error(player, "Dieses Business ist kein Fahrzeug-Business.");
|
||||
ChatService.Error(player, "Dieses Business ist kein Fahrzeug-Business");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1666,23 +1666,23 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
switch(type.ToLower())
|
||||
switch (type.ToLower())
|
||||
{
|
||||
case "vehicle":
|
||||
if(!player.IsInVehicle)
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if(veh == null)
|
||||
if (veh == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Fahrzeug wird nicht von einem Server-System genutzt.");
|
||||
ChatService.Error(player, "Dieses Fahrzeug wird nicht von einem Server-System genutzt");
|
||||
return;
|
||||
}
|
||||
|
||||
if(option.ToLower() != "yes")
|
||||
if (option.ToLower() != "yes")
|
||||
{
|
||||
player.SendChatMessage("Bist du sicher, dass du folgendes Fahrzeug löschen willst: ~m~" + veh.ToString() + " ~s~?");
|
||||
player.SendChatMessage("Falls ~g~Ja~s~, nutze ~y~/remove vehicle yes");
|
||||
@@ -1699,7 +1699,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
break;
|
||||
|
||||
case "goto":
|
||||
if(option == "")
|
||||
if (option == "")
|
||||
{
|
||||
player.SendChatMessage("~m~Benutzung: ~s~/remove [Goto] [Punkt]");
|
||||
return;
|
||||
@@ -1712,9 +1712,9 @@ namespace ReallifeGamemode.Server.Commands
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option);
|
||||
if(p == null)
|
||||
if (p == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht.");
|
||||
ChatService.Error(player, "Dieser Goto-Punkt existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1953,7 +1953,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//
|
||||
[Command("managefactionranks", "~m~Benutzung: ~s~/managefactionranks [Fraktions-ID]")]
|
||||
public void CmdFactionManageFactionRanks(Client player, int factionID)
|
||||
@@ -1969,7 +1969,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(id => id.Id == factionID);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist).");
|
||||
ChatService.Error(player, "Diese Fraktion existiert nicht (Liste: ~m~/factionlist~s~)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2017,7 +2017,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Wetter existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Wetter existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2047,7 +2047,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug.");
|
||||
ChatService.Error(player, "Du sitzt momentan nicht in einem Fahrzeug");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2119,26 +2119,26 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if(target.GetUser().BusinessId != null)
|
||||
if (target.GetUser().BusinessId != null)
|
||||
{
|
||||
ChatService.Error(player, "Der Spieler besitzt momentan schon ein Business: ~o~" + BusinessManager.GetBusiness(target.GetUser().BusinessId).Name);
|
||||
return;
|
||||
}
|
||||
|
||||
BusinessBase business = BusinessManager.GetBusiness(businessid);
|
||||
if(business == null)
|
||||
if (business == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Business existiert nicht. ~m~/businesslist");
|
||||
return;
|
||||
}
|
||||
|
||||
if(business.GetOwner() != null)
|
||||
if (business.GetOwner() != null)
|
||||
{
|
||||
ChatService.Error(player, "Das Business hat momentan noch einen Besitzer: ~o~" + business.GetOwner().Name + "~s~. Entferne diesen Besitzer erst mit ~m~/clearbusiness");
|
||||
return;
|
||||
}
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Entities.User targetUser = target.GetUser(dbContext);
|
||||
targetUser.BusinessId = businessid;
|
||||
@@ -2164,12 +2164,12 @@ namespace ReallifeGamemode.Server.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User owner = business.GetOwner(dbContext);
|
||||
if(owner == null)
|
||||
if (owner == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Business hat momentan keinen Besitzer.");
|
||||
ChatService.Error(player, "Dieses Business hat momentan keinen Besitzer");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2226,16 +2226,16 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
option1 = option1.ToString();
|
||||
|
||||
if(option1 != "add" && option1 != "remove" && option1 != "setenterposition" && option1 != "setexitposition")
|
||||
if (option1 != "add" && option1 != "remove" && option1 != "setenterposition" && option1 != "setexitposition")
|
||||
{
|
||||
player.SendChatMessage("~m~Benutzung: ~s~/interior [Add / Remove / SetEnterPosition / SetExitPosition] [Name]");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(option1)
|
||||
switch (option1)
|
||||
{
|
||||
case "add":
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Interior interiorAdd = new Interior
|
||||
{
|
||||
@@ -2249,15 +2249,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
case "remove":
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if(!int.TryParse(option2, out int intId))
|
||||
if (!int.TryParse(option2, out int intId))
|
||||
{
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden.");
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interiorRemove = InteriorManager.GetInteriorById(intId, dbContext);
|
||||
if(interiorRemove == null)
|
||||
if (interiorRemove == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2273,13 +2273,13 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
if (!int.TryParse(option2, out int intIdEnter))
|
||||
{
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden.");
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interior = InteriorManager.GetInteriorById(intIdEnter, dbContext);
|
||||
if (interior == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
interior.EnterPosition = player.Position;
|
||||
@@ -2295,13 +2295,13 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
if (!int.TryParse(option2, out int intIdExit))
|
||||
{
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden.");
|
||||
ChatService.Error(player, "Es muss eine Nummer angegeben werden");
|
||||
return;
|
||||
}
|
||||
Interior interior = InteriorManager.GetInteriorById(intIdExit, dbContext);
|
||||
if (interior == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht.");
|
||||
ChatService.Error(player, "Dieses Interior existiert nicht");
|
||||
return;
|
||||
}
|
||||
interior.ExitPosition = player.Position;
|
||||
@@ -2354,7 +2354,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
if (dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == scName.ToLower()))
|
||||
{
|
||||
ChatService.Error(player, "Dieser Name ist schon auf der Whitelist.");
|
||||
ChatService.Error(player, "Dieser Name ist schon auf der Whitelist");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2367,7 +2367,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == scName.ToLower()))
|
||||
{
|
||||
ChatService.Error(player, "Dieser Name ist nicht auf der Whitelist.");
|
||||
ChatService.Error(player, "Dieser Name ist nicht auf der Whitelist");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2391,7 +2391,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (!Enum.IsDefined(typeof(AdminLevel), rank))
|
||||
{
|
||||
ChatService.Error(player, "Dieser Adminrang ist nicht definiert.");
|
||||
ChatService.Error(player, "Dieser Adminrang ist nicht definiert");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,36 +71,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
#endregion
|
||||
#region Leader Commands
|
||||
|
||||
[Command("invite", "~m~Benutzung: ~s~/invite [Name]")]
|
||||
public void CmdFactionInvite(Client player, string name)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionId != null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Spieler ist schon in einer Fraktion.");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_invite", player.Handle);
|
||||
|
||||
player.SendChatMessage("!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet.");
|
||||
target.SendChatMessage("!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + player.GetUser().Faction.Name + "\" erhalten.");
|
||||
target.SendChatMessage("!{02FCFF}Benutze '/accept invite', um die Einladung anzunehmen");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
[Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)]
|
||||
@@ -121,7 +95,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (target.GetUser()?.FactionId != player.GetUser()?.FactionId)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Spieler ist nicht in deiner Fraktion.");
|
||||
ChatService.Error(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,7 +104,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.RankName == rank && r.FactionId == player.GetUser(dbContext).FactionId);
|
||||
if (fr == null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Rang existiert nicht.");
|
||||
ChatService.Error(player, "Dieser Rang existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,19 +135,19 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
if (target.GetUser()?.FactionId != player.GetUser()?.FactionId)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Spieler ist nicht in deiner Fraktion.");
|
||||
ChatService.Error(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Handle == target.Handle)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst dich nicht selber uninviten.");
|
||||
ChatService.Error(player, "Du kannst dich nicht selber uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionLeader ?? false)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst keinen Leader uninviten.");
|
||||
ChatService.Error(player, "Du kannst keinen Leader uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +195,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst in einem Auto nicht wiederbeleben!");
|
||||
ChatService.Error(player, "Du kannst in einem Auto nicht wiederbeleben");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,10 +203,10 @@ namespace ReallifeGamemode.Server.Commands
|
||||
var deadPlayer = nearPlayers.Where(i => i.GetData("isDead") == true).FirstOrDefault();
|
||||
if (player == deadPlayer)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst dich nicht selbst wiederbeleben!");
|
||||
ChatService.Error(player, "Du kannst dich nicht selbst wiederbeleben");
|
||||
return;
|
||||
}
|
||||
player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
|
||||
player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
|
||||
|
||||
deadPlayer.TriggerEvent("onPlayerRevived");
|
||||
deadPlayer.SendNotification("Du wurdest von ~r~" + player.Name + "~s~ wiederbelebt.");
|
||||
@@ -254,7 +228,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst in einem Auto nicht heilen!");
|
||||
ChatService.Error(player, "Du kannst in einem Auto nicht heilen");
|
||||
return;
|
||||
}
|
||||
Client target = ClientService.GetClientByNameOrId(receiver);
|
||||
@@ -267,7 +241,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("duty", "~m~Benutzung: ~s~/duty")]
|
||||
public void CmdFactionDuty(Client player)
|
||||
{
|
||||
if(player.GetData("duty") == false)
|
||||
if (player.GetData("duty") == false)
|
||||
{
|
||||
player.SetData("duty", true);
|
||||
player.SendNotification("~g~Du bist jetzt im Dienst!", false);
|
||||
|
||||
31
ReallifeGamemode.Server/Commands/GroupCommands.cs
Normal file
31
ReallifeGamemode.Server/Commands/GroupCommands.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class GroupCommands : Script
|
||||
{
|
||||
#region Chat Commands
|
||||
[Command("g", "~m~Benutzung: ~s~/g [Nachricht]", GreedyArg = true)]
|
||||
public void CmdGroupG(Client player, string message)
|
||||
{
|
||||
Entities.Group group = player.GetUser().Group;
|
||||
if (group == null)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~{1})|(!{(.*)})", "");
|
||||
message = $"{player.Name}: {message}";
|
||||
|
||||
ChatService.BroadcastGroup(message, group);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -17,44 +17,11 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
option = option.ToLower();
|
||||
|
||||
switch(option)
|
||||
switch (option)
|
||||
{
|
||||
case "invite":
|
||||
{
|
||||
if(!player.HasData("accept_invite"))
|
||||
{
|
||||
ChatService.Error(player, "Du hast keine Einladung in eine Fraktion erhalten.");
|
||||
return;
|
||||
}
|
||||
|
||||
player.ResetData("accept_data");
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_invite"));
|
||||
|
||||
if(leader == null)
|
||||
{
|
||||
ChatService.Error(player, "Die Einladung ist abgelaufen.");
|
||||
return;
|
||||
}
|
||||
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.FactionId = u.FactionId;
|
||||
own.FactionLeader = false;
|
||||
own.FactionRankId = dbContext
|
||||
.FactionRanks
|
||||
.OrderBy(x => x.Order)
|
||||
.Where(r => r.FactionId == own.FactionId)
|
||||
.FirstOrDefault()?.Id ?? null;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -68,21 +35,15 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
Vehicle pVeh = player.Vehicle;
|
||||
|
||||
if(pVeh.GetServerVehicle() is ServerVehicle veh)
|
||||
if (pVeh.GetServerVehicle() is ServerVehicle veh)
|
||||
{
|
||||
if(player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
if (player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | " + veh.ToString() + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
public string Reason { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
|
||||
|
||||
public int Applied { get; set; }
|
||||
public int UntilDateTime { get; set; }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace ReallifeGamemode.Server.Entities
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public int Balance {
|
||||
public int Balance
|
||||
{
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
|
||||
51
ReallifeGamemode.Server/Entities/Group.cs
Normal file
51
ReallifeGamemode.Server/Entities/Group.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Group : IBankAccountOwner
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
GroupBankAccount bankAccount = null;
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (bankAccount == null)
|
||||
{
|
||||
bankAccount = new GroupBankAccount
|
||||
{
|
||||
Group = this,
|
||||
Balance = 0
|
||||
};
|
||||
|
||||
databaseContext.GroupBankAccounts.Add(bankAccount);
|
||||
databaseContext.SaveChanges();
|
||||
}
|
||||
|
||||
return bankAccount;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
ReallifeGamemode.Server/Entities/GroupBankAccount.cs
Normal file
20
ReallifeGamemode.Server/Entities/GroupBankAccount.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class GroupBankAccount : IBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public Group Group { get; set; }
|
||||
|
||||
public int Balance { get; set; }
|
||||
}
|
||||
}
|
||||
30
ReallifeGamemode.Server/Entities/GroupVehicle.cs
Normal file
30
ReallifeGamemode.Server/Entities/GroupVehicle.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class GroupVehicle : ServerVehicle
|
||||
{
|
||||
public Group Group { get; set; }
|
||||
|
||||
[ForeignKey("Group")]
|
||||
public int? GroupId { get; set; }
|
||||
|
||||
public Group GetGroup()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Groups.Where(g => g.Id == GroupId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Gruppen Fahrzeug | Gruppe: " + Group.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace ReallifeGamemode.Server.Entities.Logs
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
@@ -36,7 +36,7 @@ namespace ReallifeGamemode.Server.Entities.Logs
|
||||
public float KillerPositionY { get; set; }
|
||||
public float KillerPositionZ { get; set; }
|
||||
public float KillerHeading { get; set; }
|
||||
|
||||
|
||||
[StringLength(64)]
|
||||
public string CauseOfDeath { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
|
||||
@@ -34,5 +34,5 @@ namespace ReallifeGamemode.Server.Entities.Saves
|
||||
public float Rotation { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
string numberplate = $"{this.Id}";
|
||||
|
||||
if(this is FactionVehicle fV)
|
||||
if (this is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{fV.FactionId} " + numberplate;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
|
||||
if(this is ShopVehicle sV)
|
||||
if (this is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(veh, false);
|
||||
@@ -66,6 +66,11 @@ namespace ReallifeGamemode.Server.Entities
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
||||
}
|
||||
|
||||
if (this is GroupVehicle gV)
|
||||
{
|
||||
numberplate = $"{gV.GroupId}" + numberplate;
|
||||
}
|
||||
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
return veh;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
[ForeignKey("Ban")]
|
||||
public int? BanId { get; set; }
|
||||
public Ban Ban { get; set; }
|
||||
|
||||
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
@@ -58,6 +58,10 @@ namespace ReallifeGamemode.Server.Entities
|
||||
public int? FactionRankId { get; set; }
|
||||
public FactionRank FactionRank { get; set; }
|
||||
|
||||
public Group Group { get; set; }
|
||||
|
||||
public GroupRank GroupRank { get; set; }
|
||||
|
||||
public FactionRank GetFactionRank()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
@@ -95,7 +99,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
banUser = new Ban { UserId = this.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
|
||||
this.Client?.Kick();
|
||||
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
@@ -126,7 +130,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
|
||||
public List<UserItem> GetItems()
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.UserItems.ToList().FindAll(u => u.UserId == this.Id);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,13 @@ namespace ReallifeGamemode.Server.Entities
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public int Balance {
|
||||
public int Balance
|
||||
{
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ClientService.GetClientByNameOrId(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if(!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
{
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
@@ -44,7 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
}
|
||||
|
||||
|
||||
private bool IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
@@ -69,7 +69,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
|
||||
if(timeStamp > unixTimestamp)
|
||||
if (timeStamp > unixTimestamp)
|
||||
{
|
||||
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
@@ -80,7 +80,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
user.BanId = null;
|
||||
dbContext.SaveChanges();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
@@ -67,7 +67,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if(player != killer)
|
||||
if (player != killer)
|
||||
{
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
@@ -91,16 +91,27 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Entities.Logs.Death { VictimId = player.GetUser().Id, KillerId = killerId, KillerPositionX = killerPosX, KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ, KillerHeading = killerHeading, VictimPositionX = player.Position.X, VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()};
|
||||
var dead = new Entities.Logs.Death
|
||||
{
|
||||
VictimId = player.GetUser().Id,
|
||||
KillerId = killerId,
|
||||
KillerPositionX = killerPosX,
|
||||
KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ,
|
||||
KillerHeading = killerHeading,
|
||||
VictimPositionX = player.Position.X,
|
||||
VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z,
|
||||
VictimHeading = player.Heading,
|
||||
CauseOfDeath = reason.ToString()
|
||||
};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
}
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Client player)
|
||||
{
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
if(!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
if (!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
{
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
@@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
saveUser.SaveChanges();
|
||||
}
|
||||
|
||||
user.Dead = player.HasData("isDead") ? player.GetData("isDead") : false;
|
||||
user.Dead = player.HasData("isDead") ? player.GetData("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if(veh.FactionId != player.GetUser().FactionId)
|
||||
if (veh.FactionId != player.GetUser().FactionId)
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void OnFactionRanksEdit(Client player, string jsonData)
|
||||
{
|
||||
FactionRankHelper helper = JsonConvert.DeserializeObject<FactionRankHelper>(jsonData);
|
||||
using(var context = new DatabaseContext())
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(x => x.Id == helper.FactionId);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.Error(player, "Bei der Bearbeitung der Ränge ist ein Fehler aufgetreten: Die Fraktion existiert nicht.");
|
||||
ChatService.Error(player, "Bei der Bearbeitung der Ränge ist ein Fehler aufgetreten: Die Fraktion existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
List<int> found = new List<int>();
|
||||
|
||||
for(int i = 0; i < ranks.Count; i++)
|
||||
for (int i = 0; i < ranks.Count; i++)
|
||||
{
|
||||
Rank newRank = ranks[i];
|
||||
if(newRank.Id == 0)
|
||||
if (newRank.Id == 0)
|
||||
{
|
||||
context.FactionRanks.Add(new FactionRank
|
||||
{
|
||||
@@ -52,9 +52,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < factionRanks.Count; i++)
|
||||
for (int i = 0; i < factionRanks.Count; i++)
|
||||
{
|
||||
if(!found.Contains(factionRanks[i].Id))
|
||||
if (!found.Contains(factionRanks[i].Id))
|
||||
{
|
||||
context.FactionRanks.Remove(factionRanks[i]);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:UP_ARROW")]
|
||||
public void KeyPressUpArrow(Client player)
|
||||
{
|
||||
@@ -58,6 +59,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
ATMManager.ShowAtmUi(player, player.GetData("nearATM"));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:LEFT_ARROW")]
|
||||
public void KeyPressLeftArrow(Client player)
|
||||
{
|
||||
@@ -81,99 +83,123 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:RIGHT_ARROW")]
|
||||
public void KeyPressRightArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
User user = player.GetUser();
|
||||
switch (user.FactionId)
|
||||
{
|
||||
{
|
||||
//LSFD
|
||||
case 2:
|
||||
player.TriggerEvent("showFactionInteraction", user.FactionId, player.GetData("duty"), user.Faction.Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
|
||||
[RemoteEvent("keyPress:DOWN_ARROW")]
|
||||
public void KeyPressDownArrow(Client player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
var accountData = new
|
||||
{
|
||||
regDate = u.RegistrationDate.ToShortDateString(),
|
||||
adminLevel = u.AdminLevel.GetName(),
|
||||
faction = u.Faction?.Name ?? "Zivilist",
|
||||
factionRank = u.GetFactionRank().RankName,
|
||||
group = u.Group?.Name ?? "Keine",
|
||||
groupRank = u.GroupRank.GetName()
|
||||
};
|
||||
|
||||
string faction = u.FactionLeader ? u.Faction.Name : null;
|
||||
string group = u.Group?.Name ?? null;
|
||||
bool factionInvite = player.HasData("accept_faction_invite");
|
||||
bool groupInvite = player.HasData("accept_group_invite");
|
||||
|
||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), faction, group, factionInvite, groupInvite);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
|
||||
if (player.GetData("duty") == false)
|
||||
if (player.GetData("duty") == false)
|
||||
{
|
||||
player.SetData("duty", true);
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
player.SetData("duty", true);
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
int medicCount = 0;
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
int medicCount = 0;
|
||||
foreach(Client c in NAPI.Pools.GetAllPlayers())
|
||||
if ((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
{
|
||||
if((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
{
|
||||
medicCount++;
|
||||
}
|
||||
medicCount++;
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", medicCount);
|
||||
}
|
||||
switch (factionId)
|
||||
{
|
||||
//LSPD
|
||||
case 1:
|
||||
nameTagColor = new Color(28, 134, 238);
|
||||
break;
|
||||
}
|
||||
player.NametagColor = nameTagColor;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList();
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", medicCount);
|
||||
}
|
||||
switch (factionId)
|
||||
{
|
||||
//LSPD
|
||||
case 1:
|
||||
nameTagColor = new Color(28, 134, 238);
|
||||
break;
|
||||
}
|
||||
player.NametagColor = nameTagColor;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList();
|
||||
|
||||
foreach(var cloth in clothes)
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if (cloth.SlotType == 0)
|
||||
{
|
||||
if(cloth.SlotType == 0)
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cloth.ClothId != -1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("duty", false);
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("duty", false);
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:I")]
|
||||
public void KeyPressI(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:J")]
|
||||
public void KeyPressJ(Client player)
|
||||
{
|
||||
@@ -181,7 +207,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
List<ListPlayer> ListPlayers = new List<ListPlayer>();
|
||||
|
||||
foreach(Client listPlayer in players)
|
||||
foreach (Client listPlayer in players)
|
||||
{
|
||||
var lPlayer = new ListPlayer
|
||||
{
|
||||
@@ -193,7 +219,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
ListPlayers.Add(lPlayer);
|
||||
}
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:K")]
|
||||
public void KeyPressK(Client player)
|
||||
{
|
||||
@@ -213,9 +240,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||
foreach(var cloth in clothes)
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
@@ -245,14 +272,16 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:L")]
|
||||
public void KeyPressL(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
DoorManager.ChangeDoorState(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
@@ -266,19 +295,19 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if(veh != null)
|
||||
if (veh != null)
|
||||
{
|
||||
if(veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
if (veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(veh is ShopVehicle)
|
||||
else if (veh is ShopVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("ToggleVehicleMenu");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
foreach (Client user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
[ServerEvent(Event.Update)]
|
||||
public void UpdateEvent()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
@@ -74,9 +74,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is UserVehicle uV)
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if(uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
if (uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,26 +24,15 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
/// <returns></returns>
|
||||
public static User GetUser(this Client client, DatabaseContext context = null)
|
||||
{
|
||||
context = context ?? new DatabaseContext();
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
if(context == null)
|
||||
{
|
||||
using (context = new DatabaseContext())
|
||||
{
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.FirstOrDefault(u => u.Name == client.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.FirstOrDefault(u => u.Name == client.Name);
|
||||
}
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.Include(u => u.Group)
|
||||
.Where(u => u.Name == client.Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class AdminLevelExtension
|
||||
public static class EnumExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||
@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
/// <returns></returns>
|
||||
public static string GetName(this AdminLevel level)
|
||||
{
|
||||
switch(level)
|
||||
switch (level)
|
||||
{
|
||||
case SUPPORTER:
|
||||
return "Supporter";
|
||||
@@ -31,5 +31,20 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
return "Spieler";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetName(this GroupRank rank)
|
||||
{
|
||||
switch(rank)
|
||||
{
|
||||
case GroupRank.OWNER:
|
||||
return "Besitzer";
|
||||
case GroupRank.MANAGER:
|
||||
return "Manager";
|
||||
case GroupRank.MEMBER:
|
||||
return "Mitglied";
|
||||
default:
|
||||
return "Keiner";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
|
||||
public static void PickUpGroundItem(Client player)
|
||||
{
|
||||
GroundItem nearest = GroundItems.FirstOrDefault(d => d.Position.DistanceTo(player.Position) <= 1.2);
|
||||
GroundItem nearest = GroundItems.FirstOrDefault(d => d.Position.DistanceTo(player.Position) <= 1.2);
|
||||
if (nearest != null)
|
||||
{
|
||||
var invWeight = InventoryManager.GetUserInventoryWeight(player);
|
||||
@@ -40,9 +40,9 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
var user = player.GetUser();
|
||||
if (nearestItem.Gewicht * nearest.Amount + invWeight > 40000)
|
||||
{
|
||||
for(var i = 1; i <= nearest.Amount; i++)
|
||||
{
|
||||
if(invWeight + (i * nearestItem.Gewicht) > 40000)
|
||||
for (var i = 1; i <= nearest.Amount; i++)
|
||||
{
|
||||
if (invWeight + (i * nearestItem.Gewicht) > 40000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -51,13 +51,13 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
itemsToAdd = i;
|
||||
}
|
||||
}
|
||||
if(itemsToAdd < 1)
|
||||
if (itemsToAdd < 1)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Platz im Inventar!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(existingItem != null)
|
||||
if (existingItem != null)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
else
|
||||
{
|
||||
UserItem newItem = new UserItem { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, newItem);
|
||||
InventoryManager.AddItemToInventory(player, newItem);
|
||||
}
|
||||
nearest.Amount -= itemsToAdd;
|
||||
nearestTextLabel.Text = nearestItem.Name + " ~s~(~y~" + nearest.Amount + "~s~)";
|
||||
@@ -84,17 +84,17 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
{
|
||||
UserItem existingUserItem = context.UserItems.FirstOrDefault(i => i.Id == existingItem.Id && i.UserId == user.Id);
|
||||
existingUserItem.Amount += nearest.Amount;
|
||||
context.SaveChanges();
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, item);
|
||||
InventoryManager.AddItemToInventory(player, item);
|
||||
}
|
||||
RemoveGroundItem(nearest, nearestObject, nearestTextLabel);
|
||||
player.SendNotification("Du hast ~g~" + nearest.Amount + " ~y~" + nearestItem.Name + " ~s~aufgehoben.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ namespace ReallifeGamemode.Server.Inventory
|
||||
GroundItems.Remove(grndItem);
|
||||
NAPI.Entity.DeleteEntity(grndObject);
|
||||
NAPI.Entity.DeleteEntity(grndTextLabel);
|
||||
GroundObjects.Remove(grndObject);
|
||||
GroundTextLabels.Remove(grndTextLabel);
|
||||
GroundObjects.Remove(grndObject);
|
||||
GroundTextLabels.Remove(grndTextLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Text;
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cheeseburger : FoodItem
|
||||
{
|
||||
{
|
||||
public override int Id => 2;
|
||||
public override string Name => "Cheeseburger";
|
||||
public override string Description => "Wie der Hamburger, nur mit Käse.";
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ReallifeGamemode.Server.Inventory.Items
|
||||
Client player = uItem.GetUser().Client;
|
||||
|
||||
int amountToAdd = HpAmount;
|
||||
if(player.Health + amountToAdd > 100)
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Text;
|
||||
*/
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
{
|
||||
public class Holz : IDroppableItem
|
||||
{
|
||||
public int Id => 4;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ReallifeGamemode.Server
|
||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||
|
||||
|
||||
|
||||
|
||||
InventoryManager.LoadItems();
|
||||
@@ -46,6 +46,7 @@ namespace ReallifeGamemode.Server
|
||||
InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
|
||||
|
||||
TempBlip tempBlip = new TempBlip()
|
||||
@@ -60,5 +61,5 @@ namespace ReallifeGamemode.Server
|
||||
|
||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if(dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
{
|
||||
var dataSet = new ATM
|
||||
{
|
||||
@@ -46,7 +46,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
}
|
||||
if(addedATMs > 0)
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
public static void ShowAtmUi(Client player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
@@ -150,6 +150,6 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Business;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
@@ -51,7 +52,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
public void BusinessDepositMoney(Client player, int amount)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -70,7 +71,8 @@ namespace ReallifeGamemode.Server.Managers
|
||||
player.SendNotification("~r~Du hast nicht genug Geld");
|
||||
return;
|
||||
}
|
||||
else */if(result == TransactionResult.SUCCESS)
|
||||
else */
|
||||
if (result == TransactionResult.SUCCESS)
|
||||
{
|
||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||
@@ -114,13 +116,22 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if(!(sVeh is ShopVehicle)) return;
|
||||
if (!(sVeh is ShopVehicle)) return;
|
||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price);
|
||||
|
||||
List<string> availableTargets = new List<string>()
|
||||
{
|
||||
"Spieler"
|
||||
};
|
||||
|
||||
if (player.GetUser().FactionLeader && !player.GetUser().Faction.StateOwned) availableTargets.Add("Fraktion");
|
||||
if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
|
||||
|
||||
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price, availableTargets.ToArray());
|
||||
}
|
||||
|
||||
[RemoteEvent("VehShop_BuyVehicle")]
|
||||
public void CarDealerBusiness_BuyVehicle(Client player)
|
||||
public void CarDealerBusiness_BuyVehicle(Client player, string target)
|
||||
{
|
||||
ServerVehicle sVeh = player.Vehicle?.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
@@ -129,7 +140,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
int price = shopVehicle.Price;
|
||||
CarDealerBusinessBase business = GetBusiness(shopVehicle.BusinessId) as CarDealerBusinessBase;
|
||||
TransactionResult result = BankManager.TransferMoney(player.GetUser(), business, price, "Auto gekauft");
|
||||
if(result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Du hast nicht genug Geld: " + price.ToMoneyString());
|
||||
return;
|
||||
@@ -139,23 +150,60 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
player.TriggerEvent("SERVER:Util_setWaypoint", spawnPos.X, spawnPos.Y);
|
||||
|
||||
UserVehicle newVeh = new UserVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
UserId = player.GetUser().Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
ServerVehicle newVeh = null;
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
if(target == "Spieler")
|
||||
{
|
||||
dbContext.UserVehicles.Add(newVeh);
|
||||
newVeh = new UserVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
UserId = player.GetUser().Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if(target == "Fraktion")
|
||||
{
|
||||
newVeh = new FactionVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
FactionId = player.GetUser().FactionId,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if(target == "Gruppe")
|
||||
{
|
||||
newVeh = new GroupVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
GroupId = player.GetUser().Group.Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.ServerVehicles.Add(newVeh);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
player.SetHeadOverlay(11, blemishes);
|
||||
player.SetHeadOverlay(12, blemishes);
|
||||
|
||||
|
||||
|
||||
//Gesicht (Vererbung durch Mutter / Vater)
|
||||
HeadBlend headBlend = new HeadBlend()
|
||||
{
|
||||
@@ -324,7 +324,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
//Augenfarbe
|
||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
67
ReallifeGamemode.Server/Managers/CityHallManager.cs
Normal file
67
ReallifeGamemode.Server/Managers/CityHallManager.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class CityHallManager : Script
|
||||
{
|
||||
private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
|
||||
|
||||
public static void LoadCityHall()
|
||||
{
|
||||
NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255));
|
||||
NAPI.TextLabel.CreateTextLabel("~y~Stadthalle~s~\nDrücke ~o~E~s~, um das Menü zu öffnen", _cityHallPosition, 5.0f, 1f, 0, new Color(255, 255, 255));
|
||||
var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f);
|
||||
colShape.OnEntityEnterColShape += (s, c) =>
|
||||
{
|
||||
c.TriggerEvent("SERVER:CityHall_ShowHelpText");
|
||||
};
|
||||
|
||||
colShape.OnEntityExitColShape += (s, c) =>
|
||||
{
|
||||
c.TriggerEvent("SERVER:CityHall_ClearHelpText");
|
||||
};
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:CityHall_CreateGroup")]
|
||||
public void CreateGroup(Client player, string name)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
if(u.Group != null)
|
||||
{
|
||||
ChatService.Error(player, "Du bist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
if(dbContext.Groups.Any(g => g.Name.ToLower() == name.ToLower()))
|
||||
{
|
||||
ChatService.Error(player, "Dieser Name ist schon vergeben");
|
||||
return;
|
||||
}
|
||||
|
||||
Group group = new Group
|
||||
{
|
||||
Name = name
|
||||
};
|
||||
|
||||
dbContext.Groups.Add(group);
|
||||
|
||||
u.Group = group;
|
||||
u.GroupRank = GroupRank.OWNER;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(Door door in dbContext.Doors)
|
||||
foreach (Door door in dbContext.Doors)
|
||||
{
|
||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static void ReloadDoors()
|
||||
{
|
||||
foreach(var doorPair in _doorColShapes)
|
||||
foreach (var doorPair in _doorColShapes)
|
||||
{
|
||||
doorPair.Value.Entity<ColShape>().Delete();
|
||||
}
|
||||
@@ -44,12 +44,12 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
if(!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
d.Locked = !d.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
@@ -69,11 +69,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
if(_doorColShapes.ContainsValue(colShape.Handle))
|
||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||
{
|
||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
@@ -21,6 +24,108 @@ namespace ReallifeGamemode.Server.Managers
|
||||
#region Umgebungsinteraktionen PFEILTASTE-HOCH
|
||||
#endregion
|
||||
#region Eigeninteraktionen PFEILTASTE-RUNTER
|
||||
[RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")]
|
||||
public void InteractionMenuAcceptInvite(Client player, string type)
|
||||
{
|
||||
if (type != "Fraktion" || type != "Gruppe") return;
|
||||
|
||||
if (type == "Fraktion") // Fraktions Invite annehmen
|
||||
{
|
||||
if (!player.HasData("accept_faction_invite"))
|
||||
{
|
||||
ChatService.Error(player, "Du hast keine Einladung in eine Fraktion erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_faction_invite"));
|
||||
player.ResetData("accept_faction_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
ChatService.Error(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.FactionId = u.FactionId;
|
||||
own.FactionLeader = false;
|
||||
own.FactionRankId = dbContext
|
||||
.FactionRanks
|
||||
.OrderBy(x => x.Order)
|
||||
.Where(r => r.FactionId == own.FactionId)
|
||||
.FirstOrDefault()?.Id ?? null;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe") // Gruppen Einladung annehmen
|
||||
{
|
||||
if (!player.HasData("accept_group_invite"))
|
||||
{
|
||||
ChatService.Error(player, "Du hast keine Einladung in eine Gruppe erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_group_invite"));
|
||||
player.ResetData("accept_group_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
ChatService.Error(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.Group = u.Group;
|
||||
own.GroupRank = GroupRank.MEMBER;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_InviteFaction")]
|
||||
public void InteractionMenuInviteFaction(Client player, string nameOrId)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionId != null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Spieler ist schon in einer Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_faction_invite", player.Handle);
|
||||
|
||||
player.SendChatMessage("!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet.");
|
||||
target.SendChatMessage("!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + player.GetUser().Faction.Name + "\" erhalten.");
|
||||
target.SendChatMessage("!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
#endregion
|
||||
#region Spielerinteraktionen PFEILTASTE-LINKS
|
||||
[RemoteEvent("openTradeInventory")]
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static Interior GetInteriorByName(string name, DatabaseContext dbContext = null)
|
||||
{
|
||||
if(dbContext == null)
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
if (interior.EnterPosition != null)
|
||||
{
|
||||
_interiorEnterTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Eingang", interior.EnterPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorEnterMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.EnterPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 2.0f, new Color(255, 255, 255, 100));
|
||||
_interiorEnterMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.EnterPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorEnterColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.EnterPosition, 1.5f);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
_interiorExitTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Ausgang", interior.ExitPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorExitMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.ExitPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.3f);
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
int enterId = GetInteriorIdFromEnterColShape(colShape);
|
||||
int exitId = GetInteriorIdFromExitColShape(colShape);
|
||||
if(enterId != 0)
|
||||
if (enterId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(enterId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 0);
|
||||
}
|
||||
else if(exitId != 0)
|
||||
else if (exitId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(exitId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 1);
|
||||
@@ -129,7 +129,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
[ServerEvent(Event.PlayerExitColshape)]
|
||||
public void InteriorManagerPlayerExitColshapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
if(GetInteriorIdFromEnterColShape(colShape) != 0 || GetInteriorIdFromExitColShape(colShape) != 0)
|
||||
if (GetInteriorIdFromEnterColShape(colShape) != 0 || GetInteriorIdFromExitColShape(colShape) != 0)
|
||||
{
|
||||
player.TriggerEvent("InteriorManager_ClearHelpText");
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
int newSlot = slotArr.Min();
|
||||
|
||||
item.Slot = newSlot;
|
||||
context.UserItems.Add(item);
|
||||
context.UserItems.Add(item);
|
||||
|
||||
IItem iItem = GetItemById(item.ItemId);
|
||||
|
||||
@@ -303,14 +303,14 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
Vector3 dropPosition = ClientExtension.GetPositionFromPlayer(player, 0.6f, 0);
|
||||
dropPosition.Z -= 0.8f;
|
||||
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
||||
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
||||
Random r = new Random();
|
||||
GTANetworkAPI.Object grndObject = NAPI.Object.CreateObject(3777723516, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 0);
|
||||
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition};
|
||||
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
|
||||
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", dropPosition, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
||||
fItem.Amount -= amount;
|
||||
player.TriggerEvent("removeItem", itemId, amount);
|
||||
player.TriggerEvent("removeItem", itemId, amount);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
foreach (SavedBlip b in loadData.Blips)
|
||||
{
|
||||
if(b.Active == true)
|
||||
{
|
||||
NAPI.Blip.CreateBlip((uint) b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
||||
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short) b.Rotation, b.Dimension);
|
||||
if (b.Active == true)
|
||||
{
|
||||
NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
||||
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ServerVehicle veh in loadData.ServerVehicles)
|
||||
foreach (ServerVehicle veh in loadData.ServerVehicles)
|
||||
{
|
||||
if (!veh.Active) continue;
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
foreach (DutyPoint d in DutyPoints)
|
||||
{
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1),
|
||||
new Vector3(0,0,0), 3, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1),
|
||||
new Vector3(0, 0, 0), 3, new Color(255, 255, 255, 50), false, 0);
|
||||
NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DutyPoint
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
float rotation = float.Parse(blipRotation);
|
||||
byte dimension = Convert.ToByte(blipDimension);
|
||||
|
||||
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x,y,z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
||||
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
||||
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
|
||||
saveAll.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static void StartTimeManager()
|
||||
{
|
||||
if(realTimeTimer == null)
|
||||
if (realTimeTimer == null)
|
||||
{
|
||||
realTimeTimer = new Timer(1000);
|
||||
realTimeTimer.Elapsed += SetTime;
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
colShape.OnEntityEnterColShape += (cs, c) =>
|
||||
{
|
||||
if(c.IsInVehicle)
|
||||
if (c.IsInVehicle)
|
||||
{
|
||||
Vehicle v = c.Vehicle;
|
||||
if(v.GetServerVehicle() is FactionVehicle fV && fV.GetFaction().StateOwned)
|
||||
if (v.GetServerVehicle() is FactionVehicle fV && fV.GetFaction().StateOwned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -60,13 +60,13 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(VehicleMod vMod in dbContext.VehicleMods.ToList().FindAll(vM => vM.ServerVehicleId == sVeh.Id))
|
||||
foreach (VehicleMod vMod in dbContext.VehicleMods.ToList().FindAll(vM => vM.ServerVehicleId == sVeh.Id))
|
||||
{
|
||||
if(vMod.Slot == 18)
|
||||
if (vMod.Slot == 18)
|
||||
{
|
||||
veh.SetSharedData("mod" + vMod.Slot, true);
|
||||
}
|
||||
else if(vMod.Slot == 22)
|
||||
else if (vMod.Slot == 22)
|
||||
{
|
||||
int color = vMod.ModId - 2;
|
||||
if (vMod.ModId == 0) color = -1;
|
||||
@@ -99,9 +99,9 @@ namespace ReallifeGamemode.Server.Managers
|
||||
Vehicle pV = player.Vehicle;
|
||||
if (index == 0) index--;
|
||||
|
||||
if(slot != 18)
|
||||
if (slot != 18)
|
||||
{
|
||||
if(slot == 22)
|
||||
if (slot == 22)
|
||||
{
|
||||
int color = index - 2;
|
||||
if (index == 0) color = -1;
|
||||
@@ -126,7 +126,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
VehicleMod vMod = dbContext.VehicleMods.FirstOrDefault(m => m.ServerVehicleId == sV.Id && m.Slot == slot);
|
||||
if(vMod == null && index != -1)
|
||||
if (vMod == null && index != -1)
|
||||
{
|
||||
vMod = new VehicleMod
|
||||
{
|
||||
@@ -136,7 +136,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
};
|
||||
dbContext.VehicleMods.Add(vMod);
|
||||
}
|
||||
else if(vMod != null && index == -1)
|
||||
else if (vMod != null && index == -1)
|
||||
{
|
||||
dbContext.VehicleMods.Remove(vMod);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static void AddVehicle(ServerVehicle serverVehicle, Vehicle vehicle)
|
||||
{
|
||||
if(_serverVehicles.ContainsKey(serverVehicle.Id))
|
||||
if (_serverVehicles.ContainsKey(serverVehicle.Id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static Vehicle GetVehicleFromServerVehicle(ServerVehicle serverVehicle)
|
||||
{
|
||||
if(!_serverVehicles.ContainsKey(serverVehicle.Id))
|
||||
if (!_serverVehicles.ContainsKey(serverVehicle.Id))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static ServerVehicle GetServerVehicleFromVehicle(Vehicle veh, DatabaseContext dbContext = null)
|
||||
{
|
||||
if(dbContext == null)
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
@@ -191,12 +191,12 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static bool IsValidHash(uint hash)
|
||||
{
|
||||
foreach(VehicleHash vh in Enum.GetValues(typeof(VehicleHash)))
|
||||
foreach (VehicleHash vh in Enum.GetValues(typeof(VehicleHash)))
|
||||
{
|
||||
if ((uint)vh == hash) return true;
|
||||
}
|
||||
|
||||
foreach(string mod in _enabledMods)
|
||||
foreach (string mod in _enabledMods)
|
||||
{
|
||||
if (NAPI.Util.GetHashKey(mod) == hash) return true;
|
||||
}
|
||||
|
||||
1107
ReallifeGamemode.Server/Migrations/20190505154643_Groups.Designer.cs
generated
Normal file
1107
ReallifeGamemode.Server/Migrations/20190505154643_Groups.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
128
ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs
Normal file
128
ReallifeGamemode.Server/Migrations/20190505154643_Groups.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace ReallifeGamemode.Migrations
|
||||
{
|
||||
public partial class Groups : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GroupId",
|
||||
table: "Users",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GroupRank",
|
||||
table: "Users",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "GroupId",
|
||||
table: "ServerVehicles",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Groups",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GroupBankAccounts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
GroupId = table.Column<int>(nullable: true),
|
||||
Balance = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GroupBankAccounts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_GroupBankAccounts_Groups_GroupId",
|
||||
column: x => x.GroupId,
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_GroupId",
|
||||
table: "Users",
|
||||
column: "GroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ServerVehicles_GroupId",
|
||||
table: "ServerVehicles",
|
||||
column: "GroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GroupBankAccounts_GroupId",
|
||||
table: "GroupBankAccounts",
|
||||
column: "GroupId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_ServerVehicles_Groups_GroupId",
|
||||
table: "ServerVehicles",
|
||||
column: "GroupId",
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Users_Groups_GroupId",
|
||||
table: "Users",
|
||||
column: "GroupId",
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_ServerVehicles_Groups_GroupId",
|
||||
table: "ServerVehicles");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Users_Groups_GroupId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GroupBankAccounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Groups");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Users_GroupId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_ServerVehicles_GroupId",
|
||||
table: "ServerVehicles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GroupId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GroupRank",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "GroupId",
|
||||
table: "ServerVehicles");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,6 +374,34 @@ namespace ReallifeGamemode.Migrations
|
||||
b.ToTable("GotoPoints");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Group", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Balance");
|
||||
|
||||
b.Property<int?>("GroupId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("GroupBankAccounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -744,6 +772,10 @@ namespace ReallifeGamemode.Migrations
|
||||
|
||||
b.Property<int?>("FactionRankId");
|
||||
|
||||
b.Property<int?>("GroupId");
|
||||
|
||||
b.Property<int>("GroupRank");
|
||||
|
||||
b.Property<int>("Handmoney");
|
||||
|
||||
b.Property<int>("LogUserId");
|
||||
@@ -779,6 +811,8 @@ namespace ReallifeGamemode.Migrations
|
||||
|
||||
b.HasIndex("FactionRankId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
@@ -870,6 +904,17 @@ namespace ReallifeGamemode.Migrations
|
||||
b.HasDiscriminator().HasValue("FactionVehicle");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b =>
|
||||
{
|
||||
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
|
||||
|
||||
b.Property<int?>("GroupId");
|
||||
|
||||
b.HasIndex("GroupId");
|
||||
|
||||
b.HasDiscriminator().HasValue("GroupVehicle");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b =>
|
||||
{
|
||||
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
|
||||
@@ -960,6 +1005,13 @@ namespace ReallifeGamemode.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||
.WithMany()
|
||||
.HasForeignKey("GroupId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer")
|
||||
@@ -996,6 +1048,10 @@ namespace ReallifeGamemode.Migrations
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.FactionRank", "FactionRank")
|
||||
.WithMany()
|
||||
.HasForeignKey("FactionRankId");
|
||||
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||
.WithMany()
|
||||
.HasForeignKey("GroupId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
|
||||
@@ -1029,6 +1085,13 @@ namespace ReallifeGamemode.Migrations
|
||||
.HasForeignKey("FactionId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group")
|
||||
.WithMany()
|
||||
.HasForeignKey("GroupId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b =>
|
||||
{
|
||||
b.HasOne("ReallifeGamemode.Server.Entities.User", "User")
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace ReallifeGamemode.Server.Models
|
||||
public DbSet<Entities.User> Users { get; set; }
|
||||
public DbSet<Entities.UserVehicle> UserVehicles { get; set; }
|
||||
public DbSet<Entities.UserBankAccount> UserBankAccounts { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
//Inventar
|
||||
public DbSet<Entities.UserItem> UserItems { get; set; }
|
||||
|
||||
@@ -94,5 +94,10 @@ namespace ReallifeGamemode.Server.Models
|
||||
|
||||
// Tuning Garages
|
||||
public DbSet<Entities.TuningGarage> TuningGarages { get; set; }
|
||||
}
|
||||
|
||||
// Gruppen
|
||||
public DbSet<Entities.Group> Groups { get; set; }
|
||||
public DbSet<Entities.GroupBankAccount> GroupBankAccounts { get; set; }
|
||||
public DbSet<Entities.GroupVehicle> GroupVehicles { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,17 @@ namespace ReallifeGamemode.Server.Services
|
||||
{
|
||||
public static void NotAuthorized(Client player)
|
||||
{
|
||||
ChatService.Error(player, "Du kannst diesen Befehl nicht ausführen.");
|
||||
ChatService.Error(player, "Du kannst diesen Befehl nicht ausführen");
|
||||
}
|
||||
|
||||
public static void PlayerNotFound(Client player)
|
||||
{
|
||||
ChatService.Error(player, "Der Spieler wurde nicht gefunden.");
|
||||
ChatService.Error(player, "Der Spieler wurde nicht gefunden");
|
||||
}
|
||||
|
||||
public static void Error(Client player, string message)
|
||||
{
|
||||
player.SendChatMessage($"~r~[FEHLER]~s~ {message}.");
|
||||
player.SendChatMessage($"~r~[FEHLER]~s~ {message}~s~.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -68,7 +68,21 @@ namespace ReallifeGamemode.Server.Services
|
||||
{
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if(p.GetUser()?.IsAdmin(minLevel) ?? false)
|
||||
if (p.GetUser()?.IsAdmin(minLevel) ?? false)
|
||||
{
|
||||
p.SendChatMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BroadcastGroup(string message, Group group)
|
||||
{
|
||||
message = $"!{{FF8080}}** Gruppe: {message}";
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
Group pGroup = p.GetUser()?.Group;
|
||||
if (pGroup?.Id == group.Id)
|
||||
{
|
||||
p.SendChatMessage(message);
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ namespace ReallifeGamemode.Server.Services
|
||||
|
||||
List<Client> playerList = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
if(int.TryParse(nameOrId, out int id))
|
||||
if (int.TryParse(nameOrId, out int id))
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Handle.Value == id);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
toReturn = playerList.Find(p => p.Name.ToLower() == nameOrId);
|
||||
|
||||
if(toReturn == null)
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(nameOrId));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
public static void InitDatabaseFirstTime()
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Initializing database...");
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.Users.FirstOrDefault();
|
||||
dbContext.SaveChanges();
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace ReallifeGamemode.Server.Util
|
||||
public static void CheckFactionBankAccounts()
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Checking faction bank accounts...");
|
||||
using(var dbContext = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(Faction faction in dbContext.Factions)
|
||||
foreach (Faction faction in dbContext.Factions)
|
||||
{
|
||||
if(faction.GetBankAccount(dbContext) == null)
|
||||
if (faction.GetBankAccount(dbContext) == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Adding bank account for faction: " + faction.Name);
|
||||
FactionBankAccount factionBankAccount = new FactionBankAccount()
|
||||
|
||||
14
ReallifeGamemode.Server/Util/GroupRanks.cs
Normal file
14
ReallifeGamemode.Server/Util/GroupRanks.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public enum GroupRank
|
||||
{
|
||||
NONE,
|
||||
MEMBER,
|
||||
MANAGER,
|
||||
OWNER
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
public class ListPlayer
|
||||
public class ListPlayer
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
VehicleSyncData data = GetVehicleSyncData(veh);
|
||||
if (data == default(VehicleSyncData))
|
||||
data = new VehicleSyncData();
|
||||
|
||||
|
||||
data.Engine = status;
|
||||
UpdateVehicleSyncData(veh, data);
|
||||
NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetEngineStatus", veh, status);
|
||||
@@ -207,7 +207,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetLockStatus", veh, status);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if(p.IsInVehicle && p.Vehicle.Handle == veh.Handle)
|
||||
if (p.IsInVehicle && p.Vehicle.Handle == veh.Handle)
|
||||
{
|
||||
p.TriggerEvent("Vehicle_setLockStatus", status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user