Add Ban Command

This commit is contained in:
VegaZ
2018-09-25 20:24:30 +02:00
parent 044651f629
commit 3c5ecdd8e4
6 changed files with 47 additions and 3 deletions

View File

@@ -28,5 +28,27 @@ namespace reallife_gamemode.Server.Extensions
{
return player.GetData("isLoggedIn");
}
public static void BanPlayer(Client admin, Client target, string reason, int mins)
{
if(mins == 0)
{
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
//user.Kick();
mins--;
}
else
{
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + target.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
//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.SaveChanges();
}
}
}
}