Add Login Security
This commit is contained in:
@@ -20,6 +20,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
|
||||
public void CmdAdminO(Client player, string message)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -33,6 +34,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("veh", "~m~Benutzung: ~s~/veh [Fahrzeug] (Farbe 1) (Farbe 2)")]
|
||||
public void CmdAdminVeh(Client player, VehicleHash hash, int color1 = 111, int color2 = 111)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -53,6 +55,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("fixveh")]
|
||||
public void CmdAdminFixveh(Client player)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -71,6 +74,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("delveh")]
|
||||
public void CmdAdminDelveh(Client player)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -92,6 +96,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("goto", "~m~Benutzung: ~s~/goto [Name]")]
|
||||
public void CmdAdminGoto(Client player, string name)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -112,6 +117,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("gotoxyz", "~m~Benutzung: ~s~/gotoxyz [X] [Y] [Z]")]
|
||||
public void CmdAdminGotoxyz(Client player, float x, float y, float z)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -124,6 +130,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("gethere", "~m~Benutzung: ~s~/goto [Name]")]
|
||||
public void CmdAdminGethere(Client player, string name)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -144,6 +151,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("ipl", "~m~Benutzung: ~s~/ipl [Load / Remove] [Name]")]
|
||||
public void CmdAdminIpl(Client player, string option, string name)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -171,6 +179,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("giveweapon", "~m~Benutzung: ~s~/giveweapon [Spieler] [Waffe] [Munition]")]
|
||||
public void CmdAdminGiveweapon(Client player, string name, string weapon, int ammo)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
@@ -204,13 +213,16 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("save", "~m~Benutzung: ~s~/save [Typ = ~g~Blip, ~r~Marker, Ped, Pickup, TextLabel, ~g~Vehicle")]
|
||||
public void CmdAdminSave(Client player, string typ)
|
||||
{
|
||||
if (ChatService.PlayerLoggedIn(player) == false) return;
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
switch (typ)
|
||||
{
|
||||
case "Blip":
|
||||
player.TriggerEvent("saveBlip");
|
||||
break;
|
||||
case "Ped":
|
||||
|
||||
break;
|
||||
case "Vehicle":
|
||||
if (player.IsInVehicle)
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace reallife_gamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Client player)
|
||||
{
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
}
|
||||
|
||||
23
Server/Events/Disconnect.cs
Normal file
23
Server/Events/Disconnect.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player)
|
||||
{
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
player.TriggerEvent("loginSuccess");
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.SetData("isLoggedIn", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,5 +22,11 @@ namespace reallife_gamemode.Server.Services
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Der Spieler wurde nicht gefunden.");
|
||||
}
|
||||
|
||||
public static bool PlayerLoggedIn(Client player)
|
||||
{
|
||||
if(player.GetData("isLoggedIn") == false) player.SendChatMessage("~r~[FEHLER]~s~ Du bist nicht eingeloggt.");
|
||||
return player.GetData("isLoggedIn");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user