Files
reallife-gamemode/Main.cs
2018-09-23 01:33:33 +02:00

53 lines
1.7 KiB
C#

using System;
using System.Linq;
using GTANetworkAPI;
using Microsoft.EntityFrameworkCore;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
/**
* @overview Life of German Reallife - Main Class (Main.cs)
* @author VegaZ, hydrant
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode
{
public class Main : Script
{
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
[ServerEvent(Event.ResourceStart)]
public void OnResourceStart()
{
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
NAPI.Server.SetAutoSpawnOnConnect(false);
using (var context = new DatabaseContext())
{
context.Factions.FirstOrDefault();
context.Users.FirstOrDefault();
context.SaveChanges();
foreach(Faction f in context.Factions)
{
NAPI.Util.ConsoleOutput(f.Name);
}
foreach(User u in context.Users.Include(x => x.Faction))
{
Faction f = u.Faction;
NAPI.Util.ConsoleOutput("User: " + u.Name + " | Faction: " + (f == null ? "null" : f.Name));
}
}
}
[ServerEvent(Event.ResourceStop)]
public void OnResourceStop()
{
NAPI.Chat.SendChatMessageToAll("on stop");
}
}
}