Files
reallife-gamemode/Server/Services/ChatService.cs
2018-09-25 21:42:40 +02:00

54 lines
1.5 KiB
C#

using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/**
* @overview Life of German Reallife - Chat Service (ChatService.cs)
* @author hydrant
* @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 BroadcastFaction(string message, List<Faction> factions)
{
using (var dbCon = new DatabaseContext())
{
foreach (Client c in NAPI.Pools.GetAllPlayers())
{
Faction f = c.GetFaction();
if (f != null)
{
if (factions.Find(fT => fT.Id == f.Id) != null)
{
c.SendChatMessage(message);
}
}
}
}
}
public static void BroadcastFaction(string message, Faction faction)
{
BroadcastFaction(message, new List<Faction> { faction });
}
}
}