private void OnUserConnected(IPlayer player) { if (player == null) { return; } if (!permission.GroupExists(groupKey)) { return; } var PlayerName = player.Name.ToLower(); var PlayerNameChecker = PlayerName.Contains(promotionKey.ToLower()); var PlayerIsPromoting = PromotingInfo.IsPromoting(player); if (groupAdding == true) { // Checks to see if player has already been given permissions if (!PlayerIsPromoting) { if (PlayerNameChecker && !PlayerIsPromoting) { /// ADDING THEM SINCE THEY HAVE KEY permission.AddUserGroup(player.Id, groupKey); promoters[player.Id] = new PromotingInfo(); SaveData(promoters); if (informPlayer == true) { string message = ""; foreach (var thanksText in Config["Messages", "Thanks Message"] as List <object> ) // TODO: Clean this mess up { message = message + thanksText + "\n"; } timer.Once(messageDelay, () => { if (useThanksMessage == true) { SendThanksMessage(player, message.Replace("{promotionkey}", promotionKey).Replace("{player}", player.Name).Replace("{groupkey}", groupKey)); return; } SendChatMessage(player, lang.GetMessage("Player Added Group", this, player.Id).Replace("{group}", groupKey)); }); } if (printToConsole == true) { Puts(lang.GetMessage("Player Added Group", this, player.Id).Replace("{player}", player.Name).Replace("{group}", groupKey)); } return; } } if (removeReward == true) { if (!PlayerNameChecker && PlayerIsPromoting) { /// REMOVING SINCE THEY DO NOT HAVE KEY permission.RemoveUserGroup(player.Id, groupKey); promoters.Remove(player.Id); SaveData(promoters); if (informPlayer == true) { timer.Once(messageDelay, () => { SendChatMessage(player, lang.GetMessage("Player Removed Group", this, player.Id).Replace("{group}", groupKey).Replace("{promotionkey}", promotionKey)); }); } if (printToConsole == true) { Puts(lang.GetMessage("Player Removed Group", this, player.Id).Replace("{group}", groupKey).Replace("{promotionkey}", promotionKey)); } return; } } } }
private void PromotionCommand(IPlayer player, string command, string[] args) { var HasPerm = (player.HasPermission(AdminPermission)); #region Default if (args.Length == 0) { if (useGroupInfo == true) { SendInfoMessage(player, lang.GetMessage("Default Message Group", this, player.Id).Replace("{promotionkey}", promotionKey).Replace("{group}", groupKey)); return; } SendInfoMessage(player, lang.GetMessage("Default Message", this, player.Id).Replace("{promotionkey}", promotionKey).Replace("{group}", groupKey)); return; } #endregion var CommandArg = args[0].ToLower(); var CommandInfo = (command + " " + args[0]); var CaseArgs = (new List <object> { "check", "help", "group", "remove" }); if (!CaseArgs.Contains(CommandArg)) { SendChatMessage(player, lang.GetMessage("Invalid Parameter Chat", this, player.Id).Replace("{parameter}", CommandArg)); return; } switch (CommandArg) { #region Group case "group": string message = ""; foreach (var messageText in Config["Messages", "Group Information"] as List <object> ) { message = message + messageText + "\n"; } SendInfoMessage(player, message.Replace("{promotionkey}", promotionKey)); return; #endregion #region Check case "check": if (!HasPerm && !player.IsServer) { SendChatMessage(player, lang.GetMessage("No Permission", this, player.Id).Replace("{player}", player.Name).Replace("{command}", CommandInfo)); return; } if (args.Length == 1) { SendChatMessage(player, lang.GetMessage("Invalid Syntax Check", this, player.Id)); return; } IPlayer target; target = GetPlayer(args[1], player); if (target == null) { return; } if (PromotingInfo.IsPromoting(target)) { SendChatMessage(player, lang.GetMessage("Player Is Promoting", this, player.Id).Replace("{player}", target.Name)); return; } SendChatMessage(player, lang.GetMessage("Player Not Promoting", this, player.Id).Replace("{player}", target.Name)); return; #endregion #region Help case "help": if (HasPerm) { SendInfoMessage(player, lang.GetMessage("Admin Help1", this, player.Id)); return; } SendInfoMessage(player, lang.GetMessage("Player Help", this, player.Id)); return; #endregion #region Remove case "remove": if (!HasPerm && !player.IsServer) { SendChatMessage(player, lang.GetMessage("No Permission", this, player.Id).Replace("{player}", player.Name).Replace("{command}", CommandInfo)); return; } if (args.Length == 1) { SendChatMessage(player, lang.GetMessage("Invalid Syntax Remove", this, player.Id)); return; } IPlayer Target; Target = GetPlayer(args[1], player); if (Target == null) { return; } if (!PromotingInfo.IsPromoting(Target)) { SendChatMessage(player, lang.GetMessage("Player Not Promoting", this, player.Id).Replace("{player}", Target.Name)); return; } permission.RemoveUserGroup(Target.Id, groupKey); promoters.Remove(Target.Id); SaveData(promoters); SendChatMessage(player, lang.GetMessage("Admin Removed User", this, player.Id).Replace("{target}", Target.Name).Replace("{group}", groupKey)); return; #endregion } }