Files
reallife-gamemode/Server/Services/ChatService.cs
2018-10-15 17:33:58 +02:00

72 lines
2.1 KiB
C#

using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/**
* @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.");
}
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);
}
}
}
}
public static void BroadcastFaction(string message, Faction f)
{
BroadcastFaction(message, new List<Faction>() { f });
}
public static void BroadcastAdmin(string message, AdminLevel minLevel)
{
NAPI.Pools.GetAllPlayers().ForEach(p =>
{
if(p.GetUser()?.IsAdmin(minLevel) ?? false)
{
p.SendChatMessage(message);
}
});
}
}
}