using GTANetworkAPI; using Newtonsoft.Json; using reallife_gamemode.Model; using reallife_gamemode.Server.Entities; using reallife_gamemode.Server.Extensions; using reallife_gamemode.Server.Services; using reallife_gamemode.Server.Util; using System; using System.Collections.Generic; using System.Linq; using System.Text; /** * @overview Life of German Reallife - Faction Commands (Faction.cs) * @author VegaZ, hydrant * @copyright (c) 2008 - 2018 Life of German */ namespace reallife_gamemode.Server.Commands { class Faction : Script { [Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)] public void CmdFactionF(Client player, string message) { Entities.Faction f = player.GetUser()?.GetFaction(); if(f == null || f.StateOwned) { ChatService.NotAuthorized(player); return; } string broadcastMessage = "!{02FCFF}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " )) **"; ChatService.BroadcastFaction(broadcastMessage, f); } [Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)] public void CmdFactionR(Client player, string message) { Entities.Faction f = player.GetUser()?.GetFaction(); if (f == null || !f.StateOwned) { ChatService.NotAuthorized(player); return; } string broadcastMessage = "!{33AA33}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **"; ChatService.BroadcastFaction(broadcastMessage, f); } [Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)] public void CmdFactionD(Client player, string message) { Entities.Faction f = player.GetUser()?.GetFaction(); if (f == null || !f.StateOwned) { ChatService.NotAuthorized(player); return; } string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **"; using(var context = new DatabaseContext()) { ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned)); } } [Command("invite", "~m~Benutzung: ~s~/invite [Name]")] public void CmdFactionInvite(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 != null) { player.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist schon in einer Fraktion."); return; } target.SetData("accept_invite", player.Handle); player.SendChatMessage("!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet."); target.SendChatMessage("!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + player.GetUser().GetFaction().Name + "\" erhalten."); target.SendChatMessage("!{02FCFF}Benutze '/accept invite', um die Einladung anzunehmen"); return; } } }