Example #1
0
        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                try
                {
                    int temp = int.Parse(message);
                    if (temp >= 0 && temp <= 2)
                    {
                        p.level.Physics = (Physics)temp;
                        switch (p.level.Physics)
                        {
                        case Physics.Off:
                            p.level.ClearPhysics();
                            Player.GlobalMessageLevel(p.level, "Physics is now &cOFF&e on &b" + p.level.name + "&e.");
                            Logger.Log("Physics is now OFF on " + p.level.name + ".");
                            IRCBot.Say("Physics is now OFF on " + p.level.name + ".");
                            break;

                        case Physics.Normal:
                            Player.GlobalMessageLevel(p.level, "Physics is now &aNormal&e on &b" + p.level.name + "&e.");
                            Logger.Log("Physics is now ON on " + p.level.name + ".");
                            IRCBot.Say("Physics is now ON on " + p.level.name + ".");
                            break;

                        case Physics.Advanced:
                            Player.GlobalMessageLevel(p.level, "Physics is now &aAdvanced&e on &b" + p.level.name + "&e.");
                            Logger.Log("Physics is now ADVANCED on " + p.level.name + ".");
                            IRCBot.Say("Physics is now ADVANCED on " + p.level.name + ".");
                            break;
                        }
                    }
                    else
                    {
                        p.SendMessage("Not a valid setting");
                    }
                }
                catch
                {
                    p.SendMessage("INVALID INPUT");
                }
            }
            else
            {
                Help(p);
            }
        }
Example #2
0
        // Code to be run when used
        public override void Use(Player p, string message)
        {
            int             number = message.Split(' ').Length;
            string          strLevelName;
            string          strPermission  = message;
            bool            blnLevelLoaded = false;
            Map             targetLevel;
            LevelPermission lvlPermission;

            if (message != "" || number <= 2)
            {
                targetLevel  = p.level;
                strLevelName = targetLevel.name;
                if (number == 1)
                {
                    lvlPermission = Map.PermissionFromName(message);
                    if (lvlPermission != LevelPermission.Null)
                    {
                        targetLevel.permissionvisit = lvlPermission;

                        Logger.Log(strLevelName + " Visit permission changed to " + strPermission + ".");
                        Player.GlobalMessageLevel(targetLevel, "Visit permission changed to " + strPermission + ".");
                    }
                    else
                    {
                        p.SendMessage("\"" + strPermission + "\" is not a valid rank");
                    }
                }
                else
                {
                    int pos = message.IndexOf(' ');
                    strLevelName  = message.Substring(0, pos).ToLower();
                    strPermission = message.Substring(pos + 1).ToLower();
                    lvlPermission = Map.PermissionFromName(strPermission);

                    if (lvlPermission != LevelPermission.Null)
                    {
                        foreach (Map level in Server.levels)
                        {
                            if (level.name.ToLower() == strLevelName.ToLower())
                            {
                                blnLevelLoaded = true;
                                targetLevel    = level;
                                break;
                            }
                        }

                        if (blnLevelLoaded)
                        {
                            targetLevel.permissionvisit = lvlPermission;
                            Logger.Log(strLevelName + " Visit permission changed to " + strPermission + ".");
                            Player.GlobalMessageLevel(targetLevel, "visit permission changed to " + strPermission + ".");
                            if (p.level != targetLevel)
                            {
                                p.SendMessage("Visit permission changed to " + strPermission + " on " + strLevelName + ".");
                            }
                        }
                        else
                        {
                            p.SendMessage("There is no level \"" + strPermission + "\" loaded.");
                        }
                    }
                    else
                    {
                        p.SendMessage("\"" + strPermission + "\" is not a valid rank");
                    }
                }
            }
            else
            {
                Help(p);
            }
        }