nur 1 resourcestart event
This commit is contained in:
@@ -18,6 +18,8 @@ using ReallifeGamemode.Services;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using ReallifeGamemode.Server.newbie;
|
using ReallifeGamemode.Server.newbie;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Main Class (Main.cs)
|
* @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");
|
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)]
|
[ServerEvent(Event.ResourceStart)]
|
||||||
public void OnResourceStart()
|
public void OnResourceStart()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true")
|
if (System.Environment.GetEnvironmentVariable("RAGEMP_UPDATE_DATABASE_ON_STARTUP", System.EnvironmentVariableTarget.User) == "true")
|
||||||
{
|
{
|
||||||
using var dbContext = new DatabaseContext(true);
|
using var dbContext = new DatabaseContext(true);
|
||||||
@@ -88,13 +98,13 @@ namespace ReallifeGamemode.Server
|
|||||||
});
|
});
|
||||||
|
|
||||||
IAPI apiInstance = new RageAPI();
|
IAPI apiInstance = new RageAPI();
|
||||||
eventHandler = new EventHandler(apiInstance);
|
eventHandler = new Core.Events.EventHandler(apiInstance);
|
||||||
|
|
||||||
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
||||||
|
|
||||||
NAPI.Server.SetGlobalServerChat(false);
|
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.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
@@ -133,6 +143,8 @@ namespace ReallifeGamemode.Server
|
|||||||
Gangwar.Gangwar.loadTurfs();
|
Gangwar.Gangwar.loadTurfs();
|
||||||
Bank.bank.Setup();
|
Bank.bank.Setup();
|
||||||
Introduction.Setup();
|
Introduction.Setup();
|
||||||
|
PositionManager.LoadPositionManager();
|
||||||
|
LoadManager.LoadLoadManager();
|
||||||
|
|
||||||
TempBlip tempBlip = new TempBlip()
|
TempBlip tempBlip = new TempBlip()
|
||||||
{
|
{
|
||||||
@@ -172,6 +184,36 @@ namespace ReallifeGamemode.Server
|
|||||||
|
|
||||||
//IPLS
|
//IPLS
|
||||||
NAPI.World.RequestIpl("vw_casino_garage");
|
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")]
|
[RemoteEvent("CLIENT:Event")]
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
public class LoadManager : Script
|
public class LoadManager : Script
|
||||||
{
|
{
|
||||||
[ServerEvent(Event.ResourceStart)]
|
public static void LoadLoadManager()
|
||||||
public void OnResourceStart()
|
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
public static List<JobPoint> JobPoints = new List<JobPoint>();
|
public static List<JobPoint> JobPoints = new List<JobPoint>();
|
||||||
|
|
||||||
[ServerEvent(Event.ResourceStart)]
|
public static void LoadPositionManager()
|
||||||
public void OnResourceStart()
|
|
||||||
{
|
{
|
||||||
#region DutyPoints
|
#region DutyPoints
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user