nur 1 resourcestart event

This commit is contained in:
hydrant
2021-04-03 17:27:16 +02:00
parent 9480926f28
commit 50d9f4d2f5
3 changed files with 168 additions and 128 deletions

View File

@@ -18,6 +18,8 @@ using ReallifeGamemode.Services;
using System.Threading;
using Microsoft.EntityFrameworkCore;
using ReallifeGamemode.Server.newbie;
using System;
using System.IO;
/**
* @overview Life of German Reallife - Main Class (Main.cs)
@@ -34,12 +36,20 @@ namespace ReallifeGamemode.Server
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
private EventHandler eventHandler;
private Core.Events.EventHandler eventHandler;
private readonly Mutex logMutex = new Mutex(false, "RAGE_MAIN_LOG_MUTEX");
public Main()
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
[ServerEvent(Event.ResourceStart)]
public void OnResourceStart()
{
try
{
if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true")
{
using var dbContext = new DatabaseContext(true);
@@ -88,13 +98,13 @@ namespace ReallifeGamemode.Server
});
IAPI apiInstance = new RageAPI();
eventHandler = new EventHandler(apiInstance);
eventHandler = new Core.Events.EventHandler(apiInstance);
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
NAPI.Server.SetGlobalServerChat(false);
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
NAPI.Server.SetCommandErrorMessage("");
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
NAPI.Server.SetAutoSpawnOnConnect(false);
NAPI.Server.SetAutoRespawnAfterDeath(false);
@@ -133,6 +143,8 @@ namespace ReallifeGamemode.Server
Gangwar.Gangwar.loadTurfs();
Bank.bank.Setup();
Introduction.Setup();
PositionManager.LoadPositionManager();
LoadManager.LoadLoadManager();
TempBlip tempBlip = new TempBlip()
{
@@ -172,6 +184,36 @@ namespace ReallifeGamemode.Server
//IPLS
NAPI.World.RequestIpl("vw_casino_garage");
}
catch (Exception e)
{
Log(e.ToString());
}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Log(e.ExceptionObject.ToString());
}
private void Log(string message)
{
string basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string log = Path.Combine(basePath, "log.txt");
logMutex.WaitOne();
if (!File.Exists(log))
{
File.Create(log);
}
string msg = $"[{DateTime.Now:s}] - Error: {message}{Environment.NewLine}";
File.AppendAllText(log, msg);
logMutex.ReleaseMutex();
}
[RemoteEvent("CLIENT:Event")]

View File

@@ -14,8 +14,7 @@ namespace ReallifeGamemode.Server.Managers
{
public class LoadManager : Script
{
[ServerEvent(Event.ResourceStart)]
public void OnResourceStart()
public static void LoadLoadManager()
{
using (var dbContext = new DatabaseContext())
{

View File

@@ -25,8 +25,7 @@ namespace ReallifeGamemode.Server.Managers
public static List<JobPoint> JobPoints = new List<JobPoint>();
[ServerEvent(Event.ResourceStart)]
public void OnResourceStart()
public static void LoadPositionManager()
{
#region DutyPoints