*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

@@ -57,6 +57,7 @@ cityHall(globalData);
import adminSpeed from './admin/aspeed';
adminSpeed();
import voice from './Voice/main';
voice(globalData);

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using GTANetworkAPI;
namespace ReallifeGamemode.Database.Entities
{
public partial class ServerVariable
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Variable { get; set; }
public int Value { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Database.Migrations
{
public partial class SVars : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "failpoints",
table: "Users",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "warn",
table: "Users",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "ServerVariables",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Variable = table.Column<string>(nullable: true),
Value = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ServerVariables", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ServerVariables");
migrationBuilder.DropColumn(
name: "failpoints",
table: "Users");
migrationBuilder.DropColumn(
name: "warn",
table: "Users");
}
}
}

View File

@@ -1121,6 +1121,23 @@ namespace ReallifeGamemode.Database.Migrations
b.ToTable("TextLabels");
});
modelBuilder.Entity("ReallifeGamemode.Database.Entities.ServerVariable", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.Property<string>("Variable")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
b.ToTable("ServerVariables");
});
modelBuilder.Entity("ReallifeGamemode.Database.Entities.ServerVehicle", b =>
{
b.Property<int>("Id")
@@ -1415,12 +1432,18 @@ namespace ReallifeGamemode.Database.Migrations
b.Property<bool>("WeaponLicense")
.HasColumnType("tinyint(1)");
b.Property<int>("failpoints")
.HasColumnType("int");
b.Property<int>("otheramount")
.HasColumnType("int");
b.Property<int>("trashcount")
.HasColumnType("int");
b.Property<int>("warn")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("BanId");

View File

@@ -152,6 +152,9 @@ namespace ReallifeGamemode.Database.Models
//ItemShop
public DbSet<Entities.ShopItem> ShopItems { get; set; }
//Server Variablen
public DbSet<Entities.ServerVariable> ServerVariables { get; set; }
}
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<DatabaseContext>

View File

@@ -236,7 +236,7 @@ namespace ReallifeGamemode.Server.Commands
case "ip":
if(player.HasData("togip"))
{
player.SetData("togip", false);
player.ResetData("togip");
player.SendNotification("~g~[Info]~w~ Ip´s werden nun ausgeblendet.");
}
else
@@ -249,7 +249,7 @@ namespace ReallifeGamemode.Server.Commands
case "deathlogs":
if (player.HasData("togdeath"))
{
player.SetData("togdeath", false);
player.ResetData("togdeath");
player.SendNotification("~g~[Info]~w~ Deathlogs werden nun ausgeblendet.");
}
else
@@ -261,7 +261,7 @@ namespace ReallifeGamemode.Server.Commands
case "lc":
if (player.HasData("toglc"))
{
player.SetData("toglc", false);
player.ResetData("toglc");
player.SendNotification("~g~[Info]~w~ Leaderchat wird nun ausgeblendet.");
}
else
@@ -1727,6 +1727,17 @@ namespace ReallifeGamemode.Server.Commands
#region ALevel1337
[Command("setsvar", "~m~Benutzung:~s~ /setsvar [ID] [WERT]")]
public void CmdAdmSetSvar(Player player, int varId, int varValue)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.PROJEKTLEITUNG) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
Managers.SVarManager.ChangeSVarValue(player, varId, varValue);
}
[Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")]
public void CmdAdmCreateTurf(Player player, float option)
{

View File

@@ -2,6 +2,7 @@
using System.Linq;
using GTANetworkAPI;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
@@ -29,21 +30,39 @@ namespace ReallifeGamemode.Server.Events
bool registered = false;
var whitelistStatus = Managers.SVarManager.SVars.FirstOrDefault(v => v.Variable == "WhitelistStatus").Value;
using (var dbContext = new DatabaseContext())
{
registered = dbContext.Users.Where(u => u.Name == player.Name).Any();
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName == player.SocialClubName))
switch (whitelistStatus)
{
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
case 0: //Whitelist aus
break;
NAPI.Util.ConsoleOutput(player.Name + " tried to join without whitelist entry");
case 1: //Whitelist aktiv (Main-Server)
if (dbContext.Users.FirstOrDefault(u => u.SocialClubName == player.SocialClubName).AdminLevel < AdminLevel.MAPPING)
{
NAPI.Util.ConsoleOutput(player.Name + " versucht sich einzuloggen während die Whitelist an ist. [STATUS 1]");
player.Kick();
return;
}
break;
ChatService.SendMessage(player, "~m~Du stehst nicht auf der Whitelist");
case 2: //Whitelist aktiv (Test-Server)
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName == player.SocialClubName))
{
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
player.Kick();
return;
NAPI.Util.ConsoleOutput(player.Name + " tried to join without whitelist entry [STATUS 2]");
ChatService.SendMessage(player, "~m~Du stehst nicht auf der Whitelist");
player.Kick();
return;
}
break;
}
}
@@ -64,7 +83,7 @@ namespace ReallifeGamemode.Server.Events
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID: " + player.Handle.Value + "] (" + player.Address + ")";
if(player.HasData("togip"))
{
ChatService.SendMessage(player, msg);
ChatService.SendMessage(player, msg);
}
}

View File

@@ -268,6 +268,7 @@ namespace ReallifeGamemode.Server.Gangwar
}
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).First().BankAccount.Balance += 15000;
}
else if (getOwner() != FactionName)
{
@@ -284,6 +285,7 @@ namespace ReallifeGamemode.Server.Gangwar
}
this.Owner = FactionName;
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Name == getOwner()).First().BankAccount.Balance += 10000;
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
turf.Owner = this.Owner;
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;

View File

@@ -153,6 +153,8 @@ namespace ReallifeGamemode.Server
ThreadTimers.StartAllTimers();
Managers.SVarManager.LoadSVars();
UserBankAccount.BalanceChanged += (account) =>
{
using (var dbContext = new DatabaseContext())

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