public void Execute(Player player, string[] args) { if (player.GuildRank == 40) { foreach (var e in from i in RealmManager.Worlds where i.Key != 0 from e in i.Value.Players where string.Equals(e.Value.Client.Account.Name, args[0], StringComparison.CurrentCultureIgnoreCase) select e) { if (e.Value.Client.Account.Guild.Rank == 40) { player.SendInfo(e.Value.Client.Account.Name + " has been invited to ally with your guild!"); e.Value.Client.SendPacket(new GuildAllyRequestPacket { Name = player.Client.Account.Name, Guild = player.Client.Account.Guild.Name }); } else player.SendError(e.Value.Client.Account.Guild.Name + " is already one of your allys!"); } } else player.SendInfo("Only founders can ally with other guilds!"); }
public bool Execute(Player player, RealmTime time, string args) { if (!HasPermission(player)) { player.SendInfo("You are not an Admin"); return false; } try { string[] a = args.Split(' '); bool success = Process(player, time, a); if (success) player.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "insert into commandlog (command, args, player) values (@command, @args, @player);"; cmd.Parameters.AddWithValue("@command", CommandName); cmd.Parameters.AddWithValue("@args", args); cmd.Parameters.AddWithValue("@player", $"{player.AccountId}:{player.Name}"); cmd.ExecuteNonQuery(); }); return success; } catch (Exception ex) { logger.Error("Error when executing the command.", ex); player.SendError("Error when executing the command."); return false; } }
public bool Execute(Player player, RealmTime time, string args) { if (!HasPermission(player)) { player.SendError("No permission!"); return false; } try { string[] a = args.Split(' '); return Process(player, time, a); } catch (Exception ex) { log.Error("Error when executing the command.", ex); player.SendError("Error when executing the command."); return false; } }
protected override bool Process(Player player, RealmTime time, string[] args) { if (String.IsNullOrWhiteSpace(args[0])) { player.SendInfo("Usage: /invite <player name>"); return false; } if (player.Guild[player.AccountId].Rank >= 20) { foreach (var i in player.Owner.Players.Values) { Player target = player.Owner.GetPlayerByName(args[0]); if (target == null) { player.SendInfoWithTokens("server.invite_notfound", new KeyValuePair<string, object>[1] { new KeyValuePair<string, object>("player", args[0]) }); return false; } if (!target.NameChosen || player.Dist(target) > 20) { player.SendInfoWithTokens("server.invite_notfound", new KeyValuePair<string, object>[1] { new KeyValuePair<string, object>("player", args[0]) }); return false; } if (target.Guild.IsDefault) { target.Client.SendPacket(new InvitedToGuildPacket() { Name = player.Name, GuildName = player.Guild[player.AccountId].Name }); target.Invited = true; player.SendInfoWithTokens("server.invite_succeed", new KeyValuePair<string, object>[2] { new KeyValuePair<string, object>("player", args[0]), new KeyValuePair<string, object>("guild", player.Guild[player.AccountId].Name) }); return true; } else { player.SendError("Player is already in a guild!"); return false; } } } else { player.Client.SendPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "", Text = "Members and initiates cannot invite!" }); } return false; }
public void Execute(Player player, string[] args) { if (player.GuildRank >= 20) { foreach (var e in from i in RealmManager.Worlds where i.Key != 0 from e in i.Value.Players where string.Equals(e.Value.Client.Account.Name, args[0], StringComparison.CurrentCultureIgnoreCase) select e) { if (e.Value.Client.Account.Guild.Name == "") { player.SendInfo(e.Value.Client.Account.Name + " has been invited to your guild!"); e.Value.Client.SendPacket(new InvitedToGuildPacket { Name = player.Client.Account.Name, Guild = player.Client.Account.Guild.Name }); } else player.SendError(e.Value.Client.Account.Name + " is already in a guild!"); } } else player.SendInfo("Members and initiates cannot invite!"); }
public bool Execute(Player player, RealmTime time, string text) { int index = text.IndexOf(' '); string cmd = text.Substring(1, index == -1 ? text.Length - 1 : index - 1); string args = index == -1 ? "" : text.Substring(index + 1); Command command; if (!cmds.TryGetValue(cmd, out command)) { player.SendError("Unknown command!"); return false; } logger.InfoFormat("[Command] <{0}> {1}", player.Name, text); return command.Execute(player, time, args); }