83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using GTANetworkAPI;
|
|
using reallife_gamemode.Server.Entities;
|
|
using reallife_gamemode.Server.Extensions;
|
|
using reallife_gamemode.Server.Util;
|
|
using System.Collections.Generic;
|
|
|
|
/**
|
|
* @overview Life of German Reallife - Chat Service (ChatService.cs)
|
|
* @author hydrant, xSprite
|
|
* @copyright (c) 2008 - 2018 Life of German
|
|
*/
|
|
|
|
namespace reallife_gamemode.Server.Services
|
|
{
|
|
class ChatService
|
|
{
|
|
public static void NotAuthorized(Client player)
|
|
{
|
|
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst diesen Befehl nicht ausführen.");
|
|
}
|
|
|
|
public static void PlayerNotFound(Client player)
|
|
{
|
|
player.SendChatMessage("~r~[FEHLER]~s~ Der Spieler wurde nicht gefunden.");
|
|
}
|
|
|
|
public static void PlayerNotLoggedIn(Client player)
|
|
{
|
|
player.SendChatMessage("~r~[FEHLER]~s~ Du bist nicht eingeloggt.");
|
|
}
|
|
public static void ErrorMsg(Client player)
|
|
{
|
|
player.SendChatMessage("~r~[FEHLER]~s~ Die Aktion wurde nicht ausgeführt.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sendet eine Nachricht an eine Liste von Fraktionen
|
|
/// </summary>
|
|
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
|
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
|
public static void BroadcastFaction(string message, List<Faction> factions)
|
|
{
|
|
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
|
{
|
|
Faction f = c.GetUser()?.GetFaction();
|
|
if (f != null)
|
|
{
|
|
if (factions.Find(fT => fT.Id == f.Id) != null)
|
|
{
|
|
c.SendChatMessage(message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sendet eine Nachricht an eine Fraktion
|
|
/// </summary>
|
|
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
|
/// <param name="f">Die Fraktion, die diese Nachricht bekommen soll</param>
|
|
public static void BroadcastFaction(string message, Faction f)
|
|
{
|
|
BroadcastFaction(message, new List<Faction>() { f });
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sendet eine Nachricht an alle Spieler mit einem bestimmten Admin Level
|
|
/// </summary>
|
|
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
|
/// <param name="minLevel">Das mindest Admin Level, das für das Erhalten dieser Nachricht benötigt wird</param>
|
|
public static void BroadcastAdmin(string message, AdminLevel minLevel)
|
|
{
|
|
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
|
{
|
|
if(p.GetUser()?.IsAdmin(minLevel) ?? false)
|
|
{
|
|
p.SendChatMessage(message);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|