Ejemplo n.º 1
0
        private void EventPlayerConnected(RocketPlayer player)
        {
            DateTime?cooldown = this.Database.GetCooldown(player.CSteamID.ToString(), "Global");

            if (cooldown != null)
            {
                player.GetComponent <GearUpComp>().Available = cooldown.Value;
            }
        }
Ejemplo n.º 2
0
 private void EventPlayerSpawn(RocketPlayer player, Vector3 position, byte angle)
 {
     player.GetComponent <GearUpComp>().Timer.Start();
 }
Ejemplo n.º 3
0
 private void EventPlayerDisconnected(RocketPlayer player)
 {
     this.Database.AddCooldown(player.GetComponent <GearUpComp>().Available, player.CSteamID.ToString(), "Global");
 }
Ejemplo n.º 4
0
        public void Execute(RocketPlayer player, string[] cmd)
        {
            if (!Initialized)
            {
                Initialize();
            }

            if (player == null)
            {
                return;
            }

            if (!Config.AllowCmd)
            {
                Say(player, GearUp.TDict["command_disabled"]?.ToString(), Config.ErrorColor);
                Log("GU: Commands are disabled.");
                return;
            }

            PERM perms = GetPermLevel(player);

            try {
                if (perms <= PERM.None && string.Join("", cmd) != "-info")
                {
                    Say(player, GearUp.TDict["access_denied"]?.ToString(), Color.red);
                    return;
                }

                if (cmd.Length == 0 && perms >= PERM.Self)
                {
                    player.GetComponent <GearUpComp>()?.AskGearUp();
                    return;
                }

                if (cmd.Length >= 1)
                {
                    if (!cmd[0].StartsWith("-"))
                    {
                        RocketPlayer pFromCmd = RocketPlayer.FromName(cmd[0]);
                        Kit          kFromCmd = GetKitByName(cmd[0]);

                        // kit
                        if (kFromCmd != null && perms >= PERM.Self)
                        {
                            player.GetComponent <GearUpComp>()?.AskGearUp(null, kFromCmd);
                            return;
                        }

                        // player
                        if (pFromCmd != null && perms >= PERM.Other)
                        {
                            if (cmd.Length >= 2)
                            {
                                kFromCmd = GetKitByName(cmd[1]);
                                if (kFromCmd != null)
                                {
                                    pFromCmd.GetComponent <GearUpComp>()?.AskGearUp(player, kFromCmd);
                                    //Say(player, $"{GearUp.TDict["gear_gift_success"]?.Replace("%P", pFromCmd.CharacterName)}", Config.SuccessColor);
                                    return;
                                }
                                else
                                {
                                    Say(player, $"{GearUp.TDict["access_denied_gift"]?.ToString()}", Config.ErrorColor);
                                    return;
                                }
                            }
                            else
                            {
                                Say(player, $"{GearUp.TDict["error_user_nokit"]?.ToString()}", Config.ErrorColor);
                                return;
                            }
                        }

                        // neither; bad user, no biscuit! D:<
                        Say(player, $"No matching kits or players, kits: ", Config.ErrorColor);
                        ReportPermittedKits(player);
                        return;
                    }
                    else if (cmd[0].StartsWith("-"))
                    {
                        switch (cmd[0])
                        {
                        case "-on":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = true;
                            Say(player, "GU: Enabled", Config.SuccessColor);
                            break;

                        case "-off":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = false;
                            Say(player, "GU: Disabled", Config.SuccessColor);
                            break;

                        case "-kits":
                        case "-list":
                        case "-l":
                            ReportPermittedKits(player);
                            break;

                        case "-?":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            ShowHelp(player);
                            break;

                        case "--":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            Say(player, $"GU: Plugin {(GearUp.Instance.enabled == true ? "enabled" : "disabled")}.", Color.gray);
                            break;

                        case "-reset":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            if (cmd.Length >= 2)
                            {
                                if (!string.IsNullOrEmpty(cmd[1]))
                                {
                                    RocketPlayer p = RocketPlayer.FromName(cmd[1]);
                                    if (p == null)
                                    {
                                        Say(player, $"GU: Failed to find player name matching '{cmd[1]}'!", Config.ErrorColor);
                                    }
                                    else
                                    {
                                        p.GetComponent <GearUpComp>()?.ResetCooldown(player);
                                    }
                                }
                            }
                            else
                            {
                                player.GetComponent <GearUpComp>()?.ResetCooldown();
                            }
                            break;

                        case "-info":
                            Say(player, $"GearUp {GearUp.Version} by Mash - Auria.pw [{(GearUp.Instance.enabled == true ? "enabled" : "disabled")}]", Config.InfoColor);
                            break;

                        default:
                            Say(player, "GU: Unknown operand", Config.ErrorColor);
                            break;
                        }
                        return;
                    }
                }
            } catch (Exception ex) {
                GearUp.STOP(ex.Message);
            }
        }