haus system auf core geändert
This commit is contained in:
@@ -12,7 +12,7 @@ const ListItem = NativeUI.ListItem;
|
|||||||
|
|
||||||
import moneyFormat from '../moneyformat';
|
import moneyFormat from '../moneyformat';
|
||||||
|
|
||||||
export default function carDealer(globalData: GlobalData) {
|
export default function carDealer(globalData: IGlobalData) {
|
||||||
|
|
||||||
var shopMenu: NativeUI.Menu;
|
var shopMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const ListItem = NativeUI.ListItem;
|
|||||||
|
|
||||||
import InputHelper from '../inputhelper';
|
import InputHelper from '../inputhelper';
|
||||||
|
|
||||||
export default function business(globalData: GlobalData) {
|
export default function business(globalData: IGlobalData) {
|
||||||
|
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
const localPlayer = mp.players.local;
|
const localPlayer = mp.players.local;
|
||||||
|
|
||||||
export default function charCreator(globalData: GlobalData) {
|
export default function charCreator(globalData: IGlobalData) {
|
||||||
|
|
||||||
var creatorHairMenu;
|
var creatorHairMenu;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import InputHelper from '../../inputhelper';
|
import InputHelper from '../../inputhelper';
|
||||||
|
|
||||||
export default function inventory(globalData: GlobalData) {
|
export default function inventory(globalData: IGlobalData) {
|
||||||
var q;
|
var q;
|
||||||
var qw = 0;
|
var qw = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const Color = NativeUI.Color;
|
|||||||
|
|
||||||
import InputHelper from '../inputhelper';
|
import InputHelper from '../inputhelper';
|
||||||
|
|
||||||
export default function (globalData: GlobalData) {
|
export default function (globalData: IGlobalData) {
|
||||||
|
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
var menu: NativeUI.Menu = null;
|
var menu: NativeUI.Menu = null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import moneyFormat from '../moneyformat';
|
import moneyFormat from '../moneyformat';
|
||||||
|
|
||||||
export default function handMoney(globalData: GlobalData) {
|
export default function handMoney(globalData: IGlobalData) {
|
||||||
var currentMoney = null;
|
var currentMoney = null;
|
||||||
var showMoneyChange = null;
|
var showMoneyChange = null;
|
||||||
var difference;
|
var difference;
|
||||||
|
|||||||
@@ -1,32 +1,28 @@
|
|||||||
import { Menu, Point, UIMenuItem, Color } from '../libs/NativeUI';
|
import { Menu, Point, UIMenuItem, Color } from '../libs/NativeUI';
|
||||||
import moneyFormat from '../moneyformat';
|
import moneyFormat from '../moneyformat';
|
||||||
import InputHelper from '../inputhelper';
|
import InputHelper from '../inputhelper';
|
||||||
|
import game from '..';
|
||||||
|
import { Key } from '../game';
|
||||||
|
|
||||||
export default function house(globalData: GlobalData) {
|
var houseMenu: Menu;
|
||||||
|
var houseData: any;
|
||||||
|
var houseState: number;
|
||||||
|
|
||||||
var houseMenu: Menu;
|
game.events.add("SERVER:ShowHouseMenu", () => {
|
||||||
var houseData: any;
|
|
||||||
var houseState: number;
|
|
||||||
|
|
||||||
var keyBound = false;
|
game.ui.setHelpText('Drücke ~INPUT_CONTEXT~, um das Hausmenü öffnen');
|
||||||
|
|
||||||
mp.events.add("SERVER:ShowHouseMenu", () => {
|
game.events.bindKey(Key.E, false, keyPressHandler);
|
||||||
mp.game.ui.setTextComponentFormat('STRING');
|
});
|
||||||
mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um das Hausmenü öffnen');
|
|
||||||
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
|
||||||
|
|
||||||
mp.keys.bind(0x45, false, keyPressHandler);
|
game.events.add("SERVER:SetHouseData", (dataStr, state) => {
|
||||||
keyBound = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add("SERVER:SetHouseData", (dataStr, state) => {
|
|
||||||
houseData = JSON.parse(dataStr);
|
houseData = JSON.parse(dataStr);
|
||||||
houseState = state;
|
houseState = state;
|
||||||
});
|
});
|
||||||
|
|
||||||
function keyPressHandler() {
|
function keyPressHandler() {
|
||||||
if (globalData.InMenu || globalData.InChat || globalData.InInput || !globalData.LoggedIn) return;
|
if (game.ui.inMenu || game.ui.inChat) return;
|
||||||
mp.game.ui.clearHelp(true);
|
game.ui.clearHelpText();
|
||||||
|
|
||||||
var subTitle = houseData.Type;
|
var subTitle = houseData.Type;
|
||||||
if (houseData.OwnerName) {
|
if (houseData.OwnerName) {
|
||||||
@@ -35,7 +31,7 @@ export default function house(globalData: GlobalData) {
|
|||||||
|
|
||||||
houseMenu = new Menu("Hausverwaltung", subTitle, new Point(50, 50), null, null);
|
houseMenu = new Menu("Hausverwaltung", subTitle, new Point(50, 50), null, null);
|
||||||
|
|
||||||
globalData.InMenu = true;
|
game.ui.inMenu = true;
|
||||||
|
|
||||||
var rentInItem: UIMenuItem;
|
var rentInItem: UIMenuItem;
|
||||||
var cancelOwnRentalItem: UIMenuItem;
|
var cancelOwnRentalItem: UIMenuItem;
|
||||||
@@ -76,7 +72,7 @@ export default function house(globalData: GlobalData) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cancelRentalsMenu.ItemSelect.on((item: UIMenuItem, index: number) => {
|
cancelRentalsMenu.ItemSelect.on((item: UIMenuItem, index: number) => {
|
||||||
mp.events.callRemote("CLIENT:House_CancelUserRental", item.Text);
|
game.events.callServer("House_CancelUserRental", item.Text);
|
||||||
houseRentals--;
|
houseRentals--;
|
||||||
cancelRentalsItem.SetRightLabel(houseRentals.toString());
|
cancelRentalsItem.SetRightLabel(houseRentals.toString());
|
||||||
if (houseRentals === 0) {
|
if (houseRentals === 0) {
|
||||||
@@ -107,14 +103,12 @@ export default function house(globalData: GlobalData) {
|
|||||||
|
|
||||||
houseMenu.ItemSelect.on((item, index) => {
|
houseMenu.ItemSelect.on((item, index) => {
|
||||||
if (item === cancelItem) {
|
if (item === cancelItem) {
|
||||||
mp.events.call("SERVER:CloseHouseMenu");
|
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
} else if (item === buyHouseItem) {
|
} else if (item === buyHouseItem) {
|
||||||
mp.events.callRemote("CLIENT:House_BuyHouse");
|
game.events.callServer("House_BuyHouse");
|
||||||
mp.events.call("SERVER:CloseHouseMenu");
|
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
} else if (item === setRentalFeeItem) {
|
} else if (item === setRentalFeeItem) {
|
||||||
var rentalFeeInput = new InputHelper("Wie viel soll die Miete betragen?", globalData);
|
var rentalFeeInput = new InputHelper("Wie viel soll die Miete betragen?");
|
||||||
rentalFeeInput.show();
|
rentalFeeInput.show();
|
||||||
rentalFeeInput.getValue(data => {
|
rentalFeeInput.getValue(data => {
|
||||||
if (isNaN(data)) {
|
if (isNaN(data)) {
|
||||||
@@ -123,36 +117,30 @@ export default function house(globalData: GlobalData) {
|
|||||||
|
|
||||||
var rentalFee = parseInt(data);
|
var rentalFee = parseInt(data);
|
||||||
|
|
||||||
mp.events.callRemote("CLIENT:House_SetRentalFee", rentalFee);
|
game.events.callServer("House_SetRentalFee", rentalFee);
|
||||||
mp.events.call("SERVER:CloseHouseMenu");
|
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
});
|
});
|
||||||
} else if (item === rentInItem) {
|
} else if (item === rentInItem) {
|
||||||
mp.events.callRemote("CLIENT:House_RentInHouse");
|
game.events.callServer("House_RentInHouse");
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
} else if (item === cancelOwnRentalItem) {
|
} else if (item === cancelOwnRentalItem) {
|
||||||
mp.events.callRemote("CLIENT:House_CancelOwnRental");
|
game.events.callServer("House_CancelOwnRental");
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
} else if (item === sellHouseItem) {
|
} else if (item === sellHouseItem) {
|
||||||
mp.events.callRemote("CLIENT:House_SellHouse");
|
game.events.callServer("House_SellHouse");
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
houseMenu.MenuClose.on(() => {
|
houseMenu.MenuClose.on(() => {
|
||||||
globalData.InMenu = false;
|
game.ui.inMenu = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.events.add("SERVER:CloseHouseMenu", () => {
|
game.events.add("SERVER:CloseHouseMenu", () => {
|
||||||
mp.game.ui.clearHelp(true);
|
game.ui.clearHelpText();
|
||||||
if (houseMenu != null) {
|
if (houseMenu != null) {
|
||||||
houseMenu.Close();
|
houseMenu.Close();
|
||||||
}
|
}
|
||||||
|
game.events.unbindKey(Key.E, false, keyPressHandler);
|
||||||
if (keyBound) {
|
});
|
||||||
keyBound = false;
|
|
||||||
mp.keys.unbind(0x45, false, keyPressHandler);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import moneyFormat from "../moneyformat";
|
import moneyFormat from "../moneyformat";
|
||||||
|
|
||||||
export default function (globalData: GlobalData): void {
|
export default function (globalData: IGlobalData): void {
|
||||||
var currentdate;
|
var currentdate;
|
||||||
var dateString;
|
var dateString;
|
||||||
var timeString;
|
var timeString;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default function interiors(globalData: GlobalData) {
|
export default function interiors(globalData: IGlobalData) {
|
||||||
|
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
var interiorId = -1;
|
var interiorId = -1;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { isNull } from "util";
|
import { isNull } from "util";
|
||||||
|
|
||||||
|
|
||||||
export default function licenses(globalData: GlobalData): void {
|
export default function licenses(globalData: IGlobalData): void {
|
||||||
|
|
||||||
var licenseBrowser: BrowserMp = null;
|
var licenseBrowser: BrowserMp = null;
|
||||||
var licenseTimer;
|
var licenseTimer;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @copyright (c) 2008 - 2018 Life of German
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function playerList(globalData: GlobalData): void {
|
export default function playerList(globalData: IGlobalData): void {
|
||||||
|
|
||||||
var playerlistBrowser: BrowserMp = null;
|
var playerlistBrowser: BrowserMp = null;
|
||||||
var pList;
|
var pList;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ let lastkilometer: Number = 0;
|
|||||||
let lastPrice: Number = 0;
|
let lastPrice: Number = 0;
|
||||||
let totalPrice: Number = 0;
|
let totalPrice: Number = 0;
|
||||||
var myVar;
|
var myVar;
|
||||||
export default function taximeterInput(globalData: GlobalData) {
|
export default function taximeterInput(globalData: IGlobalData) {
|
||||||
mp.events.add("CLIENT:setFarePrice", () => {
|
mp.events.add("CLIENT:setFarePrice", () => {
|
||||||
/*
|
/*
|
||||||
var textBox = new InputHelper("Setzen Sie ihre Fahrtkosten [2 - 50 $/km]", globalData);
|
var textBox = new InputHelper("Setzen Sie ihre Fahrtkosten [2 - 50 $/km]", globalData);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const UIMenuListItem = NativeUI.UIMenuListItem;
|
|||||||
const Point = NativeUI.Point;
|
const Point = NativeUI.Point;
|
||||||
const ItemsCollection = NativeUI.ItemsCollection;
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
|
|
||||||
export default function vehicleMenu(globalData: GlobalData) {
|
export default function vehicleMenu(globalData: IGlobalData) {
|
||||||
let menuBrowser: BrowserMp = null;
|
let menuBrowser: BrowserMp = null;
|
||||||
|
|
||||||
mp.events.add('ToggleVehicleMenu', () => {
|
mp.events.add('ToggleVehicleMenu', () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default function wanteds(globalData: GlobalData) {
|
export default function wanteds(globalData: IGlobalData) {
|
||||||
var browser = mp.browsers.new("package://assets/html/wanteds/index.html");
|
var browser = mp.browsers.new("package://assets/html/wanteds/index.html");
|
||||||
|
|
||||||
mp.events.add("SERVER:SetWanteds", (count: number) => {
|
mp.events.add("SERVER:SetWanteds", (count: number) => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Point = NativeUI.Point;
|
|||||||
const ItemsCollection = NativeUI.ItemsCollection;
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
const Color = NativeUI.Color;
|
const Color = NativeUI.Color;
|
||||||
|
|
||||||
export default function itemShopList(globalData: GlobalData) {
|
export default function itemShopList(globalData: IGlobalData) {
|
||||||
|
|
||||||
|
|
||||||
const localPlayer = mp.players.local;
|
const localPlayer = mp.players.local;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const ItemsCollection = NativeUI.ItemsCollection;
|
|||||||
const Color = NativeUI.Color;
|
const Color = NativeUI.Color;
|
||||||
|
|
||||||
|
|
||||||
export default function clotheShopList(globalData: GlobalData) {
|
export default function clotheShopList(globalData: IGlobalData) {
|
||||||
const categoryTitles = {
|
const categoryTitles = {
|
||||||
clothes: {
|
clothes: {
|
||||||
1: "Masks",
|
1: "Masks",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function drivingSchoolList(globalData: GlobalData) {
|
export default function drivingSchoolList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var drivingMenu: NativeUI.Menu;
|
var drivingMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function elevatorList(globalData: GlobalData) {
|
export default function elevatorList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var elevatorMenu: NativeUI.Menu;
|
var elevatorMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const Point = NativeUI.Point;
|
|||||||
const ItemsCollection = NativeUI.ItemsCollection;
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
const Color = NativeUI.Color;
|
const Color = NativeUI.Color;
|
||||||
|
|
||||||
export default function factionInteraction(globalData: GlobalData) {
|
export default function factionInteraction(globalData: IGlobalData) {
|
||||||
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
var screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||||
var player = mp.players.local;
|
var player = mp.players.local;
|
||||||
var tasks;
|
var tasks;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const Color = NativeUI.Color;
|
|||||||
|
|
||||||
import { getStreetName, getZoneName } from '../streetnames';
|
import { getStreetName, getZoneName } from '../streetnames';
|
||||||
|
|
||||||
export default function (globalData: GlobalData) {
|
export default function (globalData: IGlobalData) {
|
||||||
|
|
||||||
var menuClose = false;
|
var menuClose = false;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ let eY = sY - 0.1;
|
|||||||
let sizeMul = 0.08;
|
let sizeMul = 0.08;
|
||||||
let yMul = 1.8;
|
let yMul = 1.8;
|
||||||
|
|
||||||
export default function playerInteraction(globalData: GlobalData) {
|
export default function playerInteraction(globalData: IGlobalData) {
|
||||||
|
|
||||||
var nearbyPlayers = [];
|
var nearbyPlayers = [];
|
||||||
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ cancelItem.BackColor = new Color(213, 0, 0);
|
|||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
|
|
||||||
export default function busRouteList(globalData: GlobalData) {
|
export default function busRouteList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var routeMenu: NativeUI.Menu;
|
var routeMenu: NativeUI.Menu;
|
||||||
var routeTexts;
|
var routeTexts;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ cancelItem.BackColor = new Color(213, 0, 0);
|
|||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
|
|
||||||
export default function PilotRouteList(globalData: GlobalData) {
|
export default function PilotRouteList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var routeMenu: NativeUI.Menu;
|
var routeMenu: NativeUI.Menu;
|
||||||
var routeTexts;
|
var routeTexts;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as NativeUI from '../libs/NativeUI';
|
import * as NativeUI from '../libs/NativeUI';
|
||||||
|
|
||||||
export default function (globalData: GlobalData) {
|
export default function (globalData: IGlobalData) {
|
||||||
|
|
||||||
mp.events.add("SERVER:Job_ShowJobMenu", (jobName: string, data: any) => {
|
mp.events.add("SERVER:Job_ShowJobMenu", (jobName: string, data: any) => {
|
||||||
if (globalData.InMenu) return;
|
if (globalData.InMenu) return;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @copyright (c) 2008 - 2018 Life of German
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function(globalData: GlobalData): void {
|
export default function(globalData: IGlobalData): void {
|
||||||
var loginBrowser: BrowserMp;
|
var loginBrowser: BrowserMp;
|
||||||
var loginCam: CameraMp = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
|
var loginCam: CameraMp = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function jailList(globalData: GlobalData) {
|
export default function jailList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var jailMenu: NativeUI.Menu;
|
var jailMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function dutyCloth(globalData: GlobalData) {
|
export default function dutyCloth(globalData: IGlobalData) {
|
||||||
|
|
||||||
var dutyMenu: NativeUI.Menu;
|
var dutyMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
const player = mp.players.local;
|
const player = mp.players.local;
|
||||||
|
|
||||||
export default function keys(globalData: GlobalData) {
|
export default function keys(globalData: IGlobalData) {
|
||||||
|
|
||||||
var showInventory = false;
|
var showInventory = false;
|
||||||
var showGui = true;
|
var showGui = true;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function reportList(globalData: GlobalData) {
|
export default function reportList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var reportMenu: NativeUI.Menu;
|
var reportMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let cancelItem = new UIMenuItem("Abbrechen", "");
|
|||||||
cancelItem.BackColor = new Color(213, 0, 0);
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
export default function weaponList(globalData: GlobalData) {
|
export default function weaponList(globalData: IGlobalData) {
|
||||||
|
|
||||||
var weaponMenu: NativeUI.Menu;
|
var weaponMenu: NativeUI.Menu;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
let player = mp.players.local;
|
let player = mp.players.local;
|
||||||
|
|
||||||
export default function speedometer(globalData: GlobalData) {
|
export default function speedometer(globalData: IGlobalData) {
|
||||||
var dictLoaded = false;
|
var dictLoaded = false;
|
||||||
|
|
||||||
var lockStatus = false;
|
var lockStatus = false;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const UIMenuItem = NativeUI.UIMenuItem;
|
|||||||
const BadgeStyle = NativeUI.BadgeStyle;
|
const BadgeStyle = NativeUI.BadgeStyle;
|
||||||
const Point = NativeUI.Point;
|
const Point = NativeUI.Point;
|
||||||
|
|
||||||
export default function tuning(globalData: GlobalData) {
|
export default function tuning(globalData: IGlobalData) {
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
|
|
||||||
const disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
|
const disableInput = [75, 278, 279, 280, 281, 23, 59, 60, 71, 72, 74];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @copyright (c) 2008 - 2019 Life of German
|
* @copyright (c) 2008 - 2019 Life of German
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function voice(globalData: GlobalData) {
|
export default function voice(globalData: IGlobalData) {
|
||||||
|
|
||||||
let dictLoaded = false;
|
let dictLoaded = false;
|
||||||
const Use3d = true;
|
const Use3d = true;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { IUi, IBrowser } from "../../game";
|
import { IUi, IBrowser } from "../../game";
|
||||||
import { Menu } from "../../libs/NativeUI/index";
|
import { Menu } from "../../libs/NativeUI/index";
|
||||||
|
import { GlobalData } from "../..";
|
||||||
|
|
||||||
export default class RageUi implements IUi {
|
export default class RageUi implements IUi {
|
||||||
setHelpText(text: string): void {
|
setHelpText(text: string): void {
|
||||||
@@ -11,9 +12,17 @@ export default class RageUi implements IUi {
|
|||||||
mp.game.ui.clearHelp(true);
|
mp.game.ui.clearHelp(true);
|
||||||
}
|
}
|
||||||
private _inMenu: boolean = false;
|
private _inMenu: boolean = false;
|
||||||
|
private _inChat: boolean = false;
|
||||||
private _activeMenu: Menu = null;
|
private _activeMenu: Menu = null;
|
||||||
|
|
||||||
inChat: boolean = false;
|
get inChat() {
|
||||||
|
return this._inChat || GlobalData.InChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
set inChat(value: boolean) {
|
||||||
|
this._inChat = value;
|
||||||
|
GlobalData.InChat = value;
|
||||||
|
}
|
||||||
|
|
||||||
get activeMenu(): Menu {
|
get activeMenu(): Menu {
|
||||||
return this._activeMenu;
|
return this._activeMenu;
|
||||||
@@ -34,11 +43,12 @@ export default class RageUi implements IUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get inMenu() {
|
get inMenu() {
|
||||||
return this._inMenu;
|
return this._inMenu || GlobalData.InMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
set inMenu(value: boolean) {
|
set inMenu(value: boolean) {
|
||||||
this._inMenu = value;
|
this._inMenu = value;
|
||||||
|
GlobalData.InMenu = value;
|
||||||
this.toggleChat(!value);
|
this.toggleChat(!value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
ReallifeGamemode.Client/global.d.ts
vendored
2
ReallifeGamemode.Client/global.d.ts
vendored
@@ -1,4 +1,4 @@
|
|||||||
declare interface GlobalData {
|
declare interface IGlobalData {
|
||||||
InTuning: boolean,
|
InTuning: boolean,
|
||||||
HideGui: boolean,
|
HideGui: boolean,
|
||||||
InMenu: boolean,
|
InMenu: boolean,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { IGame } from './game';
|
import { IGame } from './game';
|
||||||
import RageGame from './core/rage-mp/game';
|
import RageGame from './core/rage-mp/game';
|
||||||
|
|
||||||
let globalData: GlobalData = {
|
let globalData: IGlobalData = {
|
||||||
InTuning: false,
|
InTuning: false,
|
||||||
HideGui: false,
|
HideGui: false,
|
||||||
InChat: false,
|
InChat: false,
|
||||||
@@ -26,6 +26,9 @@ let globalData: GlobalData = {
|
|||||||
|
|
||||||
const game: IGame = new RageGame();
|
const game: IGame = new RageGame();
|
||||||
export default game;
|
export default game;
|
||||||
|
export {
|
||||||
|
globalData as GlobalData
|
||||||
|
}
|
||||||
|
|
||||||
game.events.onPlayerCommand((cmd) => {
|
game.events.onPlayerCommand((cmd) => {
|
||||||
game.events.callServer("Command", cmd.split(' '));
|
game.events.callServer("Command", cmd.split(' '));
|
||||||
@@ -35,8 +38,7 @@ var inMenu = false;
|
|||||||
|
|
||||||
mp.game.vehicle.defaultEngineBehaviour = false;
|
mp.game.vehicle.defaultEngineBehaviour = false;
|
||||||
|
|
||||||
import house from './Gui/house';
|
require('./Gui/house');
|
||||||
house(globalData);
|
|
||||||
|
|
||||||
import vehicleEntering from './vehiclesync/entering';
|
import vehicleEntering from './vehiclesync/entering';
|
||||||
vehicleEntering(globalData);
|
vehicleEntering(globalData);
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
export default class InputHelper {
|
import { GlobalData } from "..";
|
||||||
|
|
||||||
|
export default class InputHelper {
|
||||||
private title: string;
|
private title: string;
|
||||||
private value: string;
|
private value: string;
|
||||||
private created: boolean;
|
private created: boolean;
|
||||||
private browser: BrowserMp;
|
private browser: BrowserMp;
|
||||||
private data: GlobalData;
|
private data: IGlobalData;
|
||||||
|
|
||||||
constructor(title: string, globalData: GlobalData) {
|
constructor(title: string, globalData?: IGlobalData) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.data = globalData;
|
this.data = globalData || GlobalData;
|
||||||
|
|
||||||
this.cefTitleCall = this.cefTitleCall.bind(this);
|
this.cefTitleCall = this.cefTitleCall.bind(this);
|
||||||
mp.events.add('cef_request_title', this.cefTitleCall);
|
mp.events.add('cef_request_title', this.cefTitleCall);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
export default function inventory(globalData: GlobalData): void {
|
export default function inventory(globalData: IGlobalData): void {
|
||||||
|
|
||||||
var invBrowser: BrowserMp = null;
|
var invBrowser: BrowserMp = null;
|
||||||
var itemIdArr;
|
var itemIdArr;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default function gangwarHandle(globalData: GlobalData) {
|
export default function gangwarHandle(globalData: IGlobalData) {
|
||||||
|
|
||||||
function inside(point, vs) {
|
function inside(point, vs) {
|
||||||
let x = point[0],
|
let x = point[0],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as NativeUI from '../libs/NativeUI';
|
import * as NativeUI from '../libs/NativeUI';
|
||||||
import InputHelper from '../inputhelper';
|
import InputHelper from '../inputhelper';
|
||||||
|
|
||||||
export default function checkpointHandle(globalData: GlobalData) {
|
export default function checkpointHandle(globalData: IGlobalData) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var myVar;
|
var myVar;
|
||||||
var posCp;
|
var posCp;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const ItemsCollection = NativeUI.ItemsCollection;
|
|||||||
const Color = NativeUI.Color;
|
const Color = NativeUI.Color;
|
||||||
const ListItem = NativeUI.ListItem;
|
const ListItem = NativeUI.ListItem;
|
||||||
|
|
||||||
export default function drivingSchoolHandle(globalData: GlobalData) {
|
export default function drivingSchoolHandle(globalData: IGlobalData) {
|
||||||
|
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
var mainMenu: NativeUI.Menu;
|
var mainMenu: NativeUI.Menu;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const ItemsCollection = NativeUI.ItemsCollection;
|
|||||||
const Color = NativeUI.Color;
|
const Color = NativeUI.Color;
|
||||||
const ListItem = NativeUI.ListItem;
|
const ListItem = NativeUI.ListItem;
|
||||||
|
|
||||||
export default function planeSchoolHandle(globalData: GlobalData) {
|
export default function planeSchoolHandle(globalData: IGlobalData) {
|
||||||
|
|
||||||
var keyBound = false;
|
var keyBound = false;
|
||||||
var mainMenu: NativeUI.Menu;
|
var mainMenu: NativeUI.Menu;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default function vehicleEntering(globalData: GlobalData) {
|
export default function vehicleEntering(globalData: IGlobalData) {
|
||||||
mp.events.add('render', () => {
|
mp.events.add('render', () => {
|
||||||
const controls = mp.game.controls;
|
const controls = mp.game.controls;
|
||||||
if(globalData.InChat) return;
|
if(globalData.InChat) return;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
using ReallifeGamemode.Server.Core.RageMP;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Database.Entities
|
namespace ReallifeGamemode.Database.Entities
|
||||||
{
|
{
|
||||||
@@ -28,11 +30,17 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Vector3 Position => new Vector3(X, Y, Z);
|
public Vector3 Position => new Vector3(X, Y, Z);
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public Position NewPosition => new Position(X, Y, Z);
|
||||||
|
|
||||||
[ForeignKey("Owner")]
|
[ForeignKey("Owner")]
|
||||||
public int? OwnerId { get; set; }
|
public int? OwnerId { get; set; }
|
||||||
public User Owner { get; set; }
|
public User Owner { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Player User => Owner?.Player;
|
public Player User => Owner?.Player;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public IPlayer OwnerPlayer => new RagePlayer(User);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
using ReallifeGamemode.Server.Core.RageMP;
|
||||||
using ReallifeGamemode.Server.Types;
|
using ReallifeGamemode.Server.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,6 +106,9 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
get => NAPI.Pools.GetAllPlayers().Where(c => c.Name.ToLower() == this.Name.ToLower()).FirstOrDefault();
|
get => NAPI.Pools.GetAllPlayers().Where(c => c.Name.ToLower() == this.Name.ToLower()).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public IPlayer NewPlayer => new RagePlayer(Player);
|
||||||
|
|
||||||
public override string BankAccountName => Name;
|
public override string BankAccountName => Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ReallifeGamemode.Server.Core.API\ReallifeGamemode.Server.Core.API.csproj" />
|
||||||
|
<ProjectReference Include="..\ReallifeGamemode.Server.Core.RageMP\ReallifeGamemode.Server.Core.RageMP.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Types\ReallifeGamemode.Server.Types.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Types\ReallifeGamemode.Server.Types.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Services\ReallifeGamemode.Services.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Services\ReallifeGamemode.Services.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace ReallifeGamemode.Server.Core.API
|
|||||||
|
|
||||||
ITextLabelAPI TextLabel { get; }
|
ITextLabelAPI TextLabel { get; }
|
||||||
|
|
||||||
|
IBlipAPI Blip { get; }
|
||||||
|
|
||||||
void DisableDefaultCommandErrorMessages();
|
void DisableDefaultCommandErrorMessages();
|
||||||
|
|
||||||
void DisableDefaultSpawnBehavior();
|
void DisableDefaultSpawnBehavior();
|
||||||
@@ -28,5 +30,7 @@ namespace ReallifeGamemode.Server.Core.API
|
|||||||
void SetTime(int hour, int minute, int second);
|
void SetTime(int hour, int minute, int second);
|
||||||
|
|
||||||
void TriggerClientEventForAll(string eventName, params object[] args);
|
void TriggerClientEventForAll(string eventName, params object[] args);
|
||||||
|
|
||||||
|
TEntity ToEntity<TEntity>(ushort handle) where TEntity : class, IEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
ReallifeGamemode.Server.Core.API/IBlip.cs
Normal file
10
ReallifeGamemode.Server.Core.API/IBlip.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.API
|
||||||
|
{
|
||||||
|
public interface IBlip : IEntity
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
11
ReallifeGamemode.Server.Core.API/IBlipAPI.cs
Normal file
11
ReallifeGamemode.Server.Core.API/IBlipAPI.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.API
|
||||||
|
{
|
||||||
|
public interface IBlipAPI
|
||||||
|
{
|
||||||
|
IBlip CreateBlip(uint sprite, Position position, string name, byte color, byte alpha, float scale, float drawDistance, bool shortRange);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ namespace ReallifeGamemode.Server.Core.API
|
|||||||
|
|
||||||
double Heading { get; set; }
|
double Heading { get; set; }
|
||||||
|
|
||||||
|
uint Dimension { get; set; }
|
||||||
|
|
||||||
void Remove();
|
void Remove();
|
||||||
|
|
||||||
void SetSharedData<T>(string key, T data);
|
void SetSharedData<T>(string key, T data);
|
||||||
|
|||||||
@@ -22,7 +22,19 @@ namespace ReallifeGamemode.Server.Core.API
|
|||||||
|
|
||||||
VehicleSeat VehicleSeat { get; }
|
VehicleSeat VehicleSeat { get; }
|
||||||
|
|
||||||
void SendMessage(string message, ChatPrefix prefix = ChatPrefix.None) => SendRawMessage(prefix.GetValue() + message);
|
void SendMessage(string message, ChatPrefix prefix = ChatPrefix.None)
|
||||||
|
{
|
||||||
|
if (!message.EndsWith("!") || !message.EndsWith(".") || !message.EndsWith("?"))
|
||||||
|
{
|
||||||
|
message += prefix switch
|
||||||
|
{
|
||||||
|
ChatPrefix.Error => "!",
|
||||||
|
ChatPrefix.Usage => string.Empty,
|
||||||
|
_ => ".",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
SendRawMessage(prefix.GetValue() + message);
|
||||||
|
}
|
||||||
|
|
||||||
void SendRawMessage(string message);
|
void SendRawMessage(string message);
|
||||||
|
|
||||||
|
|||||||
19
ReallifeGamemode.Server.Core.Extensions/IntegerExtensions.cs
Normal file
19
ReallifeGamemode.Server.Core.Extensions/IntegerExtensions.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.Extensions
|
||||||
|
{
|
||||||
|
public static class IntegerExtensions
|
||||||
|
{
|
||||||
|
public static string ToMoneyString(this int? money)
|
||||||
|
{
|
||||||
|
return ToMoneyString(money ?? 0);
|
||||||
|
}
|
||||||
|
public static string ToMoneyString(this int money)
|
||||||
|
{
|
||||||
|
return "$" + string.Format(new CultureInfo("de-DE"), "{0:C0}", money).Replace("€", "").Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
using ReallifeGamemode.Database.Models;
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Core.API;
|
using ReallifeGamemode.Server.Core.API;
|
||||||
@@ -10,14 +11,26 @@ namespace ReallifeGamemode.Server.Core.Extensions
|
|||||||
{
|
{
|
||||||
public static class PlayerExtensions
|
public static class PlayerExtensions
|
||||||
{
|
{
|
||||||
public static User GetUser(this IPlayer player, DatabaseContext dbContext)
|
public static User GetUser(this IPlayer player, DatabaseContext dbContext, bool bankAccount = false, bool faction = false)
|
||||||
{
|
{
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbContext.Users.Where(u => u.Name == player.Name).FirstOrDefault();
|
var user = dbContext.Users.Where(u => u.Name == player.Name);
|
||||||
|
|
||||||
|
if (bankAccount)
|
||||||
|
{
|
||||||
|
user = user.Include(u => u.BankAccount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (faction)
|
||||||
|
{
|
||||||
|
user = user.Include(u => u.Faction);
|
||||||
|
}
|
||||||
|
|
||||||
|
return user.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdminLevel GetAdminLevel(this IPlayer player, DatabaseContext dbContext)
|
public static AdminLevel GetAdminLevel(this IPlayer player, DatabaseContext dbContext)
|
||||||
@@ -39,5 +52,7 @@ namespace ReallifeGamemode.Server.Core.Extensions
|
|||||||
{
|
{
|
||||||
return player.GetAdminLevel(dbContext) >= level;
|
return player.GetAdminLevel(dbContext) >= level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsLoggedIn(this IPlayer player) => player.GetSharedData("isLoggedIn", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace ReallifeGamemode.Server.Core.RageMP
|
|||||||
|
|
||||||
public ITextLabelAPI TextLabel => new RageTextLabelAPI();
|
public ITextLabelAPI TextLabel => new RageTextLabelAPI();
|
||||||
|
|
||||||
|
public IBlipAPI Blip => new RageBlipAPI();
|
||||||
|
|
||||||
public void DisableDefaultCommandErrorMessages()
|
public void DisableDefaultCommandErrorMessages()
|
||||||
{
|
{
|
||||||
NAPI.Server.SetCommandErrorMessage(null);
|
NAPI.Server.SetCommandErrorMessage(null);
|
||||||
@@ -61,5 +63,18 @@ namespace ReallifeGamemode.Server.Core.RageMP
|
|||||||
{
|
{
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:" + eventName, args);
|
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:" + eventName, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TEntity ToEntity<TEntity>(ushort handle) where TEntity : class, IEntity
|
||||||
|
{
|
||||||
|
return typeof(TEntity).Name switch
|
||||||
|
{
|
||||||
|
"IPlayer" => new RagePlayer(new NetHandle(handle, EntityType.Player).Entity<Player>()) as TEntity,
|
||||||
|
"IVehicle" => new RageVehicle(new NetHandle(handle, EntityType.Vehicle).Entity<Vehicle>()) as TEntity,
|
||||||
|
"IMarker" => new RageMarker(new NetHandle(handle, EntityType.Marker).Entity<Marker>()) as TEntity,
|
||||||
|
"ITextLabel" => new RageTextLabel(new NetHandle(handle, EntityType.TextLabel).Entity<TextLabel>()) as TEntity,
|
||||||
|
"IColShape" => new RageColShape(new NetHandle(handle, EntityType.Colshape).Entity<ColShape>()) as TEntity,
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
ReallifeGamemode.Server.Core.RageMP/RageBlip.cs
Normal file
18
ReallifeGamemode.Server.Core.RageMP/RageBlip.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.RageMP
|
||||||
|
{
|
||||||
|
class RageBlip : RageEntity, IBlip
|
||||||
|
{
|
||||||
|
private Blip blip;
|
||||||
|
|
||||||
|
public RageBlip(Blip blip) : base(blip)
|
||||||
|
{
|
||||||
|
this.blip = blip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
ReallifeGamemode.Server.Core.RageMP/RageBlipAPI.cs
Normal file
16
ReallifeGamemode.Server.Core.RageMP/RageBlipAPI.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.RageMP
|
||||||
|
{
|
||||||
|
class RageBlipAPI : IBlipAPI
|
||||||
|
{
|
||||||
|
public IBlip CreateBlip(uint sprite, Position position, string name, byte color, byte alpha, float scale, float drawDistance, bool shortRange)
|
||||||
|
{
|
||||||
|
return new RageBlip(NAPI.Blip.CreateBlip(sprite, position.ToVector3(), scale, color, name, alpha, drawDistance, shortRange));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@ namespace ReallifeGamemode.Server.Core.RageMP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint Dimension { get => entity.Dimension; set => entity.Dimension = value; }
|
||||||
|
|
||||||
public RageEntity(GTANetworkAPI.Entity rageEntity)
|
public RageEntity(GTANetworkAPI.Entity rageEntity)
|
||||||
{
|
{
|
||||||
entity = rageEntity;
|
entity = rageEntity;
|
||||||
@@ -57,7 +59,9 @@ namespace ReallifeGamemode.Server.Core.RageMP
|
|||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (entity.GetSharedData<string>(key)).DeserializeJson<T>();
|
var data = entity.GetSharedData<string>(key);
|
||||||
|
|
||||||
|
return data.DeserializeJson<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
144
ReallifeGamemode.Server.Core/Commands/Admin/HouseCommand.cs
Normal file
144
ReallifeGamemode.Server.Core/Commands/Admin/HouseCommand.cs
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
using ReallifeGamemode.Server.Core.Extensions;
|
||||||
|
using ReallifeGamemode.Server.Core.Managers;
|
||||||
|
using ReallifeGamemode.Server.Types;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.Commands.Admin
|
||||||
|
{
|
||||||
|
class HouseCommand : AdminCommand
|
||||||
|
{
|
||||||
|
public override string CommandName => "house";
|
||||||
|
|
||||||
|
protected override AdminLevel AdminLevel => AdminLevel.HEADADMIN;
|
||||||
|
|
||||||
|
public override string HelpText => "[add / remove / price / type / reloadhouses]";
|
||||||
|
|
||||||
|
public void Handle(IPlayer player, string option1, string option2 = null)
|
||||||
|
{
|
||||||
|
using var dbContext = GetDbContext();
|
||||||
|
|
||||||
|
option1 = option1?.ToLower();
|
||||||
|
|
||||||
|
var houseManager = Main.GetScript<HouseManager>();
|
||||||
|
|
||||||
|
if (option1 == "add")
|
||||||
|
{
|
||||||
|
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||||
|
if (nearHouse != null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In der Nähe ist schon ein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = new House()
|
||||||
|
{
|
||||||
|
Price = 0,
|
||||||
|
Type = "Haus",
|
||||||
|
X = (float)player.Position.X,
|
||||||
|
Y = (float)player.Position.Y,
|
||||||
|
Z = (float)player.Position.Z
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.Houses.Add(house);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
houseManager.LoadHouse(house);
|
||||||
|
|
||||||
|
player.SendNotification("Das Haus wurde erstellt");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (option1 == "remove")
|
||||||
|
{
|
||||||
|
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||||
|
if (nearHouse == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nearHouse.OwnerId != null)
|
||||||
|
{
|
||||||
|
dbContext.Users.Where(u => u.Id == nearHouse.OwnerId).First().HouseId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (HouseRental rental in dbContext.HouseRentals.Include(r => r.User).Where(r => r.HouseId == nearHouse.Id))
|
||||||
|
{
|
||||||
|
rental.User.NewPlayer.SendRawMessage("!{#81F7BE}* Dein Mietvertrag wurde administrativ aufgelöst!");
|
||||||
|
dbContext.HouseRentals.Remove(rental);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.Houses.Remove(nearHouse);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
houseManager.RemoveHouse(nearHouse);
|
||||||
|
|
||||||
|
player.SendNotification("Das Haus wurde gelöscht");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (option1 == "price")
|
||||||
|
{
|
||||||
|
if (!int.TryParse(option2, out int price))
|
||||||
|
{
|
||||||
|
player.SendMessage("/house price [Price]", ChatPrefix.Usage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||||
|
if (nearHouse == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nearHouse.Price = price;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
houseManager.RemoveHouse(nearHouse);
|
||||||
|
houseManager.LoadHouse(nearHouse);
|
||||||
|
|
||||||
|
player.SendNotification("Der Hauspreis wurde gesetzt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (option1 == "type")
|
||||||
|
{
|
||||||
|
if (option2 == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("/house type [Type]", ChatPrefix.Usage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House nearHouse = houseManager.GetNearHouse(player.Position, dbContext);
|
||||||
|
if (nearHouse == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In deiner Nähe befindet sich kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nearHouse.Type = option2;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
houseManager.RemoveHouse(nearHouse);
|
||||||
|
houseManager.LoadHouse(nearHouse);
|
||||||
|
|
||||||
|
player.SendNotification("Der Haustyp wurde gesetzt");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (option1 == "reloadhouses")
|
||||||
|
{
|
||||||
|
houseManager.ReloadAllHouses();
|
||||||
|
player.SendNotification("Alle Häuser wurden neu geladen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.SendMessage("/house [add / remove / price / type / reloadhouses]", ChatPrefix.Usage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,6 @@ namespace ReallifeGamemode.Server.Core.Commands
|
|||||||
Log = LogManager.GetLogger(this.GetType());
|
Log = LogManager.GetLogger(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
protected DatabaseContext GetDbContext(bool useLoggerFactory = true) => Main.GetDbContext(useLoggerFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ReallifeGamemode.Server.Core.API;
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
using ReallifeGamemode.Server.Core.Extensions;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Core.Commands.User
|
namespace ReallifeGamemode.Server.Core.Commands.User
|
||||||
{
|
{
|
||||||
@@ -9,7 +10,7 @@ namespace ReallifeGamemode.Server.Core.Commands.User
|
|||||||
{
|
{
|
||||||
public override bool CanExecute(IPlayer player)
|
public override bool CanExecute(IPlayer player)
|
||||||
{
|
{
|
||||||
return player.GetSharedData("loggedIn", false);
|
return player.IsLoggedIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace ReallifeGamemode.Server.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatabaseContext GetDbContext(bool useLoggerFactory = false)
|
public static DatabaseContext GetDbContext(bool useLoggerFactory = true)
|
||||||
{
|
{
|
||||||
return new DatabaseContext(useLoggerFactory);
|
return new DatabaseContext(useLoggerFactory);
|
||||||
}
|
}
|
||||||
|
|||||||
407
ReallifeGamemode.Server.Core/Managers/HouseManager.cs
Normal file
407
ReallifeGamemode.Server.Core/Managers/HouseManager.cs
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using ReallifeGamemode.Server.Core.API;
|
||||||
|
using ReallifeGamemode.Server.Types;
|
||||||
|
using ReallifeGamemode.Server.Core.Extensions;
|
||||||
|
using System.Linq;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
|
using ReallifeGamemode.Server.Common;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Core.Managers
|
||||||
|
{
|
||||||
|
class HouseManager : Script
|
||||||
|
{
|
||||||
|
private readonly Dictionary<int, IMarker> houseMarkers = new Dictionary<int, IMarker>();
|
||||||
|
private readonly Dictionary<int, ITextLabel> houseLabels = new Dictionary<int, ITextLabel>();
|
||||||
|
private readonly Dictionary<int, IColShape> houseColShapes = new Dictionary<int, IColShape>();
|
||||||
|
private readonly Dictionary<int, IBlip> houseBlips = new Dictionary<int, IBlip>();
|
||||||
|
|
||||||
|
private readonly Dictionary<int, List<IPlayer>> playerInColShape = new Dictionary<int, List<IPlayer>>();
|
||||||
|
|
||||||
|
public HouseManager()
|
||||||
|
{
|
||||||
|
EventHandler.RegisterClientEvent("House_BuyHouse", HouseManagerBuyHouseEvent);
|
||||||
|
EventHandler.RegisterClientEvent("House_SetRentalFee", HouseManagerSetRentalFeeEvent);
|
||||||
|
EventHandler.RegisterClientEvent("House_CancelUserRental", HouseManagerCancelUserRentalEvent);
|
||||||
|
EventHandler.RegisterClientEvent("House_RentInHouse", HouseManagerRentInHouseEvent);
|
||||||
|
EventHandler.RegisterClientEvent("House_CancelOwnRental", HouseManagerCancelOwnRentalEvent);
|
||||||
|
EventHandler.RegisterClientEvent("House_SellHouse", HouseManagerSellHouseEvent);
|
||||||
|
|
||||||
|
LoadHouses();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadHouses()
|
||||||
|
{
|
||||||
|
using var dbContext = GetDbContext();
|
||||||
|
var houses = dbContext.Houses.Include(h => h.Owner);
|
||||||
|
foreach (House house in houses)
|
||||||
|
{
|
||||||
|
LoadHouse(house);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadHouse(House house)
|
||||||
|
{
|
||||||
|
Position housePos = new Position(house.X, house.Y, house.Z);
|
||||||
|
|
||||||
|
playerInColShape[house.Id] = new List<IPlayer>();
|
||||||
|
|
||||||
|
houseMarkers[house.Id] = Api.Marker.CreateMarker(MarkerType.VerticalCylinder, housePos.Subtract(new Position(0, 0, 1.7)), new Position(), new Position(), 1.6f, Color.White);
|
||||||
|
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||||
|
|
||||||
|
if (house.OwnerId != null)
|
||||||
|
{
|
||||||
|
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
||||||
|
|
||||||
|
if (house.RentalFee != 0)
|
||||||
|
{
|
||||||
|
text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
||||||
|
}
|
||||||
|
|
||||||
|
houseLabels[house.Id] = Api.TextLabel.CreateTextLabel(text, housePos, 10f, 1f, 0, new Color(255, 255, 255));
|
||||||
|
|
||||||
|
if (house.Price != 0)
|
||||||
|
{
|
||||||
|
houseColShapes[house.Id] = Api.ColShape.CreateCyclinder(housePos.Subtract(new Position(0, 0, 2)), 4.0f, 2f);
|
||||||
|
|
||||||
|
houseColShapes[house.Id].OnEntityEnter += HouseManager_OnEntityEnterColShape;
|
||||||
|
houseColShapes[house.Id].OnEntityExit += HouseManager_OnEntityExitColShape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManager_OnEntityExitColShape(IColShape colShape, IPlayer client)
|
||||||
|
{
|
||||||
|
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||||
|
if (!houseColShapes.ContainsValue(colShape))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int houseId = houseColShapes.Where(p => p.Value.Handle == colShape.Handle).FirstOrDefault().Key;
|
||||||
|
playerInColShape[houseId].Remove(client);
|
||||||
|
|
||||||
|
client.TriggerEvent("CloseHouseMenu");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManager_OnEntityEnterColShape(IColShape colShape, IPlayer client)
|
||||||
|
{
|
||||||
|
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||||
|
if (!houseColShapes.ContainsValue(colShape))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var dbContext = GetDbContext())
|
||||||
|
{
|
||||||
|
int houseId = houseColShapes.Where(p => p.Value.Handle == colShape.Handle).FirstOrDefault().Key;
|
||||||
|
playerInColShape[houseId].Add(client);
|
||||||
|
House house = GetHouseById(houseId, dbContext);
|
||||||
|
User user = client.GetUser(dbContext);
|
||||||
|
|
||||||
|
client.TriggerEvent("ShowHouseMenu");
|
||||||
|
SendPlayerHouseData(client, house);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public House GetHouseById(int id, DatabaseContext dbContext)
|
||||||
|
{
|
||||||
|
return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendPlayerHouseData(IPlayer player, House house)
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
var userHouseStatus = -1;
|
||||||
|
|
||||||
|
if (house.OwnerId == null) userHouseStatus = 0;
|
||||||
|
else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
||||||
|
else if (dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
||||||
|
|
||||||
|
var rentals = dbContext.HouseRentals.Where(h => h.HouseId == house.Id).Include(h => h.User).Select(h => h.User.Name).ToList();
|
||||||
|
|
||||||
|
var newHouse = new
|
||||||
|
{
|
||||||
|
OwnerName = house.Owner?.Name,
|
||||||
|
house.RentalFee,
|
||||||
|
house.Price,
|
||||||
|
house.Type,
|
||||||
|
Rentals = rentals
|
||||||
|
};
|
||||||
|
|
||||||
|
player.TriggerEvent("SetHouseData", newHouse.SerializeJson(), userHouseStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveHouse(House house)
|
||||||
|
{
|
||||||
|
if (houseMarkers.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseMarkers[house.Id].Remove();
|
||||||
|
houseMarkers.Remove(house.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (houseLabels.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseLabels[house.Id].Remove();
|
||||||
|
houseLabels.Remove(house.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (houseColShapes.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseColShapes[house.Id].Remove();
|
||||||
|
houseColShapes.Remove(house.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (houseBlips.ContainsKey(house.Id))
|
||||||
|
{
|
||||||
|
houseBlips[house.Id].Remove();
|
||||||
|
houseBlips.Remove(house.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (IPlayer client in playerInColShape[house.Id])
|
||||||
|
{
|
||||||
|
client.TriggerEvent("CloseHouseMenu");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public House GetNearHouse(Position position, DatabaseContext dbContext)
|
||||||
|
{
|
||||||
|
return dbContext.Houses.Where(h => h.NewPosition.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.NewPosition.DistanceTo(position)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReloadAllHouses()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
foreach (House house in dbContext.Houses.Include(h => h.Owner).ToList())
|
||||||
|
{
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerBuyHouseEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
User user = player.GetUser(dbContext, bankAccount: true);
|
||||||
|
|
||||||
|
if (user.HouseId != null)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du kann nicht mehrere Häuser besitzen", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetNearHouse(player.Position, dbContext);
|
||||||
|
|
||||||
|
var userBank = user.BankAccount;
|
||||||
|
|
||||||
|
if (userBank.Balance < house.Price)
|
||||||
|
{
|
||||||
|
player.SendMessage($"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
house.Owner = user;
|
||||||
|
user.House = house;
|
||||||
|
|
||||||
|
userBank.Balance -= house.Price;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerSetRentalFeeEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
var rentalFee = args[0].ToInt();
|
||||||
|
|
||||||
|
using var dbContext = GetDbContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (user.HouseId == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
|
|
||||||
|
if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
||||||
|
{
|
||||||
|
DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
||||||
|
string dateStr = newPossibility.ToLongDateString();
|
||||||
|
string timeStr = newPossibility.ToShortTimeString();
|
||||||
|
player.SendNotification(
|
||||||
|
$"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rentalFee < 0)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rentalFee > 5000)
|
||||||
|
{
|
||||||
|
player.SendNotification($"~r~Die Miete darf einen Preis von {5000.ToMoneyString()} nicht überschreiten!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
house.LastRentSetTime = DateTime.Now;
|
||||||
|
house.RentalFee = rentalFee;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
||||||
|
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerCancelUserRentalEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
string userName = args[0] as string;
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
if (user.HouseId == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
User target = dbContext.Users.Where(u => u.Name == userName).FirstOrDefault();
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Dieser Spieler wurde nicht gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
|
|
||||||
|
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
||||||
|
if (rental == null)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Der Spieler ist nicht in deinem Haus eingemietet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.HouseRentals.Remove(rental);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
target.NewPlayer?.SendNotification($"~y~{player.Name}~s~ hat deinen Mietvertrag ~g~gekündigt~s~.");
|
||||||
|
|
||||||
|
player.SendNotification("Du hast dem Spieler ~y~" + target.Name + "~s~ den Mietvertrag gekündigt.");
|
||||||
|
SendPlayerHouseData(player, house);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerRentInHouseEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
using var dbContext = new DatabaseContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
House house = GetNearHouse(player.Position, dbContext);
|
||||||
|
|
||||||
|
if (house == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In deiner Nähe ist kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (house.RentalFee == 0)
|
||||||
|
{
|
||||||
|
player.SendMessage("Dieses Haus hat keinen Platz für Mieter", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HouseRental newRental = new HouseRental
|
||||||
|
{
|
||||||
|
HouseId = house.Id,
|
||||||
|
UserId = user.Id
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.HouseRentals.Add(newRental);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SendNotification("~g~Du hast dich in das Haus eingemietet");
|
||||||
|
|
||||||
|
house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet.");
|
||||||
|
SendPlayerHouseData(player, house);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerCancelOwnRentalEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
using var dbContext = GetDbContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
House house = GetNearHouse(player.Position, dbContext);
|
||||||
|
|
||||||
|
if (house == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("In deiner Nähe ist kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).FirstOrDefault();
|
||||||
|
|
||||||
|
if (rental == null)
|
||||||
|
{
|
||||||
|
player.SendNotification("~r~Du bist nin diesem Haus nicht eingemietet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.HouseRentals.Remove(rental);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
||||||
|
house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
||||||
|
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
|
||||||
|
SendPlayerHouseData(player, house);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HouseManagerSellHouseEvent(IPlayer player, params object[] args)
|
||||||
|
{
|
||||||
|
using var dbContext = GetDbContext();
|
||||||
|
User user = player.GetUser(dbContext);
|
||||||
|
if (user.HouseId == null)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du besitzt kein Haus", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
|
house.OwnerId = null;
|
||||||
|
user.HouseId = null;
|
||||||
|
|
||||||
|
var backMoney = (int)(house.Price * 0.4);
|
||||||
|
|
||||||
|
player.SendMessage("Du bekommst vom Hausverkauf ~g~" + backMoney.ToMoneyString() + "~s~ zurück.");
|
||||||
|
|
||||||
|
user.BankAccount.Balance += backMoney;
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SendMessage("!{#81F7BE}* Du hast dein Haus verkauft.");
|
||||||
|
|
||||||
|
RemoveHouse(house);
|
||||||
|
LoadHouse(house);
|
||||||
|
|
||||||
|
SendPlayerHouseData(player, house);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,6 @@ namespace ReallifeGamemode.Server.Core
|
|||||||
Log = LogManager.GetLogger(GetType());
|
Log = LogManager.GetLogger(GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
protected DatabaseContext GetDbContext(bool useLoggerFactory = true) => Main.GetDbContext(useLoggerFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Types
|
namespace ReallifeGamemode.Server.Types
|
||||||
{
|
{
|
||||||
public class CommandArgumentCountMismatchException : Exception
|
public class CommandArgumentCountMismatchException : SendHelpTextException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2793,144 +2793,10 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
||||||
public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
||||||
{
|
//{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
//}
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
option1 = option1?.ToLower();
|
|
||||||
|
|
||||||
if (option1 == "add")
|
|
||||||
{
|
|
||||||
House nearHouse = HouseManager.GetNearHouse(player.Position);
|
|
||||||
if (nearHouse != null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "In der Nähe ist schon ein Haus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
House house = new House()
|
|
||||||
{
|
|
||||||
Price = 0,
|
|
||||||
Type = "Haus",
|
|
||||||
X = player.Position.X,
|
|
||||||
Y = player.Position.Y,
|
|
||||||
Z = player.Position.Z
|
|
||||||
};
|
|
||||||
|
|
||||||
dbContext.Houses.Add(house);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
|
||||||
HouseManager.LoadHouse(house);
|
|
||||||
|
|
||||||
player.SendNotification("Das Haus wurde erstellt");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (option1 == "remove")
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
|
||||||
if (nearHouse == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nearHouse.OwnerId != null)
|
|
||||||
{
|
|
||||||
dbContext.Users.Where(u => u.Id == nearHouse.OwnerId).First().HouseId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (HouseRental rental in dbContext.HouseRentals.Include(r => r.User).Where(r => r.HouseId == nearHouse.Id))
|
|
||||||
{
|
|
||||||
rental.User.Player?.SendChatMessage("!{#81F7BE}* Dein Mietvertrag wurde administrativ aufgelöst!");
|
|
||||||
dbContext.HouseRentals.Remove(rental);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbContext.Houses.Remove(nearHouse);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
|
||||||
HouseManager.RemoveHouse(nearHouse);
|
|
||||||
|
|
||||||
player.SendNotification("Das Haus wurde gelöscht");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (option1 == "price")
|
|
||||||
{
|
|
||||||
if (!int.TryParse(option2, out int price))
|
|
||||||
{
|
|
||||||
ChatService.SendMessage(player, "~m~Benutzung: ~s~/house price [Price]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
|
||||||
if (nearHouse == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nearHouse.Price = price;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
|
||||||
HouseManager.RemoveHouse(nearHouse);
|
|
||||||
HouseManager.LoadHouse(nearHouse);
|
|
||||||
|
|
||||||
player.SendNotification("Der Hauspreis wurde gesetzt");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (option1 == "type")
|
|
||||||
{
|
|
||||||
if (option2 == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "~m~Benutzung: ~s~/house type [Type]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
House nearHouse = HouseManager.GetNearHouse(player.Position, dbContext);
|
|
||||||
if (nearHouse == null)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, "In deiner Nähe befindet sich kein Haus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nearHouse.Type = option2;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
|
||||||
HouseManager.RemoveHouse(nearHouse);
|
|
||||||
HouseManager.LoadHouse(nearHouse);
|
|
||||||
|
|
||||||
player.SendNotification("Der Haustyp wurde gesetzt");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (option1 == "reloadhouses")
|
|
||||||
{
|
|
||||||
HouseManager.ReloadAllHouses();
|
|
||||||
player.SendNotification("Alle Häuser wurden neu geladen");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.SendChatMessage("~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("paydaydrop", "~m~Benutzung: ~s~/paydaydrop")]
|
[Command("paydaydrop", "~m~Benutzung: ~s~/paydaydrop")]
|
||||||
public void CmdAdminPaydaydrop(Player player)
|
public void CmdAdminPaydaydrop(Player player)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Wanted;
|
|||||||
using ReallifeGamemode.Database;
|
using ReallifeGamemode.Database;
|
||||||
using ReallifeGamemode.Server.Types;
|
using ReallifeGamemode.Server.Types;
|
||||||
using ReallifeGamemode.Database.Entities;
|
using ReallifeGamemode.Database.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
@@ -52,6 +53,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.Name = username;
|
player.Name = username;
|
||||||
player.TriggerEvent("SERVER:Login_Success");
|
player.TriggerEvent("SERVER:Login_Success");
|
||||||
player.SetData("isLoggedIn", true);
|
player.SetData("isLoggedIn", true);
|
||||||
|
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||||
player.SetData("spec", true);
|
player.SetData("spec", true);
|
||||||
player.SetData("duty", false);
|
player.SetData("duty", false);
|
||||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace ReallifeGamemode.Server
|
|||||||
CityHallManager.LoadCityHall();
|
CityHallManager.LoadCityHall();
|
||||||
JobManager.LoadJobs();
|
JobManager.LoadJobs();
|
||||||
TaxiDriverJob.StartTaxiTimer();
|
TaxiDriverJob.StartTaxiTimer();
|
||||||
HouseManager.LoadHouses();
|
//HouseManager.LoadHouses();
|
||||||
DrivingSchool.DrivingSchool.Setup();
|
DrivingSchool.DrivingSchool.Setup();
|
||||||
PlaneSchool.Setup();
|
PlaneSchool.Setup();
|
||||||
Gangwar.Gangwar.loadTurfs();
|
Gangwar.Gangwar.loadTurfs();
|
||||||
|
|||||||
@@ -12,439 +12,432 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Managers
|
namespace ReallifeGamemode.Server.Managers
|
||||||
{
|
{
|
||||||
public class HouseManager : Script
|
//public class HouseManager : Script
|
||||||
{
|
//{
|
||||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
// private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
// private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
// private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||||
private static readonly Dictionary<int, NetHandle> houseBlips = new Dictionary<int, NetHandle>();
|
// private static readonly Dictionary<int, NetHandle> houseBlips = new Dictionary<int, NetHandle>();
|
||||||
|
|
||||||
private static readonly Dictionary<int, List<Player>> playerInColShape = new Dictionary<int, List<Player>>();
|
// private static readonly Dictionary<int, List<Player>> playerInColShape = new Dictionary<int, List<Player>>();
|
||||||
|
|
||||||
public static async void LoadHouses()
|
// public static async void LoadHouses()
|
||||||
{
|
// {
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
// }
|
||||||
List<House> houses = await dbContext.Houses.Include(h => h.Owner).ToListAsync();
|
|
||||||
foreach (House house in houses)
|
// public static async void ReloadAllHouses()
|
||||||
{
|
// {
|
||||||
LoadHouse(house, true);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// foreach (House house in await dbContext.Houses.Include(h => h.Owner).ToListAsync())
|
||||||
}
|
// {
|
||||||
|
// RemoveHouse(house);
|
||||||
public static async void ReloadAllHouses()
|
// LoadHouse(house, false);
|
||||||
{
|
// }
|
||||||
using (var dbContext = new DatabaseContext())
|
// }
|
||||||
{
|
// }
|
||||||
foreach (House house in await dbContext.Houses.Include(h => h.Owner).ToListAsync())
|
|
||||||
{
|
// public static House GetNearHouse(Vector3 position, DatabaseContext dbContext = null)
|
||||||
RemoveHouse(house);
|
// {
|
||||||
LoadHouse(house, false);
|
// if (dbContext == null)
|
||||||
}
|
// {
|
||||||
}
|
// using (dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
|
// return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||||
public static House GetNearHouse(Vector3 position, DatabaseContext dbContext = null)
|
// }
|
||||||
{
|
// }
|
||||||
if (dbContext == null)
|
// else
|
||||||
{
|
// {
|
||||||
using (dbContext = new DatabaseContext())
|
// return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
||||||
{
|
// }
|
||||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
// }
|
||||||
}
|
|
||||||
}
|
// public void AddHouse(string type, int price, Vector3 position)
|
||||||
else
|
// {
|
||||||
{
|
// using (var dbContext = new DatabaseContext())
|
||||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault();
|
// {
|
||||||
}
|
// var house = new House()
|
||||||
}
|
// {
|
||||||
|
// Price = price,
|
||||||
public void AddHouse(string type, int price, Vector3 position)
|
// Type = type,
|
||||||
{
|
// X = position.X,
|
||||||
using (var dbContext = new DatabaseContext())
|
// Y = position.Y,
|
||||||
{
|
// Z = position.Z
|
||||||
var house = new House()
|
// };
|
||||||
{
|
|
||||||
Price = price,
|
// dbContext.Houses.Add(house);
|
||||||
Type = type,
|
// dbContext.SaveChanges();
|
||||||
X = position.X,
|
|
||||||
Y = position.Y,
|
// LoadHouse(house);
|
||||||
Z = position.Z
|
// }
|
||||||
};
|
// }
|
||||||
|
|
||||||
dbContext.Houses.Add(house);
|
// public static House GetHouseById(int id, DatabaseContext dbContext = null)
|
||||||
dbContext.SaveChanges();
|
// {
|
||||||
|
// if (dbContext == null)
|
||||||
LoadHouse(house);
|
// {
|
||||||
}
|
// using (dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
|
// return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||||
public static House GetHouseById(int id, DatabaseContext dbContext = null)
|
// }
|
||||||
{
|
// }
|
||||||
if (dbContext == null)
|
// else
|
||||||
{
|
// {
|
||||||
using (dbContext = new DatabaseContext())
|
// return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
||||||
{
|
// }
|
||||||
return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
// }
|
||||||
}
|
|
||||||
}
|
// public static void LoadHouse(House house, bool loadUser = true)
|
||||||
else
|
// {
|
||||||
{
|
// if (loadUser) house = house.Refresh();
|
||||||
return dbContext.Houses.Where(h => h.Id == id).Include(h => h.Owner).FirstOrDefault();
|
|
||||||
}
|
// playerInColShape[house.Id] = new List<Player>();
|
||||||
}
|
|
||||||
|
// houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255)).Handle;
|
||||||
public static void LoadHouse(House house, bool loadUser = true)
|
// string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
||||||
{
|
|
||||||
if (loadUser) house = house.Refresh();
|
// if (house.OwnerId != null)
|
||||||
|
// {
|
||||||
playerInColShape[house.Id] = new List<Player>();
|
// text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
||||||
|
|
||||||
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255)).Handle;
|
// if (house.RentalFee != 0)
|
||||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{(house.Price == 0 ? "~r~Nicht verkäuflich" : house.Price.ToMoneyString())}";
|
// {
|
||||||
|
// text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
||||||
if (house.OwnerId != null)
|
// }
|
||||||
{
|
// }
|
||||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.Owner.Name}";
|
// else
|
||||||
|
// {
|
||||||
if (house.RentalFee != 0)
|
// //houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
||||||
{
|
|
||||||
text += $"\n~s~Mietpreis: ~g~{house.RentalFee.ToMoneyString()}";
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
// houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||||
//houseBlips[house.Id] = NAPI.Blip.CreateBlip(40, house.Position, 0.7f, 11, "Haus", shortRange: true); too many blips
|
|
||||||
|
// if (house.Price != 0)
|
||||||
}
|
// {
|
||||||
|
// houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
||||||
|
|
||||||
|
// houseColShapes[house.Id].Entity<ColShape>().OnEntityEnterColShape += HouseManager_OnEntityEnterColShape;
|
||||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
// houseColShapes[house.Id].Entity<ColShape>().OnEntityExitColShape += HouseManager_OnEntityExitColShape;
|
||||||
|
// }
|
||||||
if (house.Price != 0)
|
// }
|
||||||
{
|
|
||||||
houseColShapes[house.Id] = NAPI.ColShape.CreateCylinderColShape(house.Position.Subtract(new Vector3(0, 0, 2)), 2.0f, 5f);
|
// private static void HouseManager_OnEntityExitColShape(ColShape colShape, Player client)
|
||||||
|
// {
|
||||||
houseColShapes[house.Id].Entity<ColShape>().OnEntityEnterColShape += HouseManager_OnEntityEnterColShape;
|
// if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||||
houseColShapes[house.Id].Entity<ColShape>().OnEntityExitColShape += HouseManager_OnEntityExitColShape;
|
// if (!houseColShapes.ContainsValue(colShape.Handle))
|
||||||
}
|
// {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
private static void HouseManager_OnEntityExitColShape(ColShape colShape, Player client)
|
// int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||||
{
|
// playerInColShape[houseId].Remove(client);
|
||||||
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
|
||||||
if (!houseColShapes.ContainsValue(colShape.Handle))
|
// client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||||
{
|
// }
|
||||||
return;
|
|
||||||
}
|
// private static void HouseManager_OnEntityEnterColShape(ColShape colShape, Player client)
|
||||||
int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
// {
|
||||||
playerInColShape[houseId].Remove(client);
|
// if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
||||||
|
// if (!houseColShapes.ContainsValue(colShape.Handle))
|
||||||
client.TriggerEvent("SERVER:CloseHouseMenu");
|
// {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
private static void HouseManager_OnEntityEnterColShape(ColShape colShape, Player client)
|
// int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||||
{
|
// playerInColShape[houseId].Add(client);
|
||||||
if (!client.IsLoggedIn() || client.IsInVehicle) return;
|
// House house = GetHouseById(houseId);
|
||||||
if (!houseColShapes.ContainsValue(colShape.Handle))
|
// User user = client.GetUser();
|
||||||
{
|
|
||||||
return;
|
// client.TriggerEvent("SERVER:ShowHouseMenu");
|
||||||
}
|
// SendPlayerHouseData(client, house);
|
||||||
int houseId = houseColShapes.Where(p => p.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
// }
|
||||||
playerInColShape[houseId].Add(client);
|
|
||||||
House house = GetHouseById(houseId);
|
// private static void SendPlayerHouseData(Player player, House house)
|
||||||
User user = client.GetUser();
|
// {
|
||||||
|
// User user = player.GetUser();
|
||||||
client.TriggerEvent("SERVER:ShowHouseMenu");
|
// var userHouseStatus = -1;
|
||||||
SendPlayerHouseData(client, house);
|
|
||||||
}
|
// using (var dbContext = new DatabaseContext())
|
||||||
|
// {
|
||||||
private static void SendPlayerHouseData(Player player, House house)
|
// if (house.OwnerId == null) userHouseStatus = 0;
|
||||||
{
|
// else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
||||||
User user = player.GetUser();
|
// else if (dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
||||||
var userHouseStatus = -1;
|
|
||||||
|
// var rentals = dbContext.HouseRentals.Where(h => h.HouseId == house.Id).Include(h => h.User).Select(h => h.User.Name).ToList();
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
// var newHouse = new
|
||||||
if (house.OwnerId == null) userHouseStatus = 0;
|
// {
|
||||||
else if (house.OwnerId == user?.Id) userHouseStatus = 1;
|
// OwnerName = house.Owner?.Name,
|
||||||
else if (dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).Count() == 1) userHouseStatus = 2;
|
// house.RentalFee,
|
||||||
|
// house.Price,
|
||||||
var rentals = dbContext.HouseRentals.Where(h => h.HouseId == house.Id).Include(h => h.User).Select(h => h.User.Name).ToList();
|
// house.Type,
|
||||||
|
// Rentals = rentals
|
||||||
var newHouse = new
|
// };
|
||||||
{
|
|
||||||
OwnerName = house.Owner?.Name,
|
// player.TriggerEvent("SERVER:SetHouseData", JsonConvert.SerializeObject(newHouse), userHouseStatus);
|
||||||
house.RentalFee,
|
// }
|
||||||
house.Price,
|
// }
|
||||||
house.Type,
|
|
||||||
Rentals = rentals
|
// public static void RemoveHouse(House house)
|
||||||
};
|
// {
|
||||||
|
// if (houseMarkers.ContainsKey(house.Id))
|
||||||
player.TriggerEvent("SERVER:SetHouseData", JsonConvert.SerializeObject(newHouse), userHouseStatus);
|
// {
|
||||||
}
|
// houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||||
}
|
// houseMarkers.Remove(house.Id);
|
||||||
|
// }
|
||||||
public static void RemoveHouse(House house)
|
|
||||||
{
|
// if (houseLabels.ContainsKey(house.Id))
|
||||||
if (houseMarkers.ContainsKey(house.Id))
|
// {
|
||||||
{
|
// houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||||
houseMarkers[house.Id].Entity<Marker>().Delete();
|
// houseLabels.Remove(house.Id);
|
||||||
houseMarkers.Remove(house.Id);
|
// }
|
||||||
}
|
|
||||||
|
// if (houseColShapes.ContainsKey(house.Id))
|
||||||
if (houseLabels.ContainsKey(house.Id))
|
// {
|
||||||
{
|
// houseColShapes[house.Id].Entity<ColShape>().Delete();
|
||||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
// houseColShapes.Remove(house.Id);
|
||||||
houseLabels.Remove(house.Id);
|
// }
|
||||||
}
|
|
||||||
|
// if (houseBlips.ContainsKey(house.Id))
|
||||||
if (houseColShapes.ContainsKey(house.Id))
|
// {
|
||||||
{
|
// houseBlips[house.Id].Entity<Blip>().Delete();
|
||||||
houseColShapes[house.Id].Entity<ColShape>().Delete();
|
// houseBlips.Remove(house.Id);
|
||||||
houseColShapes.Remove(house.Id);
|
// }
|
||||||
}
|
|
||||||
|
// foreach (Player client in playerInColShape[house.Id])
|
||||||
if (houseBlips.ContainsKey(house.Id))
|
// {
|
||||||
{
|
// client.TriggerEvent("SERVER:CloseHouseMenu");
|
||||||
houseBlips[house.Id].Entity<Blip>().Delete();
|
// }
|
||||||
houseBlips.Remove(house.Id);
|
// }
|
||||||
}
|
|
||||||
|
// [RemoteEvent("CLIENT:House_BuyHouse")]
|
||||||
foreach (Player client in playerInColShape[house.Id])
|
// public void HouseManagerBuyHouseEvent(Player player)
|
||||||
{
|
// {
|
||||||
client.TriggerEvent("SERVER:CloseHouseMenu");
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:House_BuyHouse")]
|
// if (user.HouseId != null)
|
||||||
public void HouseManagerBuyHouseEvent(Player player)
|
// {
|
||||||
{
|
// ChatService.ErrorMessage(player, "Du kann nicht mehrere Häuser besitzen");
|
||||||
using (var dbContext = new DatabaseContext())
|
// return;
|
||||||
{
|
// }
|
||||||
User user = player.GetUser(dbContext);
|
|
||||||
|
// House house = GetNearHouse(player.Position, dbContext);
|
||||||
if (user.HouseId != null)
|
|
||||||
{
|
// var userBank = user.BankAccount;
|
||||||
ChatService.ErrorMessage(player, "Du kann nicht mehrere Häuser besitzen");
|
|
||||||
return;
|
// if (userBank.Balance < house.Price)
|
||||||
}
|
// {
|
||||||
|
// ChatService.ErrorMessage(player, $"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})");
|
||||||
House house = GetNearHouse(player.Position, dbContext);
|
// return;
|
||||||
|
// }
|
||||||
var userBank = user.BankAccount;
|
|
||||||
|
// house.Owner = user;
|
||||||
if (userBank.Balance < house.Price)
|
// user.House = house;
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(player, $"Du hast nicht genug Geld für das Haus ({house.Price.ToMoneyString()})");
|
// userBank.Balance -= house.Price;
|
||||||
return;
|
|
||||||
}
|
// dbContext.SaveChanges();
|
||||||
|
|
||||||
house.Owner = user;
|
// RemoveHouse(house);
|
||||||
user.House = house;
|
// LoadHouse(house);
|
||||||
|
// }
|
||||||
userBank.Balance -= house.Price;
|
// }
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
// [RemoteEvent("CLIENT:House_SetRentalFee")]
|
||||||
|
// public void HouseManagerSetRentalFeeEvent(Player player, int rentalFee)
|
||||||
RemoveHouse(house);
|
// {
|
||||||
LoadHouse(house);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
|
||||||
[RemoteEvent("CLIENT:House_SetRentalFee")]
|
// if (user.HouseId == null)
|
||||||
public void HouseManagerSetRentalFeeEvent(Player player, int rentalFee)
|
// {
|
||||||
{
|
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||||
using (var dbContext = new DatabaseContext())
|
// return;
|
||||||
{
|
// }
|
||||||
User user = player.GetUser(dbContext);
|
|
||||||
|
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
if (user.HouseId == null)
|
|
||||||
{
|
// if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
||||||
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
// {
|
||||||
return;
|
// DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
||||||
}
|
// string dateStr = newPossibility.ToLongDateString();
|
||||||
|
// string timeStr = newPossibility.ToShortTimeString();
|
||||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
// player.SendNotification(
|
||||||
|
// $"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
||||||
if (DateTime.Now - house.LastRentSetTime < TimeSpan.FromDays(7))
|
// return;
|
||||||
{
|
// }
|
||||||
DateTime newPossibility = house.LastRentSetTime.AddDays(7);
|
|
||||||
string dateStr = newPossibility.ToLongDateString();
|
// if (rentalFee < 0)
|
||||||
string timeStr = newPossibility.ToShortTimeString();
|
// {
|
||||||
player.SendNotification(
|
// player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
||||||
$"~r~Die Miete wurde in den letzten 7 Tagen schon verändert. Die nächste Änderung kann am {dateStr} um {timeStr} Uhr geändert werden.");
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
|
||||||
|
// if (rentalFee > 5000)
|
||||||
if (rentalFee < 0)
|
// {
|
||||||
{
|
// player.SendNotification($"~r~Die Miete darf einen Preis von {5000.ToMoneyString()} nicht überschreiten!");
|
||||||
player.SendNotification("~r~Die Miete darf kein negativer Betrag sein!");
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
|
||||||
|
// house.LastRentSetTime = DateTime.Now;
|
||||||
if (rentalFee > 5000)
|
// house.RentalFee = rentalFee;
|
||||||
{
|
|
||||||
player.SendNotification($"~r~Die Miete darf einen Preis von {5000.ToMoneyString()} nicht überschreiten!");
|
// dbContext.SaveChanges();
|
||||||
return;
|
|
||||||
}
|
// player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
||||||
|
|
||||||
house.LastRentSetTime = DateTime.Now;
|
// RemoveHouse(house);
|
||||||
house.RentalFee = rentalFee;
|
// LoadHouse(house);
|
||||||
|
// }
|
||||||
dbContext.SaveChanges();
|
// }
|
||||||
|
|
||||||
player.SendNotification($"Der Mietpreis wurde auf ~g~{rentalFee.ToMoneyString()}~s~ gesetzt");
|
// [RemoteEvent("CLIENT:House_CancelUserRental")]
|
||||||
|
// public void HouseManagerCancelUserRentalEvent(Player player, string userName)
|
||||||
RemoveHouse(house);
|
// {
|
||||||
LoadHouse(house);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
// if (user.HouseId == null)
|
||||||
[RemoteEvent("CLIENT:House_CancelUserRental")]
|
// {
|
||||||
public void HouseManagerCancelUserRentalEvent(Player player, string userName)
|
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||||
{
|
// return;
|
||||||
using (var dbContext = new DatabaseContext())
|
// }
|
||||||
{
|
|
||||||
User user = player.GetUser(dbContext);
|
// User target = dbContext.Users.Where(u => u.Name == userName).FirstOrDefault();
|
||||||
if (user.HouseId == null)
|
// if (target == null)
|
||||||
{
|
// {
|
||||||
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
// player.SendNotification("~r~Dieser Spieler wurde nicht gefunden.");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
User target = dbContext.Users.Where(u => u.Name == userName).FirstOrDefault();
|
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
if (target == null)
|
|
||||||
{
|
// HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
||||||
player.SendNotification("~r~Dieser Spieler wurde nicht gefunden.");
|
// if (rental == null)
|
||||||
return;
|
// {
|
||||||
}
|
// player.SendNotification("~r~Der Spieler ist nicht in deinem Haus eingemietet");
|
||||||
|
// return;
|
||||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
// }
|
||||||
|
|
||||||
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == target.Id).FirstOrDefault();
|
// dbContext.HouseRentals.Remove(rental);
|
||||||
if (rental == null)
|
// dbContext.SaveChanges();
|
||||||
{
|
|
||||||
player.SendNotification("~r~Der Spieler ist nicht in deinem Haus eingemietet");
|
// target.Player?.SendNotification($"~y~{player.Name}~s~ hat deinen Mietvertrag ~g~gekündigt~s~.");
|
||||||
return;
|
|
||||||
}
|
// player.SendNotification("Du hast dem Spieler ~y~" + target.Name + "~s~ den Mietvertrag gekündigt.");
|
||||||
|
// SendPlayerHouseData(player, house);
|
||||||
dbContext.HouseRentals.Remove(rental);
|
// }
|
||||||
dbContext.SaveChanges();
|
// }
|
||||||
|
|
||||||
target.Player?.SendNotification($"~y~{player.Name}~s~ hat deinen Mietvertrag ~g~gekündigt~s~.");
|
// [RemoteEvent("CLIENT:House_RentInHouse")]
|
||||||
|
// public void HouseManagerRentInHouseEvent(Player player)
|
||||||
player.SendNotification("Du hast dem Spieler ~y~" + target.Name + "~s~ den Mietvertrag gekündigt.");
|
// {
|
||||||
SendPlayerHouseData(player, house);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
// House house = GetNearHouse(player.Position, dbContext);
|
||||||
[RemoteEvent("CLIENT:House_RentInHouse")]
|
|
||||||
public void HouseManagerRentInHouseEvent(Player player)
|
// if (house == null)
|
||||||
{
|
// {
|
||||||
using (var dbContext = new DatabaseContext())
|
// ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
||||||
{
|
// return;
|
||||||
User user = player.GetUser(dbContext);
|
// }
|
||||||
House house = GetNearHouse(player.Position, dbContext);
|
|
||||||
|
// if (house.RentalFee == 0)
|
||||||
if (house == null)
|
// {
|
||||||
{
|
// player.SendChatMessage("~r~Dieses Haus hat keinen Platz für Mieter!");
|
||||||
ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
|
||||||
|
// HouseRental newRental = new HouseRental
|
||||||
if (house.RentalFee == 0)
|
// {
|
||||||
{
|
// HouseId = house.Id,
|
||||||
player.SendChatMessage("~r~Dieses Haus hat keinen Platz für Mieter!");
|
// UserId = user.Id
|
||||||
return;
|
// };
|
||||||
}
|
|
||||||
|
// dbContext.HouseRentals.Add(newRental);
|
||||||
HouseRental newRental = new HouseRental
|
|
||||||
{
|
// dbContext.SaveChanges();
|
||||||
HouseId = house.Id,
|
|
||||||
UserId = user.Id
|
// player.SendNotification("~g~Du hast dich in das Haus eingemietet");
|
||||||
};
|
|
||||||
|
// house.User?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet.");
|
||||||
dbContext.HouseRentals.Add(newRental);
|
// SendPlayerHouseData(player, house);
|
||||||
|
// }
|
||||||
dbContext.SaveChanges();
|
// }
|
||||||
|
|
||||||
player.SendNotification("~g~Du hast dich in das Haus eingemietet");
|
// [RemoteEvent("CLIENT:House_CancelOwnRental")]
|
||||||
|
// public void HouseManagerCancelOwnRentalEvent(Player player)
|
||||||
house.User?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet.");
|
// {
|
||||||
SendPlayerHouseData(player, house);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
// House house = GetNearHouse(player.Position, dbContext);
|
||||||
[RemoteEvent("CLIENT:House_CancelOwnRental")]
|
|
||||||
public void HouseManagerCancelOwnRentalEvent(Player player)
|
// if (house == null)
|
||||||
{
|
// {
|
||||||
using (var dbContext = new DatabaseContext())
|
// ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
||||||
{
|
// return;
|
||||||
User user = player.GetUser(dbContext);
|
// }
|
||||||
House house = GetNearHouse(player.Position, dbContext);
|
|
||||||
|
// HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).FirstOrDefault();
|
||||||
if (house == null)
|
|
||||||
{
|
// if (rental == null)
|
||||||
ChatService.ErrorMessage(player, "In deiner Nähe ist kein Haus");
|
// {
|
||||||
return;
|
// player.SendNotification("~r~Du bist nin diesem Haus nicht eingemietet");
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
HouseRental rental = dbContext.HouseRentals.Where(h => h.HouseId == house.Id && h.UserId == user.Id).FirstOrDefault();
|
|
||||||
|
// dbContext.HouseRentals.Remove(rental);
|
||||||
if (rental == null)
|
|
||||||
{
|
// dbContext.SaveChanges();
|
||||||
player.SendNotification("~r~Du bist nin diesem Haus nicht eingemietet");
|
|
||||||
return;
|
// player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
||||||
}
|
// house.User?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
||||||
|
|
||||||
dbContext.HouseRentals.Remove(rental);
|
// RemoveHouse(house);
|
||||||
|
// LoadHouse(house);
|
||||||
dbContext.SaveChanges();
|
|
||||||
|
// SendPlayerHouseData(player, house);
|
||||||
player.SendNotification("~g~Du hast den Mietvertrag gekündigt.");
|
// }
|
||||||
house.User?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt.");
|
// }
|
||||||
|
|
||||||
RemoveHouse(house);
|
// [RemoteEvent("CLIENT:House_SellHouse")]
|
||||||
LoadHouse(house);
|
// public void HouseManagerSellHouseEvent(Player player)
|
||||||
|
// {
|
||||||
SendPlayerHouseData(player, house);
|
// using (var dbContext = new DatabaseContext())
|
||||||
}
|
// {
|
||||||
}
|
// User user = player.GetUser(dbContext);
|
||||||
|
// if (user.HouseId == null)
|
||||||
[RemoteEvent("CLIENT:House_SellHouse")]
|
// {
|
||||||
public void HouseManagerSellHouseEvent(Player player)
|
// ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
||||||
{
|
// return;
|
||||||
using (var dbContext = new DatabaseContext())
|
// }
|
||||||
{
|
|
||||||
User user = player.GetUser(dbContext);
|
// House house = GetHouseById(user.HouseId.Value, dbContext);
|
||||||
if (user.HouseId == null)
|
// house.OwnerId = null;
|
||||||
{
|
// user.HouseId = null;
|
||||||
ChatService.ErrorMessage(player, "Du besitzt kein Haus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
House house = GetHouseById(user.HouseId.Value, dbContext);
|
|
||||||
house.OwnerId = null;
|
|
||||||
user.HouseId = null;
|
|
||||||
|
|
||||||
var backMoney = (int)(house.Price * 0.4);
|
// var backMoney = (int)(house.Price * 0.4);
|
||||||
|
|
||||||
ChatService.SendMessage(player, "Du bekommst vom Hausverkauf ~g~" + backMoney.ToMoneyString() + "~s~ zurück.");
|
// ChatService.SendMessage(player, "Du bekommst vom Hausverkauf ~g~" + backMoney.ToMoneyString() + "~s~ zurück.");
|
||||||
|
|
||||||
user.BankAccount.Balance += backMoney;
|
// user.BankAccount.Balance += backMoney;
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
// dbContext.SaveChanges();
|
||||||
|
|
||||||
player.SendChatMessage("!{#81F7BE}* Du hast dein Haus verkauft.");
|
// player.SendChatMessage("!{#81F7BE}* Du hast dein Haus verkauft.");
|
||||||
|
|
||||||
RemoveHouse(house);
|
// RemoveHouse(house);
|
||||||
LoadHouse(house);
|
// LoadHouse(house);
|
||||||
|
|
||||||
SendPlayerHouseData(player, house);
|
// SendPlayerHouseData(player, house);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user