Added /uninvite Command
This commit is contained in:
@@ -135,5 +135,53 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("uninvite", "~m~Benutzung: ~s~/uninvite [Name]")]
|
||||||
|
public void CmdFactionUninvite(Client player, string name)
|
||||||
|
{
|
||||||
|
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client target = ClientService.GetClientByName(name);
|
||||||
|
if (target == null || !target.IsLoggedIn())
|
||||||
|
{
|
||||||
|
ChatService.PlayerNotFound(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.GetUser()?.FactionId != player.GetUser()?.FactionId)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist nicht in deiner Fraktion.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.Handle == target.Handle)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst dich nicht selber uninviten.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(target.GetUser()?.FactionLeader ?? false)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst keinen Leader uninviten.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
|
||||||
|
target.GetUser(dbContext).FactionRankId = null;
|
||||||
|
target.GetUser(dbContext).FactionId = null;
|
||||||
|
|
||||||
|
player.SendChatMessage("!{02FCFF}Du hast " + target.Name + " aus der Fraktion geworfen.");
|
||||||
|
target.SendChatMessage("!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen.");
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user