Example #1
0
        public void duty(UnturnedPlayer caller, Reason r, DutyGroup dg)
        {
            bool c = true;

            foreach (var pod in OnDuty_Players)
            {
                if (pod.Player.CSteamID == caller.CSteamID)
                {
                    c = false;
                    if (pod.DutyGroup.Group == null)
                    {
                        caller.Admin(false);
                    }
                    else
                    {
                        R.Permissions.RemovePlayerFromGroup(pod.DutyGroup.Group, caller);
                    }
                    OnDuty_Players.Remove(pod);
                    if (Configuration.Instance.EnableServerAnnouncer)
                    {
                        UnturnedChat.Say(Translate("off_duty_message", caller.DisplayName), UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, Color.blue));
                    }
                }
                break;
            }
            if (c)
            {
                if (r != null && dg != null)
                {
                    if (dg.Group == null)
                    {
                        caller.Admin(true);
                        if (Configuration.Instance.EnableServerAnnouncer)
                        {
                            UnturnedChat.Say(Translate("on_duty_message", caller.DisplayName), UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, Color.blue));
                        }
                    }
                    else
                    {
                        R.Permissions.AddPlayerToGroup(dg.Group, caller);
                        if (Configuration.Instance.EnableServerAnnouncer)
                        {
                            UnturnedChat.Say(Translate(r.Translate_Id, caller.DisplayName), UnturnedChat.GetColorFromName(Configuration.Instance.MessageColor, Color.blue));
                        }
                    }

                    OnDuty_Players.Add(new onDuty
                    {
                        Player    = caller,
                        DutyGroup = dg,
                        Reason    = r
                    });
                }
            }
        }
Example #2
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            bool           c      = true;
            UnturnedPlayer player = (UnturnedPlayer)caller;

            foreach (var pod in Duty.Instance.OnDuty_Players)
            {
                Rocket.Core.Logging.Logger.LogWarning(pod.Player.DisplayName);
                if (pod.Player.CSteamID == player.CSteamID)
                {
                    Rocket.Core.Logging.Logger.LogWarning(caller.DisplayName);
                    Duty.Instance.duty(player, null, null);
                    c = false;
                }
            }
            if (c)
            {
                if (command.Length == 0)
                {
                    command = new string[] { "" };
                }
                DutyGroup p_dg = null;
                foreach (var dg in Duty.Instance.Configuration.Instance.DutyGroups)
                {
                    if (player.HasPermission(dg.Permission))
                    {
                        p_dg = dg;
                    }
                }
                if (p_dg == null)
                {
                    if (player.HasPermission(Duty.Instance.Configuration.Instance.SuperAdminPermission))
                    {
                        p_dg = new DutyGroup
                        {
                            Group      = null,
                            Permission = Duty.Instance.Configuration.Instance.SuperAdminPermission,
                            Reasons    = null
                        };
                    }
                }
                if (p_dg == null)
                {
                    UnturnedChat.Say(caller, Duty.Instance.Translate("no_dutygroup"), Color.red);
                }

                string reasons = "";
                if (p_dg.Reasons != null)
                {
                    foreach (var r in p_dg.Reasons)
                    {
                        reasons += r.Name + " | ";
                    }
                    reasons += "||";
                    reasons  = reasons.Replace(" | ||", string.Empty);
                }
                else
                {
                    reasons = "You do not need a reason to go on duty!";
                }
                if (p_dg.Group == null)
                {
                    UnturnedChat.Say(caller, Duty.Instance.Translate("reasons", "SUPER ADMIN", reasons), Color.red);
                }
                else
                {
                    UnturnedChat.Say(caller, Duty.Instance.Translate("reasons", p_dg.Group, reasons), Color.red);
                }
            }
        }
Example #3
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            bool           c      = true;
            UnturnedPlayer player = (UnturnedPlayer)caller;

            foreach (var pod in Duty.Instance.OnDuty_Players)
            {
                Rocket.Core.Logging.Logger.LogWarning(pod.Player.DisplayName);
                if (pod.Player.CSteamID == player.CSteamID)
                {
                    Rocket.Core.Logging.Logger.LogWarning(caller.DisplayName);
                    Duty.Instance.duty(player, null, null);
                    c = false;
                }
            }
            if (c)
            {
                if (command.Length == 0)
                {
                    command = new string[] { "" };
                }
                DutyGroup p_dg = null;
                Reason    p_r  = null;
                foreach (var dg in Duty.Instance.Configuration.Instance.DutyGroups)
                {
                    if (player.HasPermission(dg.Permission))
                    {
                        p_dg = dg;
                    }
                }
                if (p_dg == null)
                {
                    if (player.HasPermission(Duty.Instance.Configuration.Instance.SuperAdminPermission))
                    {
                        p_dg = new DutyGroup
                        {
                            Group      = null,
                            Permission = Duty.Instance.Configuration.Instance.SuperAdminPermission,
                            Reasons    = null
                        };
                    }
                }
                if (p_dg == null)
                {
                    UnturnedChat.Say(caller, Duty.Instance.Translate("no_dutygroup"), Color.red);
                }
                else
                {
                    if (p_dg.Reasons != null)
                    {
                        p_dg.Reasons.ForEach((r) =>
                        {
                            if (r.Name == command[0])
                            {
                                p_r = r;
                            }
                        });
                    }
                    else
                    {
                        p_r = new Reason
                        {
                            Name         = "sadmin",
                            Translate_Id = "on_duty_message"
                        };
                    }
                }


                if (p_r == null)
                {
                    string reasons = "";
                    foreach (var r in p_dg.Reasons)
                    {
                        reasons += r.Name + " | ";
                    }
                    reasons += "||";
                    reasons  = reasons.Replace(" | ||", string.Empty);
                    UnturnedChat.Say(caller, Duty.Instance.Translate("no_reason", reasons), Color.red);
                }
                else
                {
                    Duty.Instance.duty(player, p_r, p_dg);
                }
            }
        }