From 5e3bc3927524f3472a81a443d5628ceb8b47a5f8 Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 12 Mar 2020 19:19:42 +0100 Subject: [PATCH] Add changes --- ReallifeGamemode.Client/index.ts | 14 +- .../vehiclesync/vehiclesync.ts | 603 ++---------------- .../Logic/JwtTokenGenerator.cs | 1 + .../Types/GetUserDataResponse.cs | 1 + ReallifeGamemode.Database/AdminLevel.cs | 25 - ReallifeGamemode.Database/Entities/User.cs | 1 + ReallifeGamemode.Database/GroupRanks.cs | 14 - .../ReallifeGamemode.Database.csproj | 3 +- ReallifeGamemode.Server.Core.API/Color.cs | 2 + ReallifeGamemode.Server.Core.API/IAPI.cs | 2 + ReallifeGamemode.Server.Core.API/IColShape.cs | 2 +- .../ITextLabel.cs | 11 + .../ITextLabelAPI.cs | 12 + .../PlayerExtensions.cs | 38 ++ ...lifeGamemode.Server.Core.Extensions.csproj | 13 + .../RageAPI.cs | 2 + .../RageColShapeAPI.cs | 7 +- .../RageTextLabel.cs | 20 + .../RageTextLabelAPI.cs | 19 + .../Commands/Admin/AdminCommand.cs | 16 + .../Managers/VehicleManager.cs | 59 ++ .../Menus/PoliceDepartment.cs | 28 + ReallifeGamemode.Server.Types/AdminLevel.cs | 25 +- ReallifeGamemode.Server.Types/Font.cs | 15 + ReallifeGamemode.Server.Types/GroupRank.cs | 11 +- .../Commands/AdminCommands.cs | 37 +- .../Commands/UserCommands.cs | 1 + ReallifeGamemode.Server/Events/Connect.cs | 1 + ReallifeGamemode.Server/Events/Death.cs | 1 + ReallifeGamemode.Server/Events/Disconnect.cs | 1 + ReallifeGamemode.Server/Events/Key.cs | 5 +- ReallifeGamemode.Server/Events/Login.cs | 1 + ReallifeGamemode.Server/Events/Vehicle.cs | 5 +- .../Extensions/EnumExtensions.cs | 3 +- ReallifeGamemode.Server/Job/TaxiDriverJob.cs | 9 +- .../Managers/BusinessManager.cs | 1 + .../Managers/CityHallManager.cs | 3 +- .../Managers/DoorManager.cs | 1 + .../Managers/InteractionManager.cs | 1 + ReallifeGamemode.Server/Report/Report.cs | 1 + .../Services/ChatService.cs | 1 + .../ReallifeGamemode.Services.csproj | 2 +- ReallifeGamemode.sln | 14 + 43 files changed, 390 insertions(+), 642 deletions(-) delete mode 100644 ReallifeGamemode.Database/AdminLevel.cs delete mode 100644 ReallifeGamemode.Database/GroupRanks.cs create mode 100644 ReallifeGamemode.Server.Core.API/ITextLabel.cs create mode 100644 ReallifeGamemode.Server.Core.API/ITextLabelAPI.cs create mode 100644 ReallifeGamemode.Server.Core.Extensions/PlayerExtensions.cs create mode 100644 ReallifeGamemode.Server.Core.Extensions/ReallifeGamemode.Server.Core.Extensions.csproj create mode 100644 ReallifeGamemode.Server.Core.RageMP/RageTextLabel.cs create mode 100644 ReallifeGamemode.Server.Core.RageMP/RageTextLabelAPI.cs create mode 100644 ReallifeGamemode.Server.Core/Commands/Admin/AdminCommand.cs create mode 100644 ReallifeGamemode.Server.Core/Managers/VehicleManager.cs create mode 100644 ReallifeGamemode.Server.Types/Font.cs diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index d64a02e1..9e1b4e05 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -161,8 +161,7 @@ sirenSilence(); import waypointUtil from './util/waypoint'; waypointUtil(); -import vehicleSync from './vehiclesync/vehiclesync'; -vehicleSync(); +require('./vehiclesync/vehiclesync'); import smoothThrottle from './vehiclesync/smoothtrottle'; smoothThrottle(); @@ -201,4 +200,13 @@ import itemShopList from './Interaction/ItemShop'; itemShopList(globalData); import taximeterInput from './Gui/taximeter'; -taximeterInput(globalData); \ No newline at end of file +taximeterInput(globalData); + +interface VehicleData { + EngineState: boolean; + Locked: boolean; +} + +export { + VehicleData +} \ No newline at end of file diff --git a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts index e7c14514..84a85c30 100644 --- a/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts +++ b/ReallifeGamemode.Client/vehiclesync/vehiclesync.ts @@ -1,560 +1,75 @@ -//Disapproved by the entire planet -//You don't need to worry about anything here -export default function vehicleSync() { - mp.events.add("VehStream_SetEngineStatus", (veh, status) => { - if (veh === undefined || veh === null || !veh.isAVehicle()) return; - if (veh !== undefined) { - if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on - { - veh.setEngineOn(status, true, false); - veh.setUndriveable(true); - } - else { - veh.setEngineOn(status, false, true); - veh.setUndriveable(!status); - } - } - }); +import game, { VehicleData } from '../index'; +import { IVehicle, EntityType, IEntity, VehicleSeat } from '../game'; +import { parseJson } from '../util'; - mp.events.add("VehStream_SetLockStatus", (veh, status) => { - if (veh === undefined || veh === null || !veh.isAVehicle()) return; - if (veh !== undefined) { - if (status) - veh.setDoorsLocked(2); - else - veh.setDoorsLocked(1); - } - }); +game.events.add('SERVER:Vehicle:UpdateData', (vehId, dataStr) => { + var data: VehicleData = parseJson(dataStr); + var vehicle: IVehicle = game.vehicles.at(vehId); - mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => { - entity = mp.vehicles.atRemoteId(entity); - if (entity === undefined || entity === null || !entity.isAVehicle()) return; - if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') { - var toggle = entity.getVariable("VehicleSyncData"); - entity.setEngineOn(toggle.Engine, false, true); - entity.setUndriveable(!toggle.Engine); - entity.setInvincible(false); - } - }); + setVehicleData(vehicle, data); +}); - mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => { - if (entity === undefined || entity === null || !entity.isAVehicle()) return; - if (entity !== undefined) { - if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') { - var toggle = entity.getVariable("VehicleSyncData"); - entity.setEngineOn(toggle.Engine, true, false); - entity.setUndriveable(!toggle.Engine); - } - var level = entity.getDirtLevel(); - mp.events.callRemote("VehStream_SetDirtLevel", entity, level); - } - }); +game.events.onPlayerEnterVehicle((vehicle, seat) => { + while (!game.players.local.inVehicle) { + game.wait(0); + } - mp.events.add("VehStream_PlayerExitVehicle", (entity) => { - entity = mp.vehicles.atRemoteId(entity); - if (entity === undefined || entity === null || !entity.isAVehicle()) { - return; - } - setTimeout(() => { - var Status = []; - let y = 0; - for (y = 0; y < 8; y++) { - if (entity.isDoorDamaged(y)) { - Status.push(2); - } - else if (entity.getDoorAngleRatio(y) > 0.15) { - Status.push(1); - } - else { - Status.push(0); - } - } - mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]); + if (vehicle) { + var data: VehicleData = vehicle.getSharedData("VehicleData"); - Status = []; - if (entity.isWindowIntact(0)) { - if (entity.getBoneIndexByName("window_rf") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(1)) { - if (entity.getBoneIndexByName("window_lf") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(2)) { - if (entity.getBoneIndexByName("window_rr") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(3)) { - if (entity.getBoneIndexByName("window_lr") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]); + setVehicleData(vehicle, data); + } +}); - Status = []; - if (!entity.isTyreBurst(0, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(0, false)) { - Status.push(1); - } - else { - Status.push(2); - } +game.events.onPlayerExitVehicle(() => { + var veh = game.players.local.vehicle; + while (game.players.local.inVehicle) { + game.wait(0); + } - if (!entity.isTyreBurst(1, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(1, false)) { - Status.push(1); - } - else { - Status.push(2); - } + if (veh) { + var data: VehicleData = veh.getSharedData("VehicleData"); - if (!entity.isTyreBurst(2, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(2, false)) { - Status.push(1); - } - else { - Status.push(2); - } + setVehicleData(veh, data); + } +}); - if (!entity.isTyreBurst(3, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(3, false)) { - Status.push(1); - } - else { - Status.push(2); - } +game.events.onEntityStreamIn((entity: IEntity) => { + if (entity && entity.type === EntityType.Vehicle) { + var data: VehicleData = entity.getSharedData("VehicleData"); - if (!entity.isTyreBurst(4, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(4, false)) { - Status.push(1); - } - else { - Status.push(2); - } + var vehicle = entity; + setVehicleData(vehicle, data); + } +}); - if (!entity.isTyreBurst(5, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(5, false)) { - Status.push(1); - } - else { - Status.push(2); - } +function setVehicleData(veh: IVehicle, data: VehicleData): void { + game.ui.sendChatMessage("setVehicleData"); + if (!veh) { + game.ui.sendChatMessage("veh is null"); + return; + } - if (!entity.isTyreBurst(6, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(6, false)) { - Status.push(1); - } - else { - Status.push(2); - } + game.ui.sendChatMessage("veh is not null"); + if (data === null) { + game.ui.sendChatMessage("data is null"); + data = { + EngineState: false, + Locked: false + }; + } - if (!entity.isTyreBurst(7, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(7, false)) { - Status.push(1); - } - else { - Status.push(2); - } + game.ui.sendChatMessage(`engine: ${data.EngineState}, locked: ${data.Locked}`); - if (!entity.isTyreBurst(45, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(45, false)) { - Status.push(1); - } - else { - Status.push(2); - } + var engineState = data.EngineState; + if (veh.isSeatFree(VehicleSeat.Driver)) { + veh.setEngineStatus(engineState, true, false); + veh.setUndriveable(true); + } else { + veh.setEngineStatus(engineState, false, true); + veh.setUndriveable(!engineState); + } - if (!entity.isTyreBurst(47, false)) { - Status.push(0); - } - else if (entity.isTyreBurst(47, false)) { - Status.push(1); - } - else { - Status.push(2); - } - - mp.events.callRemote("VehStream_SetWheelData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7], Status[8], Status[9]); - }, 2500); - }); - - mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => { - entity = mp.vehicles.atRemoteId(entity); - if (entity === undefined || entity === null || !entity.isAVehicle()) return; - setTimeout(() => { - var Status = []; - let y = 0; - for (y = 0; y < 8; y++) { - if (entity.isDoorDamaged(y)) { - Status.push(2); - } - else if (entity.getDoorAngleRatio(y) > 0.15) { - Status.push(1); - } - else { - Status.push(0); - } - } - //mp.events.callRemote("VehStream_SetDoorData", entity, Status[0], Status[1], Status[2], Status[3], Status[4], Status[5], Status[6], Status[7]); - - Status = []; - if (entity.isWindowIntact(0)) { - if (entity.getBoneIndexByName("window_rf") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(1)) { - if (entity.getBoneIndexByName("window_lf") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(2)) { - if (entity.getBoneIndexByName("window_rr") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - if (entity.isWindowIntact(3)) { - if (entity.getBoneIndexByName("window_lr") === -1) { - Status.push(1); - } - else { - Status.push(0); - } - } - else { - Status.push(2); - } - mp.events.callRemote("VehStream_SetWindowData", entity, Status[0], Status[1], Status[2], Status[3]); - }, 3000); - }); - - mp.events.add("VehStream_SetVehicleDirtLevel", (entity, dirt) => { - if (entity === undefined || entity === null || !entity.isAVehicle()) return; - if (entity !== undefined) { - entity.setDirtLevel(dirt); - } - }); - - mp.events.add("VehStream_SetVehicleDoorStatus_Single", (veh, door, state) => { - if (veh === undefined || veh === null || !veh.isAVehicle()) return; - if (veh !== undefined) { - if (state === 0) { - veh.setDoorShut(door, false); - } - else if (state === 1) { - veh.setDoorOpen(door, false, false); - } - else { - veh.setDoorBroken(door, true); - } - } - }); - - mp.events.add("VehStream_SetVehicleDoorStatus", (...args) => { - if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) { - let y = 0; - for (y = 1; y < args.length; y++) { - if (args[y] === 0) { - args[0].setDoorShut(y - 1, false); - } - else if (args[y] === 1) { - args[0].setDoorOpen(y - 1, false, false); - } - else { - args[0].setDoorBroken(y - 1, true); - } - } - } - }); - - mp.events.add("VehStream_SetVehicleWindowStatus_Single", (veh, windw, state) => { - if (veh === undefined || veh === null || !veh.isAVehicle()) return; - if (veh !== undefined) { - if (state === 1) { - veh.rollDownWindow(windw); - } - else if (state === 0) { - veh.fixWindow(windw); - veh.rollUpWindow(windw); - } - else { - veh.smashWindow(windw); - } - } - }); - - mp.events.add("VehStream_SetVehicleWindowStatus", (...args) => { - if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) { - let y = 0; - for (y = 1; y < 4; y++) { - if (args[y] === 1) { - args[0].rollDownWindow(y - 1); - } - else if (args[y] === 0) { - args[0].fixWindow(y - 1); - args[0].rollUpWindow(y - 1); - } - else { - args[0].smashWindow(y - 1); - } - } - } - }); - - mp.events.add("VehStream_SetVehicleWheelStatus_Single", (veh, wheel, state) => { - if (veh === undefined || veh === null || !veh.isAVehicle()) return; - if (veh !== undefined) { - if (wheel === 9) { - if (state === 1) { - veh.setTyreBurst(45, false, 1000); - } - else if (state === 0) { - veh.setTyreFixed(45); - } - else { - veh.setTyreBurst(45, true, 1000); - } - } - else if (wheel === 10) { - if (state === 1) { - veh.setTyreBurst(47, false, 1000); - } - else if (state === 0) { - veh.setTyreFixed(47); - } - else { - veh.setTyreBurst(47, true, 1000); - } - } - else { - if (state === 1) { - veh.setTyreBurst(wheel, false, 1000); - } - else if (state === 0) { - veh.setTyreFixed(wheel); - } - else { - veh.setTyreBurst(wheel, true, 1000); - } - } - } - }); - - mp.events.add("VehStream_SetVehicleWheelStatus", (...args) => { - if (args[0] !== undefined && args[0] !== null || !args[0].isAVehicle()) { - let y = 0; - for (y = 1; y < args.length; y++) { - if (y === 9) { - if (args[y] === 1) { - args[0].setTyreBurst(45, false, 1000); - } - else if (args[y] === 0) { - args[0].setTyreFixed(45); - } - else { - args[0].setTyreBurst(45, true, 1000); - } - } - else if (y === 10) { - if (args[y] === 1) { - args[0].setTyreBurst(47, false, 1000); - } - else if (args[y] === 0) { - args[0].setTyreFixed(47); - } - else { - args[0].setTyreBurst(47, true, 1000); - } - } - else { - if (args[y] === 1) { - args[0].setTyreBurst(y - 1, false, 1000); - } - else if (args[y] === 0) { - args[0].setTyreFixed(y - 1); - } - else { - args[0].setTyreBurst(y - 1, true, 1000); - } - } - } - } - }); - - //Sync data on stream in - mp.events.add("entityStreamIn", (entity) => { - if (entity === undefined || entity === null || !entity.isAVehicle()) return; - if (entity.type === "vehicle") { - let typeor = typeof entity.getVariable('VehicleSyncData'); - let actualData = entity.getVariable('VehicleSyncData'); - - //Needed to stop vehicles from freaking out - mp.game.streaming.requestCollisionAtCoord(entity.position.x, entity.position.y, entity.position.z); - //mp.game.invoke('0x199640F55E0F7596', entity.position.x, entity.position.y, entity.position.z); - entity.setLoadCollisionFlag(true); - entity.trackVisibility(); - - if (typeor !== 'undefined' && entity.isSeatFree(-1)) //Only if there is no driver - { - entity.position = actualData.Position; - entity.rotation = actualData.Rotation; - } - - //Set doors unbreakable for a moment - let x = 0; - for (x = 0; x < 8; x++) { - entity.setDoorBreakable(x, false); - } - - //Do it anyway - entity.setUndriveable(true); - - if (typeor !== 'undefined') { - entity.setEngineOn(actualData.Engine, true, false); - entity.setUndriveable(true); - - if (actualData.Locked) - entity.setDoorsLocked(2); - else - entity.setDoorsLocked(1); - - entity.setDirtLevel(actualData.Dirt); - - for (x = 0; x < 8; x++) { - if (actualData.Door[x] === 1) - entity.setDoorOpen(x, false, false); - else if (actualData.Door[x] === 0) - entity.setDoorShut(x, true); - else - entity.setDoorBroken(x, true); - } - - for (x = 0; x < 4; x++) { - if (actualData.Window[x] === 0) { - entity.fixWindow(x); - } - else if (actualData.Window[x] === 1) { - entity.rollDownWindow(x); - } - else { - entity.smashWindow(x); - } - } - - for (x = 0; x < 8; x++) { - if (actualData.Wheel[x] === 0) { - entity.setTyreFixed(x); - } - else if (actualData.Wheel[x] === 1) { - entity.setTyreBurst(x, false, 0); - } - else { - entity.setTyreBurst(x, true, 1000); - } - } - - //For trailer mid wheels - if (actualData.Wheel[8] === 0) { - entity.setTyreFixed(45); - } - else if (actualData.Wheel[8] === 1) { - entity.setTyreBurst(45, false, 0); - } - else { - entity.setTyreBurst(45, true, 1000); - } - - if (actualData.Wheel[9] === 0) { - entity.setTyreFixed(47); - } - else if (actualData.Wheel[9] === 1) { - entity.setTyreBurst(47, false, 0); - } - else { - entity.setTyreBurst(47, true, 1000); - } - } - - //Make doors breakable again - setTimeout(() => { - for (x = 0; x < 8; x++) { - if (entity) { - entity.setDoorBreakable(x, true); - } - } - }, 1500); - } - }); - - mp.events.add("vehsync:OpenCar", (bool) => { - if (bool) { - mp.game.audio.playSoundFrontend(1, "OPENED", "MP_PROPERTIES_ELEVATOR_DOORS", true); - } else { - mp.game.audio.playSoundFrontend(1, "CLOSED", "MP_PROPERTIES_ELEVATOR_DOORS", true); - } - - }); + var locked: boolean = data.Locked; + veh.setDoorsLocked(locked); } \ No newline at end of file diff --git a/ReallifeGamemode.DataService/Logic/JwtTokenGenerator.cs b/ReallifeGamemode.DataService/Logic/JwtTokenGenerator.cs index 53c9bb13..b4aef6de 100644 --- a/ReallifeGamemode.DataService/Logic/JwtTokenGenerator.cs +++ b/ReallifeGamemode.DataService/Logic/JwtTokenGenerator.cs @@ -11,6 +11,7 @@ using Microsoft.IdentityModel.Tokens; using ReallifeGamemode.Database; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.DataService.Logic { diff --git a/ReallifeGamemode.DataService/Types/GetUserDataResponse.cs b/ReallifeGamemode.DataService/Types/GetUserDataResponse.cs index de951ab9..7f6b7294 100644 --- a/ReallifeGamemode.DataService/Types/GetUserDataResponse.cs +++ b/ReallifeGamemode.DataService/Types/GetUserDataResponse.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.DataService.Types { diff --git a/ReallifeGamemode.Database/AdminLevel.cs b/ReallifeGamemode.Database/AdminLevel.cs deleted file mode 100644 index d484d95c..00000000 --- a/ReallifeGamemode.Database/AdminLevel.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -/** -* @overview Life of German Reallife - Admin Levels (AdminLevel.cs) -* @author VegaZ, hydrant -* @copyright (c) 2008 - 2018 Life of German -*/ - -namespace ReallifeGamemode.Database -{ - public enum AdminLevel : int - { - PLAYER = 0, - MAPPING = 1, - ENTWICKLUNG = 2, - SUPPORTER = 3, - ADMIN = 4, - ADMIN2 = 5, - ADMIN3 = 6, - HEADADMIN = 1337, - PROJEKTLEITUNG = 1338 - } -} diff --git a/ReallifeGamemode.Database/Entities/User.cs b/ReallifeGamemode.Database/Entities/User.cs index d4570709..fec8b401 100644 --- a/ReallifeGamemode.Database/Entities/User.cs +++ b/ReallifeGamemode.Database/Entities/User.cs @@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using GTANetworkAPI; using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Entities User (User.cs) diff --git a/ReallifeGamemode.Database/GroupRanks.cs b/ReallifeGamemode.Database/GroupRanks.cs deleted file mode 100644 index 9a8d89da..00000000 --- a/ReallifeGamemode.Database/GroupRanks.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ReallifeGamemode.Database -{ - public enum GroupRank - { - NONE, - MEMBER, - MANAGER, - OWNER - } -} diff --git a/ReallifeGamemode.Database/ReallifeGamemode.Database.csproj b/ReallifeGamemode.Database/ReallifeGamemode.Database.csproj index 4af8ed0d..e74ff86b 100644 --- a/ReallifeGamemode.Database/ReallifeGamemode.Database.csproj +++ b/ReallifeGamemode.Database/ReallifeGamemode.Database.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netstandard2.1 AnyCPU;x64 8.0 @@ -17,6 +17,7 @@ + diff --git a/ReallifeGamemode.Server.Core.API/Color.cs b/ReallifeGamemode.Server.Core.API/Color.cs index fe34d597..0f3e54d7 100644 --- a/ReallifeGamemode.Server.Core.API/Color.cs +++ b/ReallifeGamemode.Server.Core.API/Color.cs @@ -6,6 +6,8 @@ namespace ReallifeGamemode.Server.Core.API { public struct Color { + public static Color White => new Color(255, 255, 255); + public int R { get; set; } public int G { get; set; } diff --git a/ReallifeGamemode.Server.Core.API/IAPI.cs b/ReallifeGamemode.Server.Core.API/IAPI.cs index 08f3d215..ecbcf353 100644 --- a/ReallifeGamemode.Server.Core.API/IAPI.cs +++ b/ReallifeGamemode.Server.Core.API/IAPI.cs @@ -15,6 +15,8 @@ namespace ReallifeGamemode.Server.Core.API IMarkerAPI Marker { get; } + ITextLabelAPI TextLabel { get; } + void DisableDefaultCommandErrorMessages(); void DisableDefaultSpawnBehavior(); diff --git a/ReallifeGamemode.Server.Core.API/IColShape.cs b/ReallifeGamemode.Server.Core.API/IColShape.cs index ba194363..ff2ebeb8 100644 --- a/ReallifeGamemode.Server.Core.API/IColShape.cs +++ b/ReallifeGamemode.Server.Core.API/IColShape.cs @@ -6,7 +6,7 @@ namespace ReallifeGamemode.Server.Core.API { public interface IColShape : IEntity { - delegate void ColShapeEvent(IColShape colShape, IEntity entity); + delegate void ColShapeEvent(IColShape colShape, IPlayer entity); event ColShapeEvent OnEntityEnter; event ColShapeEvent OnEntityExit; diff --git a/ReallifeGamemode.Server.Core.API/ITextLabel.cs b/ReallifeGamemode.Server.Core.API/ITextLabel.cs new file mode 100644 index 00000000..6e2a32e8 --- /dev/null +++ b/ReallifeGamemode.Server.Core.API/ITextLabel.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ReallifeGamemode.Server.Core.API +{ + public interface ITextLabel : IEntity + { + string Text { get; set; } + } +} diff --git a/ReallifeGamemode.Server.Core.API/ITextLabelAPI.cs b/ReallifeGamemode.Server.Core.API/ITextLabelAPI.cs new file mode 100644 index 00000000..a06c6755 --- /dev/null +++ b/ReallifeGamemode.Server.Core.API/ITextLabelAPI.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReallifeGamemode.Server.Types; + +namespace ReallifeGamemode.Server.Core.API +{ + public interface ITextLabelAPI + { + ITextLabel CreateTextLabel(string text, Position position, float range, float size, Font font, Color color); + } +} diff --git a/ReallifeGamemode.Server.Core.Extensions/PlayerExtensions.cs b/ReallifeGamemode.Server.Core.Extensions/PlayerExtensions.cs new file mode 100644 index 00000000..a3b8d524 --- /dev/null +++ b/ReallifeGamemode.Server.Core.Extensions/PlayerExtensions.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using ReallifeGamemode.Database.Entities; +using ReallifeGamemode.Database.Models; +using ReallifeGamemode.Server.Core.API; +using ReallifeGamemode.Server.Types; + +namespace ReallifeGamemode.Server.Core.Extensions +{ + public static class PlayerExtensions + { + public static User GetUser(this IPlayer player, DatabaseContext dbContext) + { + if (player == null) + { + return null; + } + + return dbContext.Users.Where(u => u.Name == player.Name).FirstOrDefault(); + } + + public static AdminLevel GetAdminLevel(this IPlayer player, DatabaseContext dbContext) + { + return player.GetData(u => u.AdminLevel, dbContext); + } + + public static TData GetData(this IPlayer player, Expression> data, DatabaseContext dbContext) + { + if (player == null) + { + return default; + } + + return dbContext.Users.Where(u => u.Name == player.Name).Select(data).FirstOrDefault(); + } + } +} diff --git a/ReallifeGamemode.Server.Core.Extensions/ReallifeGamemode.Server.Core.Extensions.csproj b/ReallifeGamemode.Server.Core.Extensions/ReallifeGamemode.Server.Core.Extensions.csproj new file mode 100644 index 00000000..f96fa05f --- /dev/null +++ b/ReallifeGamemode.Server.Core.Extensions/ReallifeGamemode.Server.Core.Extensions.csproj @@ -0,0 +1,13 @@ + + + + netstandard2.1 + + + + + + + + + diff --git a/ReallifeGamemode.Server.Core.RageMP/RageAPI.cs b/ReallifeGamemode.Server.Core.RageMP/RageAPI.cs index 4e09b3f5..38beb468 100644 --- a/ReallifeGamemode.Server.Core.RageMP/RageAPI.cs +++ b/ReallifeGamemode.Server.Core.RageMP/RageAPI.cs @@ -14,6 +14,8 @@ namespace ReallifeGamemode.Server.Core.RageMP public IMarkerAPI Marker => new RageMarkerAPI(); + public ITextLabelAPI TextLabel => new RageTextLabelAPI(); + public void DisableDefaultCommandErrorMessages() { NAPI.Server.SetCommandErrorMessage(null); diff --git a/ReallifeGamemode.Server.Core.RageMP/RageColShapeAPI.cs b/ReallifeGamemode.Server.Core.RageMP/RageColShapeAPI.cs index 75298ec6..b7f59c6e 100644 --- a/ReallifeGamemode.Server.Core.RageMP/RageColShapeAPI.cs +++ b/ReallifeGamemode.Server.Core.RageMP/RageColShapeAPI.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using GTANetworkAPI; using ReallifeGamemode.Server.Core.API; using ReallifeGamemode.Server.Core.API.API; @@ -10,12 +11,14 @@ namespace ReallifeGamemode.Server.Core.RageMP { public IColShape CreateCyclinder(Position position, float height, float range) { - throw new NotImplementedException(); + var colShape = NAPI.ColShape.CreateCylinderColShape(position.ToVector3(), range, height); + return new RageColShape(colShape); } public IColShape CreateSphere(Position position, float range) { - throw new NotImplementedException(); + var colShape = NAPI.ColShape.CreateSphereColShape(position.ToVector3(), range); + return new RageColShape(colShape); } } } diff --git a/ReallifeGamemode.Server.Core.RageMP/RageTextLabel.cs b/ReallifeGamemode.Server.Core.RageMP/RageTextLabel.cs new file mode 100644 index 00000000..c7b623d4 --- /dev/null +++ b/ReallifeGamemode.Server.Core.RageMP/RageTextLabel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Server.Core.API; + +namespace ReallifeGamemode.Server.Core.RageMP +{ + public class RageTextLabel : RageEntity, ITextLabel + { + private TextLabel textLabel; + + public string Text { get => textLabel.Text; set => textLabel.Text = value; } + + public RageTextLabel(TextLabel textLabel) : base(textLabel) + { + this.textLabel = textLabel; + } + } +} diff --git a/ReallifeGamemode.Server.Core.RageMP/RageTextLabelAPI.cs b/ReallifeGamemode.Server.Core.RageMP/RageTextLabelAPI.cs new file mode 100644 index 00000000..9c036cd5 --- /dev/null +++ b/ReallifeGamemode.Server.Core.RageMP/RageTextLabelAPI.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; +using ReallifeGamemode.Server.Core.API; +using ReallifeGamemode.Server.Types; + +namespace ReallifeGamemode.Server.Core.RageMP +{ + public class RageTextLabelAPI : ITextLabelAPI + { + public ITextLabel CreateTextLabel(string text, Position position, float range, float size, Font font, API.Color color) + { + TextLabel textLabel = NAPI.TextLabel.CreateTextLabel(text, position.ToVector3(), range, size, (int)font, color.ToColor()); + + return new RageTextLabel(textLabel); + } + } +} diff --git a/ReallifeGamemode.Server.Core/Commands/Admin/AdminCommand.cs b/ReallifeGamemode.Server.Core/Commands/Admin/AdminCommand.cs new file mode 100644 index 00000000..23eb9c9c --- /dev/null +++ b/ReallifeGamemode.Server.Core/Commands/Admin/AdminCommand.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReallifeGamemode.Server.Core.API; + +namespace ReallifeGamemode.Server.Core.Commands.Admin +{ + abstract class AdminCommand : Command + { + + public override bool CanExecute(IPlayer player) + { + throw new NotImplementedException(); + } + } +} diff --git a/ReallifeGamemode.Server.Core/Managers/VehicleManager.cs b/ReallifeGamemode.Server.Core/Managers/VehicleManager.cs new file mode 100644 index 00000000..94b30f91 --- /dev/null +++ b/ReallifeGamemode.Server.Core/Managers/VehicleManager.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReallifeGamemode.Server.Core.API; +using ReallifeGamemode.Server.Types; +using ReallifeGamemode.Server.Common; + +namespace ReallifeGamemode.Server.Core.Managers +{ + internal class VehicleManager : Script + { + private const string DataKey = "VehicleData"; + + public VehicleManager() + { + + } + + public void SetEngineState(IVehicle veh, bool state) + { + var data = GetData(veh); + data.EngineState = state; + SetData(veh, data); + } + + public bool GetEngineState(IVehicle veh) + { + return GetData(veh).EngineState; + } + + public void SetLocked(IVehicle veh, bool state) + { + var data = GetData(veh); + data.Locked = state; + SetData(veh, data); + } + + public bool IsLocked(IVehicle veh) + { + return GetData(veh).Locked; + } + + public VehicleData GetData(IVehicle veh) + { + return veh.GetSharedData(DataKey, new VehicleData()); + } + + public void SetData(IVehicle veh, VehicleData data) + { + if (data is null) + { + throw new ArgumentNullException(nameof(data)); + } + + veh.SetSharedData(DataKey, data); + Api.TriggerClientEventForAll("Vehicle:UpdateData", veh.Handle, data.SerializeJson()); + } + } +} diff --git a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs index efaa338d..4af5ec40 100644 --- a/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs +++ b/ReallifeGamemode.Server.Core/Menus/PoliceDepartment.cs @@ -1,12 +1,40 @@ using System; using System.Collections.Generic; using System.Text; +using ReallifeGamemode.Server.Core.API; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Core.Menus { internal class PoliceDepartment : Script { + + public PoliceDepartment() + { + // Marker position: 440.869 -981.045 30.689 + + CreateVisuals(); + } + + private void CreateVisuals() + { + Position pos = new Position(440.869, -981.045, 30.689); + + Api.TextLabel.CreateTextLabel("Polizeirevier\n\nDrücke ~y~E~s~, um das Menü zu öffnen", pos, 20f, 1.3f, Font.ChaletLondon, Color.White); + Api.Marker.CreateMarker(MarkerType.VerticalCylinder, pos.Subtract(new Position(0, 0, 1.5)), new Position(), new Position(), 1f, new Color()); + IColShape colShape = Api.ColShape.CreateSphere(pos.Subtract(new Position(0, 0, 1.5)), 3f); + + colShape.OnEntityEnter += OnPlayerEnterPoliceDepartment; + colShape.OnEntityExit += OnPlayerExitPoliceDepartment; + } + + private void OnPlayerEnterPoliceDepartment(IColShape colShape, IPlayer player) + { + + } + + private void OnPlayerExitPoliceDepartment(IColShape colShape, IPlayer player) { } diff --git a/ReallifeGamemode.Server.Types/AdminLevel.cs b/ReallifeGamemode.Server.Types/AdminLevel.cs index 816e989e..64fd637b 100644 --- a/ReallifeGamemode.Server.Types/AdminLevel.cs +++ b/ReallifeGamemode.Server.Types/AdminLevel.cs @@ -7,21 +7,14 @@ namespace ReallifeGamemode.Server.Types { public enum AdminLevel { - [EnumMember(Value = "None")] - None = 0, - [EnumMember(Value = "Team")] - Team = 1, - [EnumMember(Value = "Supporter")] - Support = 2, - [EnumMember(Value = "Administrator (1)")] - Admin_1 = 3, - [EnumMember(Value = "Administrator (2)")] - Admin_2 = 4, - [EnumMember(Value = "Administrator (3)")] - Admin_3 = 5, - [EnumMember(Value = "Head-Administrator")] - Headadmin = 6, - [EnumMember(Value = "Projektleiter")] - Project_Lead = 7, + PLAYER = 0, + MAPPING = 1, + ENTWICKLUNG = 2, + SUPPORTER = 3, + ADMIN = 4, + ADMIN2 = 5, + ADMIN3 = 6, + HEADADMIN = 1337, + PROJEKTLEITUNG = 1338 } } diff --git a/ReallifeGamemode.Server.Types/Font.cs b/ReallifeGamemode.Server.Types/Font.cs new file mode 100644 index 00000000..3da8b0ed --- /dev/null +++ b/ReallifeGamemode.Server.Types/Font.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ReallifeGamemode.Server.Types +{ + public enum Font + { + ChaletLondon = 0, + HouseScript = 1, + Monospacec = 2, + CharletComprimeColonge = 4, + Pricedown = 7 + } +} diff --git a/ReallifeGamemode.Server.Types/GroupRank.cs b/ReallifeGamemode.Server.Types/GroupRank.cs index 77d42a6f..038af7bd 100644 --- a/ReallifeGamemode.Server.Types/GroupRank.cs +++ b/ReallifeGamemode.Server.Types/GroupRank.cs @@ -7,12 +7,9 @@ namespace ReallifeGamemode.Server.Types { public enum GroupRank { - None, - [EnumMember(Value = "Mitglied")] - Member, - [EnumMember(Value = "Manager")] - Manager, - [EnumMember(Value = "Leiter")] - Leader + NONE, + MEMBER, + MANAGER, + OWNER } } diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index d7a9e899..029e61e2 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Admin Commands (Admin.cs) @@ -31,7 +32,7 @@ namespace ReallifeGamemode.Server.Commands { public class AdminCommands : Script { - + #region Todo [Command("eat", "~m~Benutzung: ~s~/eat [Item]")] public void CmdAdminEat(Player player, string item) @@ -137,35 +138,35 @@ namespace ReallifeGamemode.Server.Commands } else { - switch (player.GetUser().AdminLevel) - { - case AdminLevel.MAPPING: + switch (player.GetUser().AdminLevel) + { + case AdminLevel.MAPPING: ChatService.SendMessage(player, "~b~ " + "/team, /tc, /position"); break; - case AdminLevel.ENTWICKLUNG: + case AdminLevel.ENTWICKLUNG: ChatService.SendMessage(player, "~b~ " + "/team, /tc, /position"); break; - case AdminLevel.SUPPORTER: + case AdminLevel.SUPPORTER: ChatService.SendMessage(player, "~b~ " + "/tsupport, /showtickets, /rc, /rc quit, /o, /pm, /dimension, /to, /gh, /clearchat, /skick"); break; - case AdminLevel.ADMIN: + case AdminLevel.ADMIN: ChatService.SendMessage(player, "~b~ " + "/a, /countdown, /freeze, /unfreeze, /mark, /gotmark, /gotox, /up, /setdimension, /spec, /warn, /ip, /kick, /ban /unban, /slap, /takeweapon, /tov, /ghv, /factionlist, /businesslist, /joblist"); break; - case AdminLevel.ADMIN2: + case AdminLevel.ADMIN2: ChatService.SendMessage(player, "~b~ " + "/sethp, /setarmor, /arevive, /aunjail, /aclear, /clothes, /props,/aclear"); break; - case AdminLevel.ADMIN3: + case AdminLevel.ADMIN3: ChatService.SendMessage(player, "~b~ " + "/adice, /settime, /setweather, /rsetarmor, /rgiveweapon, /giveweapon, /veh, /fv, /vfix, /vdestroy, /vlivery, /vcolor, /vehsmoke, /aneon, /mod, /showtuningmenu, /rvdestroy, /vsethp"); break; - case AdminLevel.HEADADMIN: + case AdminLevel.HEADADMIN: ChatService.SendMessage(player, "~b~ " + "/aspeed, /set, /setmoney, /givemoney, /sethandmoney, /givehandmoney, /paydaydrop, /setwage, /freekh, /ainvite, /makeleader, /managefactionranks, /setweaponrack, /rmweaponrack, /setweaponrank, /giveitem, /inventory, /save, /remove, /house, /setbusinessbankbalance, /reloaddors, /interior, /editmode, /setbliptemplate, /ipl, /load, /quicksavemode, /createturf, /setturf, /cancleturf, /reloadturfs, /deleteturfs, /setturfpoint"); break; - case AdminLevel.PROJEKTLEITUNG: + case AdminLevel.PROJEKTLEITUNG: ChatService.SendMessage(player, "~b~ " + "/makeadmin, /whitelist, /blind"); break; - } + } } - + } @@ -264,7 +265,7 @@ namespace ReallifeGamemode.Server.Commands } } } - + [Command("aduty", "~m~Benutzung: ~s~/aduty")] public void CmdAduty(Player player) { @@ -485,7 +486,7 @@ namespace ReallifeGamemode.Server.Commands } - + [Command("gotolist", "~m~Benutzung: ~s~/gotolist")] //TODO Als Browser anzeigeN?? public void CmdAdminGotoList(Player player) @@ -826,7 +827,7 @@ namespace ReallifeGamemode.Server.Commands else player.Position = new Vector3(x, y, z); } - + [Command("slap", "~m~Benutzung: ~s~/slap [Spieler] (Höhe)")] public void CmdAdminSlap(Player player, string name, int wert = 5) { @@ -990,7 +991,7 @@ namespace ReallifeGamemode.Server.Commands return; } - if(name == null || component == null || drawable == null) + if (name == null || component == null || drawable == null) { player.SendChatMessage("~m~Benutzung: ~s~/clothes [Spieler] [Component ID] [Drawable] (Textur)"); return; @@ -2537,7 +2538,7 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast das Geld von " + target.Name + " auf ~g~$" + amount + "~s~ gesetzt."); ChatService.SendMessage(target, "~b~[ADMIN]~s~ Dein Geld wurde von Admin " + player.Name + " auf ~g~$" + amount + "~s~ gesetzt."); } - + [Command("givemoney", "~m~Benutzung: ~s~/givemoney [Name] [Menge]")] public void GivePlayerMoney(Player player, string receiver, int amount) { diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index f9372e7b..54e952b8 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -4,6 +4,7 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using System; using System.Linq; diff --git a/ReallifeGamemode.Server/Events/Connect.cs b/ReallifeGamemode.Server/Events/Connect.cs index 12cf9342..d84a25af 100644 --- a/ReallifeGamemode.Server/Events/Connect.cs +++ b/ReallifeGamemode.Server/Events/Connect.cs @@ -4,6 +4,7 @@ using GTANetworkAPI; using ReallifeGamemode.Database; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Wanted; diff --git a/ReallifeGamemode.Server/Events/Death.cs b/ReallifeGamemode.Server/Events/Death.cs index 7200f8e2..69410223 100644 --- a/ReallifeGamemode.Server/Events/Death.cs +++ b/ReallifeGamemode.Server/Events/Death.cs @@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Services; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Wanted; diff --git a/ReallifeGamemode.Server/Events/Disconnect.cs b/ReallifeGamemode.Server/Events/Disconnect.cs index 43b4fec3..174d1d47 100644 --- a/ReallifeGamemode.Server/Events/Disconnect.cs +++ b/ReallifeGamemode.Server/Events/Disconnect.cs @@ -10,6 +10,7 @@ using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Event Login (Login.cs) diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 8652f8c4..1a234e13 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -15,6 +15,7 @@ using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.DrivingSchool; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Event Key (Key.cs) * @author VegaZ @@ -326,11 +327,11 @@ namespace ReallifeGamemode.Server.Events } player.TriggerEvent("showElevatorMenu", JsonConvert.SerializeObject(stages.ToArray())); } - if(nearestClotheShopPoint != null) + if (nearestClotheShopPoint != null) { nearestClotheShopPoint.clotheShop.LoadShopNUI(player); } - if(nearestItemShopPoint != null) + if (nearestItemShopPoint != null) { nearestItemShopPoint.itemShop.LoadShopNUI(player); } diff --git a/ReallifeGamemode.Server/Events/Login.cs b/ReallifeGamemode.Server/Events/Login.cs index 698d3784..74431a64 100644 --- a/ReallifeGamemode.Server/Events/Login.cs +++ b/ReallifeGamemode.Server/Events/Login.cs @@ -8,6 +8,7 @@ using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Event Login (Login.cs) diff --git a/ReallifeGamemode.Server/Events/Vehicle.cs b/ReallifeGamemode.Server/Events/Vehicle.cs index 3716c620..d2c2c701 100644 --- a/ReallifeGamemode.Server/Events/Vehicle.cs +++ b/ReallifeGamemode.Server/Events/Vehicle.cs @@ -3,6 +3,7 @@ using ReallifeGamemode.Database; using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using System; @@ -105,7 +106,7 @@ namespace ReallifeGamemode.Server.Events return; } } - else if(sV is JobVehicle) + else if (sV is JobVehicle) { return; } @@ -124,7 +125,7 @@ namespace ReallifeGamemode.Server.Events else if (!player.IsInVehicle) { GTANetworkAPI.Vehicle vehicle = null; - foreach(var veh in NAPI.Pools.GetAllVehicles()) + foreach (var veh in NAPI.Pools.GetAllVehicles()) { if (player.Position.DistanceTo(veh.Position) <= 3f) { diff --git a/ReallifeGamemode.Server/Extensions/EnumExtensions.cs b/ReallifeGamemode.Server/Extensions/EnumExtensions.cs index 2f5d5d10..04b1ef33 100644 --- a/ReallifeGamemode.Server/Extensions/EnumExtensions.cs +++ b/ReallifeGamemode.Server/Extensions/EnumExtensions.cs @@ -1,9 +1,10 @@ using ReallifeGamemode.Server.Util; -using static ReallifeGamemode.Database.AdminLevel; using System; using System.Collections.Generic; using System.Text; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; +using static ReallifeGamemode.Server.Types.AdminLevel; namespace ReallifeGamemode.Server.Extensions { diff --git a/ReallifeGamemode.Server/Job/TaxiDriverJob.cs b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs index 867aeae2..d70ba2bb 100644 --- a/ReallifeGamemode.Server/Job/TaxiDriverJob.cs +++ b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs @@ -11,6 +11,7 @@ using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Database.Entities; using System.Linq; using Newtonsoft.Json; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Job { @@ -100,7 +101,7 @@ namespace ReallifeGamemode.Server.Job private static void UpdateFare(object sender, ElapsedEventArgs e) { - foreach(var player in GetPlayerInJob()) + foreach (var player in GetPlayerInJob()) { if (!player.HasData("hasPassager")) { player.SetData("hasPassager", false); continue; } int playerId = player.GetUser().Id; @@ -112,15 +113,15 @@ namespace ReallifeGamemode.Server.Job lastPositions[v.Handle] = v.Position; double distance = lastPosition.DistanceTo(v.Position) / 1000.0; - if (distance > 0.5) { ChatService.BroadcastAdmin($"Möglicher Cheater - {player.Name}", Database.AdminLevel.MAPPING); continue; } + if (distance > 0.5) { ChatService.BroadcastAdmin($"Möglicher Cheater - {player.Name}", AdminLevel.MAPPING); continue; } if (!player.GetData("hasPassager")) continue; foreach (Player occupant in v.Occupants) { occupant.TriggerEvent("CLIENT:updateFare", JsonConvert.SerializeObject(distance)); } - + } } - + } } diff --git a/ReallifeGamemode.Server/Managers/BusinessManager.cs b/ReallifeGamemode.Server/Managers/BusinessManager.cs index 409557fa..378cc3d2 100644 --- a/ReallifeGamemode.Server/Managers/BusinessManager.cs +++ b/ReallifeGamemode.Server/Managers/BusinessManager.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Managers { diff --git a/ReallifeGamemode.Server/Managers/CityHallManager.cs b/ReallifeGamemode.Server/Managers/CityHallManager.cs index 5d8680cf..2aaaff9a 100644 --- a/ReallifeGamemode.Server/Managers/CityHallManager.cs +++ b/ReallifeGamemode.Server/Managers/CityHallManager.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Managers { @@ -19,7 +20,7 @@ namespace ReallifeGamemode.Server.Managers public static void LoadCityHall() { - NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255)); + NAPI.Marker.CreateMarker(GTANetworkAPI.MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255)); NAPI.TextLabel.CreateTextLabel("~y~Stadthalle~s~\nDrücke ~o~E~s~, um das Menü zu öffnen", _cityHallPosition, 5.0f, 1f, 0, new Color(255, 255, 255)); var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f); colShape.OnEntityEnterColShape += (s, c) => diff --git a/ReallifeGamemode.Server/Managers/DoorManager.cs b/ReallifeGamemode.Server/Managers/DoorManager.cs index 6bdd9f14..fb6caef3 100644 --- a/ReallifeGamemode.Server/Managers/DoorManager.cs +++ b/ReallifeGamemode.Server/Managers/DoorManager.cs @@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Util; using ReallifeGamemode.Database; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Managers BankManager (BankManager.cs) * @author VegaZ diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index ee57ae6f..20bae711 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Text; using ReallifeGamemode.Database; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Types; /** * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) diff --git a/ReallifeGamemode.Server/Report/Report.cs b/ReallifeGamemode.Server/Report/Report.cs index c21d40d7..9e26389f 100644 --- a/ReallifeGamemode.Server/Report/Report.cs +++ b/ReallifeGamemode.Server/Report/Report.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using ReallifeGamemode.Database; using ReallifeGamemode.Services; +using ReallifeGamemode.Server.Types; namespace ReallifeGamemode.Server.Report { diff --git a/ReallifeGamemode.Server/Services/ChatService.cs b/ReallifeGamemode.Server/Services/ChatService.cs index 5ade5fbe..3679f346 100644 --- a/ReallifeGamemode.Server/Services/ChatService.cs +++ b/ReallifeGamemode.Server/Services/ChatService.cs @@ -4,6 +4,7 @@ using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Job; +using ReallifeGamemode.Server.Types; using ReallifeGamemode.Server.Util; using System; using System.Collections.Generic; diff --git a/ReallifeGamemode.Services/ReallifeGamemode.Services.csproj b/ReallifeGamemode.Services/ReallifeGamemode.Services.csproj index 0ee579bc..e3664574 100644 --- a/ReallifeGamemode.Services/ReallifeGamemode.Services.csproj +++ b/ReallifeGamemode.Services/ReallifeGamemode.Services.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netstandard2.1 Debug;Release;ServerBuild x64 AnyCPU;x64 diff --git a/ReallifeGamemode.sln b/ReallifeGamemode.sln index beed96b1..befa7325 100644 --- a/ReallifeGamemode.sln +++ b/ReallifeGamemode.sln @@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReallifeGamemode.Server.Cor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReallifeGamemode.Server.Log", "ReallifeGamemode.Server.Log\ReallifeGamemode.Server.Log.csproj", "{1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReallifeGamemode.Server.Core.Extensions", "ReallifeGamemode.Server.Core.Extensions\ReallifeGamemode.Server.Core.Extensions.csproj", "{C21396B2-31D3-47C5-8D87-651FA16E60FD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -193,6 +195,18 @@ Global {1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}.ServerBuild|Any CPU.Build.0 = Debug|Any CPU {1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}.ServerBuild|x64.ActiveCfg = Debug|Any CPU {1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}.ServerBuild|x64.Build.0 = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Debug|x64.ActiveCfg = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Debug|x64.Build.0 = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Release|Any CPU.Build.0 = Release|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Release|x64.ActiveCfg = Release|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.Release|x64.Build.0 = Release|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.ServerBuild|Any CPU.ActiveCfg = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.ServerBuild|Any CPU.Build.0 = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.ServerBuild|x64.ActiveCfg = Debug|Any CPU + {C21396B2-31D3-47C5-8D87-651FA16E60FD}.ServerBuild|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE