Change login-process for Ban-System
This commit is contained in:
@@ -3,17 +3,10 @@
|
|||||||
* @author VegaZ, hydrant
|
* @author VegaZ, hydrant
|
||||||
* @copyright (c) 2008 - 2018 Life of German
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var loginBrowser;
|
var loginBrowser;
|
||||||
loginBrowser = mp.browsers.new('package://Login/login.html');
|
|
||||||
mp.gui.chat.activate(false);
|
|
||||||
mp.gui.cursor.show(true, true);
|
|
||||||
mp.game.ui.displayHud(false);
|
|
||||||
mp.game.ui.displayRadar(false);
|
|
||||||
|
|
||||||
var loginCam = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
|
var loginCam = mp.cameras.new('login', new mp.Vector3(-1883.736, -781.4911, 78.27616), new mp.Vector3(3.185999, 0, -79.59519), 40);
|
||||||
loginCam.setActive(true);
|
|
||||||
mp.game.cam.renderScriptCams(true, false, 0, true, false);
|
mp.events.callRemote('IsPlayerBanned');
|
||||||
|
|
||||||
mp.events.add('loginInformationToServer', (password) => {
|
mp.events.add('loginInformationToServer', (password) => {
|
||||||
|
|
||||||
@@ -73,6 +66,22 @@ mp.events.add('registerFail', (reason) => {
|
|||||||
showCefError(reason);
|
showCefError(reason);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mp.events.add('showLogin', () => {
|
||||||
|
|
||||||
|
loginBrowser = mp.browsers.new('package://Login/login.html');
|
||||||
|
mp.gui.chat.activate(false);
|
||||||
|
mp.gui.cursor.show(true, true);
|
||||||
|
mp.game.ui.displayHud(false);
|
||||||
|
mp.game.ui.displayRadar(false);
|
||||||
|
|
||||||
|
loginCam.setActive(true);
|
||||||
|
mp.game.cam.renderScriptCams(true, false, 0, true, false);
|
||||||
|
});
|
||||||
|
|
||||||
function showCefError(error) {
|
function showCefError(error) {
|
||||||
loginBrowser.execute(`showError(\`` + error + `\`)`);
|
loginBrowser.execute(`showError(\`` + error + `\`)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//function isPlayerBanned() {
|
||||||
|
|
||||||
|
//}
|
||||||
@@ -25,8 +25,8 @@ namespace reallife_gamemode.Server.Entities
|
|||||||
|
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
public string BannedBy { get; set; }
|
public string BannedBy { get; set; }
|
||||||
[Timestamp]
|
|
||||||
public byte[] Applied { get; set; }
|
public int Applied { get; set; }
|
||||||
public byte[] UntilDateTime { get; set; }
|
public int UntilDateTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,36 @@ namespace reallife_gamemode.Server.Events
|
|||||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||||
player.FreezePosition = true;
|
player.FreezePosition = true;
|
||||||
}
|
}
|
||||||
|
[RemoteEvent("IsPlayerBanned")]
|
||||||
|
public void IsPlayerBanned(Client player)
|
||||||
|
{
|
||||||
|
using (var loginUser = new Model.DatabaseContext())
|
||||||
|
{
|
||||||
|
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||||
|
if (user.BanId != null)
|
||||||
|
{
|
||||||
|
using (var banUser = new DatabaseContext())
|
||||||
|
{
|
||||||
|
|
||||||
|
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
var bannedUser = banUser.Bans.SingleOrDefault(u => u.Id == user.BanId);
|
||||||
|
if (bannedUser.Applied == bannedUser.UntilDateTime)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
|
||||||
|
//player.Kick();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var timeStamp = bannedUser.UntilDateTime;
|
||||||
|
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||||
|
//player.Kick();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else player.TriggerEvent("showLogin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
|
using reallife_gamemode.Server.Entities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
|
|||||||
@@ -31,23 +31,30 @@ namespace reallife_gamemode.Server.Extensions
|
|||||||
|
|
||||||
public static void BanPlayer(Client admin, Client target, string reason, int mins)
|
public static void BanPlayer(Client admin, Client target, string reason, int mins)
|
||||||
{
|
{
|
||||||
if(mins == 0)
|
using (var banUser = new DatabaseContext())
|
||||||
|
{
|
||||||
|
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||||
|
Ban user;
|
||||||
|
if (mins == 0)
|
||||||
{
|
{
|
||||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||||
//user.Kick();
|
user = new Ban { UserId = GetUser(target).Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp};
|
||||||
|
//TODO user.Kick();
|
||||||
mins--;
|
mins--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||||
//user.Kick();
|
user = new Ban { UserId = GetUser(target).Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||||
|
//TODO user.Kick();
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var banUser = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var user = new Ban { UserId = GetUser(target).Id, Reason = reason, BannedBy = admin.Name, UntilDateTime = BitConverter.GetBytes(DateTime.Now.Ticks - mins)};
|
|
||||||
banUser.Bans.Add(user);
|
banUser.Bans.Add(user);
|
||||||
banUser.SaveChanges();
|
banUser.SaveChanges();
|
||||||
|
|
||||||
|
var targetUser = banUser.Users.FirstOrDefault(u => u.Name == target.Name);
|
||||||
|
targetUser.BanId = user.Id;
|
||||||
|
banUser.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user