/lc und /ga für admins
This commit is contained in:
@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Extensions;
|
|||||||
using ReallifeGamemode.Server.Factions.Medic;
|
using ReallifeGamemode.Server.Factions.Medic;
|
||||||
using ReallifeGamemode.Server.Managers;
|
using ReallifeGamemode.Server.Managers;
|
||||||
using ReallifeGamemode.Server.Services;
|
using ReallifeGamemode.Server.Services;
|
||||||
|
using ReallifeGamemode.Server.Types;
|
||||||
using ReallifeGamemode.Services;
|
using ReallifeGamemode.Services;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,20 +44,21 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionGA(Player player, string message)
|
public void CmdFactionGA(Player player, string message)
|
||||||
{
|
{
|
||||||
Faction f = player.GetUser()?.Faction;
|
User user = player.GetUser();
|
||||||
|
Faction f = user?.Faction;
|
||||||
if (f == null || f.StateOwned)
|
if (f == null || f.StateOwned)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.GetUser().Faction.Name == "Ballas" || player.GetUser().Faction.Name == "Grove")
|
if (f.Name == "Ballas" || f.Name == "Grove" || user.IsAdmin(AdminLevel.ADMIN))
|
||||||
{
|
{
|
||||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||||
|
|
||||||
string broadcastMessage = "!{FF0000}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " **";
|
string broadcastMessage = "!{FF0000}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " **";
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned));
|
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -177,7 +179,8 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionLc(Player player, string message)
|
public void CmdFactionLc(Player player, string message)
|
||||||
{
|
{
|
||||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
User user = player.GetUser();
|
||||||
|
if (user?.FactionId == null || user.FactionLeader == false || !user.IsAdmin(AdminLevel.ADMIN))
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
@@ -189,7 +192,8 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
|
|
||||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||||
{
|
{
|
||||||
if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg);
|
User pUser = p.GetUser();
|
||||||
|
if (pUser?.FactionLeader ?? false || pUser.IsAdmin(AdminLevel.ADMIN)) ChatService.SendMessage(p, broadcastMsg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,12 @@ namespace ReallifeGamemode.Server.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||||
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
||||||
public static void BroadcastFaction(string message, List<Faction> factions)
|
public static void BroadcastFaction(string message, List<Faction> factions, bool toAdmins = false)
|
||||||
{
|
{
|
||||||
foreach (Player c in NAPI.Pools.GetAllPlayers())
|
foreach (Player c in NAPI.Pools.GetAllPlayers())
|
||||||
{
|
{
|
||||||
Faction f = c.GetUser()?.Faction;
|
User user = c.GetUser();
|
||||||
|
Faction f = user.Faction;
|
||||||
if (f != null)
|
if (f != null)
|
||||||
{
|
{
|
||||||
if (factions.Find(fT => fT.Id == f.Id) != null)
|
if (factions.Find(fT => fT.Id == f.Id) != null)
|
||||||
@@ -64,6 +65,10 @@ namespace ReallifeGamemode.Server.Services
|
|||||||
ChatService.SendMessage(c, message);
|
ChatService.SendMessage(c, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(user.IsAdmin(AdminLevel.ADMIN) && toAdmins)
|
||||||
|
{
|
||||||
|
ChatService.SendMessage(c, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user