*WhitelistStatus hinzugefügt *Servervariablen hinzugefügt: /setsvar

This commit is contained in:
VegaZ
2021-04-01 22:43:03 +02:00
parent 42b7be7770
commit 4079b4bd3c
11 changed files with 2070 additions and 13 deletions

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Services;
namespace ReallifeGamemode.Server.Managers
{
public class SVarManager : Script
{
public static List<ServerVariable> SVars = new List<ServerVariable>();
public static void LoadSVars()
{
using (var dbContext = new DatabaseContext())
{
SVars = dbContext.ServerVariables.Select(row => row).ToList();
foreach(var svar in SVars)
{
System.Console.WriteLine("[SVAR][" + svar.Id + "] " + svar.Variable + " = " + svar.Value);
}
System.Console.WriteLine("Geladene Server Variablen [" + SVars.Count() + "]");
}
}
public static void ChangeSVarValue(Player player, int varId, int varValue)
{
using (var dbContext = new DatabaseContext())
{
var changeValue = dbContext.ServerVariables.FirstOrDefault(v => v.Id == varId);
var oldValue = changeValue.Value;
SVars.FirstOrDefault(v => v.Id == varId).Value = varValue;
changeValue.Value = varValue;
dbContext.SaveChanges();
ChatService.SendMessage(player, "~r~Wert von Server Variable ~o~" + changeValue.Variable + "~r~ in ~g~ " + varValue + "~r~geändert. Alter Wert: ~y~" + oldValue);
}
}
}
}