public void Execute(IRocketPlayer caller, string[] command) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); if (caller != null) { UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length != 1) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("accept_usage")); return; } else if (command.Length == 1) { UnturnedPlayer Target = UnturnedPlayer.FromName(command[0].ToLower()); if (RocketJobs.Instance.Applications.ContainsKey(Target.CSteamID)) { string JobName = RocketJobs.Instance.Applications[Target.CSteamID]; foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { if (Job.JobName.ToLower() == JobName.ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { Permissions.AddPlayerToGroup(Job.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_accepted_application", Target.CharacterName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Job.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Job.JobName)); } return; } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_not_leader_of_job", Job.JobName)); return; } } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_invalid_job_in_storage")); return; } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_applying")); return; } } }
public void AddToGroup(UnturnedPlayer untPlayer, string group) { RocketPermissionsManager rocketPerms = R.Instance.GetComponent <RocketPermissionsManager>(); if (GroupExists(group)) { rocketPerms.AddPlayerToGroup(group, untPlayer); if (Config.LogChanges) { Logger.Log(Translate("log_rank_added_to", untPlayer.DisplayName, untPlayer.Id, group)); } } }
public void Execute(IRocketPlayer caller, string[] command) { if (caller != null) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length > 3 || command.Length < 2) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } else if (command.Length == 2) { if (command[0].ToLower() == "clear") { #region FindGroupAndClear foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "add" || command[0].ToLower() == "remove") { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } else if (command.Length == 3) { if (command[0].ToLower() == "clear") { #region FindGroupAndClear foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "add") { UnturnedPlayer Target = UnturnedPlayer.FromName(command[2].ToLower()); CSteamID TargetID = Target.CSteamID; #region PreventDoubleJoining foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string Members in Group.Members) { if (Members == TargetID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job_admin")); return; } } } } foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string Members in Group.Members) { if (Members == TargetID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job_admin")); return; } } } RocketPermissionsGroup Group2 = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group2 != null) { foreach (string IDS in Group2.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_of_a_job_admin")); return; } } } } #endregion #region FindGroupAndAdd foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job_admin", Target.CharacterName, Jobs.JobName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Jobs.JobName)); } return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job_admin", Target.CharacterName, Jobs.JobName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Jobs.JobName)); } return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "remove") { UnturnedPlayer Target = UnturnedPlayer.FromName(command[2].ToLower()); CSteamID TargetID = Target.CSteamID; #region FindGroupAndRemove foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { foreach (string Member in Group.Members) { if (Member == TargetID.ToString()) { Permissions.RemovePlayerFromGroup(Group.Id, Target); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName)); } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_in_job", Jobs.JobName)); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { foreach (string Member in Group.Members) { if (Member == TargetID.ToString()) { Permissions.RemovePlayerFromGroup(Group.Id, Target); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName)); } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_in_job", Jobs.JobName)); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } } }
public void Execute(IRocketPlayer caller, string[] command) { if (caller != null) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length != 1) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("join_apply_usage")); return; } else if (command.Length == 1) { #region PreventMakingMoreThan1Application if (RocketJobs.Instance.Applications.ContainsKey(Player.CSteamID)) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_applying")); } #endregion #region PreventDoubleJoining foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job")); return; } } } if (Group == null) { Logger.LogWarning("Permission Group " + Job.PermissionGroup + " does not exist!"); } } foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job")); return; } } } else if (Group == null) { Logger.LogWarning("Permission Group " + Job.PermissionGroup + " does not exist!"); } RocketPermissionsGroup Group2 = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group2 != null) { foreach (string IDS in Group2.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_of_a_job")); return; } } } else if (Group2 == null) { Logger.LogWarning("Permission Group " + Job.LeaderPermissionGroup + " does not exist!"); } } #endregion #region FindAndJoin foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[0].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, caller); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Player.CharacterName, Jobs.JobName)); } return; } else if (Group == null) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_contact_admin")); Logger.LogWarning("Permission Group " + Jobs.PermissionGroup + " does not exist!"); } } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[0].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.LeaderPermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { foreach (SteamPlayer player in Provider.clients) { if (IDS == player.playerID.steamID.ToString()) { UnturnedPlayer target = UnturnedPlayer.FromCSteamID(player.playerID.steamID); RocketJobs.Instance.Applications.Add(ID, Jobs.JobName); UnturnedChat.Say(target, RocketJobs.Instance.Translate("notification_player_applying", Player.CharacterName)); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_applied_to_job", Jobs.JobName)); return; } } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_offline", Jobs.JobName)); return; } else if (Group == null) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_contact_admin")); Logger.LogWarning("Permission Group " + Jobs.PermissionGroup + " does not exist!"); } } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[0].ToLower())); } } }