Add changes

This commit is contained in:
hydrant
2020-03-12 19:19:42 +01:00
parent 06c2a2092f
commit 5e3bc39275
43 changed files with 390 additions and 642 deletions

View File

@@ -161,8 +161,7 @@ sirenSilence();
import waypointUtil from './util/waypoint'; import waypointUtil from './util/waypoint';
waypointUtil(); waypointUtil();
import vehicleSync from './vehiclesync/vehiclesync'; require('./vehiclesync/vehiclesync');
vehicleSync();
import smoothThrottle from './vehiclesync/smoothtrottle'; import smoothThrottle from './vehiclesync/smoothtrottle';
smoothThrottle(); smoothThrottle();
@@ -202,3 +201,12 @@ itemShopList(globalData);
import taximeterInput from './Gui/taximeter'; import taximeterInput from './Gui/taximeter';
taximeterInput(globalData); taximeterInput(globalData);
interface VehicleData {
EngineState: boolean;
Locked: boolean;
}
export {
VehicleData
}

View File

@@ -1,560 +1,75 @@
//Disapproved by the entire planet import game, { VehicleData } from '../index';
//You don't need to worry about anything here import { IVehicle, EntityType, IEntity, VehicleSeat } from '../game';
export default function vehicleSync() { import { parseJson } from '../util';
mp.events.add("VehStream_SetEngineStatus", (veh, status) => {
if (veh === undefined || veh === null || !veh.isAVehicle()) return; game.events.add('SERVER:Vehicle:UpdateData', (vehId, dataStr) => {
if (veh !== undefined) { var data: VehicleData = parseJson(dataStr);
if (veh.isSeatFree(-1)) //Turns engine on instantly if no driver, otherwise it will not turn on var vehicle: IVehicle = game.vehicles.at(vehId);
{
veh.setEngineOn(status, true, false); setVehicleData(vehicle, data);
veh.setUndriveable(true); });
}
else { game.events.onPlayerEnterVehicle((vehicle, seat) => {
veh.setEngineOn(status, false, true); while (!game.players.local.inVehicle) {
veh.setUndriveable(!status); game.wait(0);
} }
if (vehicle) {
var data: VehicleData = vehicle.getSharedData("VehicleData");
setVehicleData(vehicle, data);
} }
}); });
mp.events.add("VehStream_SetLockStatus", (veh, status) => { game.events.onPlayerExitVehicle(() => {
if (veh === undefined || veh === null || !veh.isAVehicle()) return; var veh = game.players.local.vehicle;
if (veh !== undefined) { while (game.players.local.inVehicle) {
if (status) game.wait(0);
veh.setDoorsLocked(2); }
else
veh.setDoorsLocked(1); if (veh) {
var data: VehicleData = veh.getSharedData("VehicleData");
setVehicleData(veh, data);
} }
}); });
mp.events.add("VehStream_PlayerEnterVehicleAttempt", (entity, seat) => { game.events.onEntityStreamIn((entity: IEntity) => {
entity = mp.vehicles.atRemoteId(entity); if (entity && entity.type === EntityType.Vehicle) {
if (entity === undefined || entity === null || !entity.isAVehicle()) return; var data: VehicleData = entity.getSharedData("VehicleData");
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') {
var toggle = entity.getVariable("VehicleSyncData"); var vehicle = <IVehicle>entity;
entity.setEngineOn(toggle.Engine, false, true); setVehicleData(vehicle, data);
entity.setUndriveable(!toggle.Engine);
entity.setInvincible(false);
} }
}); });
mp.events.add("VehStream_PlayerExitVehicleAttempt", (entity) => { function setVehicleData(veh: IVehicle, data: VehicleData): void {
if (entity === undefined || entity === null || !entity.isAVehicle()) return; game.ui.sendChatMessage("setVehicleData");
if (entity !== undefined) { if (!veh) {
if (typeof entity.getVariable("VehicleSyncData") !== 'undefined') { game.ui.sendChatMessage("veh is null");
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);
}
});
mp.events.add("VehStream_PlayerExitVehicle", (entity) => {
entity = mp.vehicles.atRemoteId(entity);
if (entity === undefined || entity === null || !entity.isAVehicle()) {
return; 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 = []; game.ui.sendChatMessage("veh is not null");
if (entity.isWindowIntact(0)) { if (data === null) {
if (entity.getBoneIndexByName("window_rf") === -1) { game.ui.sendChatMessage("data is null");
Status.push(1); data = {
} EngineState: false,
else { Locked: false
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]);
Status = [];
if (!entity.isTyreBurst(0, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(0, false)) {
Status.push(1);
}
else {
Status.push(2);
} }
if (!entity.isTyreBurst(1, false)) { game.ui.sendChatMessage(`engine: ${data.EngineState}, locked: ${data.Locked}`);
Status.push(0);
}
else if (entity.isTyreBurst(1, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(2, false)) { var engineState = data.EngineState;
Status.push(0); if (veh.isSeatFree(VehicleSeat.Driver)) {
} veh.setEngineStatus(engineState, true, false);
else if (entity.isTyreBurst(2, false)) { veh.setUndriveable(true);
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(3, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(3, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(4, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(4, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(5, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(5, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(6, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(6, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(7, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(7, false)) {
Status.push(1);
}
else {
Status.push(2);
}
if (!entity.isTyreBurst(45, false)) {
Status.push(0);
}
else if (entity.isTyreBurst(45, false)) {
Status.push(1);
}
else {
Status.push(2);
}
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 { } else {
mp.game.audio.playSoundFrontend(1, "CLOSED", "MP_PROPERTIES_ELEVATOR_DOORS", true); veh.setEngineStatus(engineState, false, true);
veh.setUndriveable(!engineState);
} }
}); var locked: boolean = data.Locked;
veh.setDoorsLocked(locked);
} }

View File

@@ -11,6 +11,7 @@ using Microsoft.IdentityModel.Tokens;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.DataService.Logic namespace ReallifeGamemode.DataService.Logic
{ {

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.DataService.Types namespace ReallifeGamemode.DataService.Types
{ {

View File

@@ -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
}
}

View File

@@ -4,6 +4,7 @@ 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.Types;
/** /**
* @overview Life of German Reallife - Entities User (User.cs) * @overview Life of German Reallife - Entities User (User.cs)

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ReallifeGamemode.Database
{
public enum GroupRank
{
NONE,
MEMBER,
MANAGER,
OWNER
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<LangVersion>8.0</LangVersion> <LangVersion>8.0</LangVersion>
</PropertyGroup> </PropertyGroup>
@@ -17,6 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<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>

View File

@@ -6,6 +6,8 @@ namespace ReallifeGamemode.Server.Core.API
{ {
public struct Color public struct Color
{ {
public static Color White => new Color(255, 255, 255);
public int R { get; set; } public int R { get; set; }
public int G { get; set; } public int G { get; set; }

View File

@@ -15,6 +15,8 @@ namespace ReallifeGamemode.Server.Core.API
IMarkerAPI Marker { get; } IMarkerAPI Marker { get; }
ITextLabelAPI TextLabel { get; }
void DisableDefaultCommandErrorMessages(); void DisableDefaultCommandErrorMessages();
void DisableDefaultSpawnBehavior(); void DisableDefaultSpawnBehavior();

View File

@@ -6,7 +6,7 @@ namespace ReallifeGamemode.Server.Core.API
{ {
public interface IColShape : IEntity public interface IColShape : IEntity
{ {
delegate void ColShapeEvent(IColShape colShape, IEntity entity); delegate void ColShapeEvent(IColShape colShape, IPlayer entity);
event ColShapeEvent OnEntityEnter; event ColShapeEvent OnEntityEnter;
event ColShapeEvent OnEntityExit; event ColShapeEvent OnEntityExit;

View File

@@ -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; }
}
}

View File

@@ -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);
}
}

View File

@@ -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<TData>(this IPlayer player, Expression<Func<User, TData>> data, DatabaseContext dbContext)
{
if (player == null)
{
return default;
}
return dbContext.Users.Where(u => u.Name == player.Name).Select(data).FirstOrDefault();
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ReallifeGamemode.Database\ReallifeGamemode.Database.csproj" />
<ProjectReference Include="..\ReallifeGamemode.Server.Core.API\ReallifeGamemode.Server.Core.API.csproj" />
<ProjectReference Include="..\ReallifeGamemode.Server.Types\ReallifeGamemode.Server.Types.csproj" />
</ItemGroup>
</Project>

View File

@@ -14,6 +14,8 @@ namespace ReallifeGamemode.Server.Core.RageMP
public IMarkerAPI Marker => new RageMarkerAPI(); public IMarkerAPI Marker => new RageMarkerAPI();
public ITextLabelAPI TextLabel => new RageTextLabelAPI();
public void DisableDefaultCommandErrorMessages() public void DisableDefaultCommandErrorMessages()
{ {
NAPI.Server.SetCommandErrorMessage(null); NAPI.Server.SetCommandErrorMessage(null);

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using GTANetworkAPI;
using ReallifeGamemode.Server.Core.API; using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Core.API.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) 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) public IColShape CreateSphere(Position position, float range)
{ {
throw new NotImplementedException(); var colShape = NAPI.ColShape.CreateSphereColShape(position.ToVector3(), range);
return new RageColShape(colShape);
} }
} }
} }

View File

@@ -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;
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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());
}
}
}

View File

@@ -1,12 +1,40 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Core.Menus namespace ReallifeGamemode.Server.Core.Menus
{ {
internal class PoliceDepartment : Script internal class PoliceDepartment : Script
{ {
public PoliceDepartment() 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)
{ {
} }

View File

@@ -7,21 +7,14 @@ namespace ReallifeGamemode.Server.Types
{ {
public enum AdminLevel public enum AdminLevel
{ {
[EnumMember(Value = "None")] PLAYER = 0,
None = 0, MAPPING = 1,
[EnumMember(Value = "Team")] ENTWICKLUNG = 2,
Team = 1, SUPPORTER = 3,
[EnumMember(Value = "Supporter")] ADMIN = 4,
Support = 2, ADMIN2 = 5,
[EnumMember(Value = "Administrator (1)")] ADMIN3 = 6,
Admin_1 = 3, HEADADMIN = 1337,
[EnumMember(Value = "Administrator (2)")] PROJEKTLEITUNG = 1338
Admin_2 = 4,
[EnumMember(Value = "Administrator (3)")]
Admin_3 = 5,
[EnumMember(Value = "Head-Administrator")]
Headadmin = 6,
[EnumMember(Value = "Projektleiter")]
Project_Lead = 7,
} }
} }

View File

@@ -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
}
}

View File

@@ -7,12 +7,9 @@ namespace ReallifeGamemode.Server.Types
{ {
public enum GroupRank public enum GroupRank
{ {
None, NONE,
[EnumMember(Value = "Mitglied")] MEMBER,
Member, MANAGER,
[EnumMember(Value = "Manager")] OWNER
Manager,
[EnumMember(Value = "Leiter")]
Leader
} }
} }

View File

@@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Admin Commands (Admin.cs) * @overview Life of German Reallife - Admin Commands (Admin.cs)

View File

@@ -4,6 +4,7 @@ using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using System; using System;
using System.Linq; using System.Linq;

View File

@@ -4,6 +4,7 @@ using GTANetworkAPI;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Server.Wanted;

View File

@@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Factions.Medic; using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Server.Wanted;

View File

@@ -10,6 +10,7 @@ using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Event Login (Login.cs) * @overview Life of German Reallife - Event Login (Login.cs)

View File

@@ -15,6 +15,7 @@ using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.DrivingSchool; using ReallifeGamemode.Server.DrivingSchool;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Event Key (Key.cs) * @overview Life of German Reallife - Event Key (Key.cs)
* @author VegaZ * @author VegaZ

View File

@@ -8,6 +8,7 @@ using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Wanted; using ReallifeGamemode.Server.Wanted;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Event Login (Login.cs) * @overview Life of German Reallife - Event Login (Login.cs)

View File

@@ -3,6 +3,7 @@ using ReallifeGamemode.Database;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using System; using System;

View File

@@ -1,9 +1,10 @@
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using static ReallifeGamemode.Database.AdminLevel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
using static ReallifeGamemode.Server.Types.AdminLevel;
namespace ReallifeGamemode.Server.Extensions namespace ReallifeGamemode.Server.Extensions
{ {

View File

@@ -11,6 +11,7 @@ using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Database.Entities; using ReallifeGamemode.Database.Entities;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Job namespace ReallifeGamemode.Server.Job
{ {
@@ -112,7 +113,7 @@ namespace ReallifeGamemode.Server.Job
lastPositions[v.Handle] = v.Position; lastPositions[v.Handle] = v.Position;
double distance = lastPosition.DistanceTo(v.Position) / 1000.0; 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<bool>("hasPassager")) continue; if (!player.GetData<bool>("hasPassager")) continue;
foreach (Player occupant in v.Occupants) foreach (Player occupant in v.Occupants)
{ {

View File

@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
{ {

View File

@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Managers namespace ReallifeGamemode.Server.Managers
{ {
@@ -19,7 +20,7 @@ namespace ReallifeGamemode.Server.Managers
public static void LoadCityHall() 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)); 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); var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f);
colShape.OnEntityEnterColShape += (s, c) => colShape.OnEntityEnterColShape += (s, c) =>

View File

@@ -6,6 +6,7 @@ using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Managers BankManager (BankManager.cs) * @overview Life of German Reallife - Managers BankManager (BankManager.cs)
* @author VegaZ * @author VegaZ

View File

@@ -12,6 +12,7 @@ using System.Linq;
using System.Text; using System.Text;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Types;
/** /**
* @overview Life of German Reallife - Managers Interaction (InteractionManager.cs) * @overview Life of German Reallife - Managers Interaction (InteractionManager.cs)

View File

@@ -12,6 +12,7 @@ using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using ReallifeGamemode.Database; using ReallifeGamemode.Database;
using ReallifeGamemode.Services; using ReallifeGamemode.Services;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Report namespace ReallifeGamemode.Server.Report
{ {

View File

@@ -4,6 +4,7 @@ using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models; using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Job; using ReallifeGamemode.Server.Job;
using ReallifeGamemode.Server.Types;
using ReallifeGamemode.Server.Util; using ReallifeGamemode.Server.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<Configurations>Debug;Release;ServerBuild</Configurations> <Configurations>Debug;Release;ServerBuild</Configurations>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>

View File

@@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReallifeGamemode.Server.Cor
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReallifeGamemode.Server.Log", "ReallifeGamemode.Server.Log\ReallifeGamemode.Server.Log.csproj", "{1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReallifeGamemode.Server.Log", "ReallifeGamemode.Server.Log\ReallifeGamemode.Server.Log.csproj", "{1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}"
EndProject 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 Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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|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.ActiveCfg = Debug|Any CPU
{1A6DB9CA-1921-4758-A9F6-9E3AEB3E1D02}.ServerBuild|x64.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE