/oprules - displays rules for operators

/oprules - displays rules for operators

Postby dzienny » 13 May 2012, 21:28

This custom command allows a server owner to add a set of rules for operators. The rules should be saved to "oprules.txt" file that is, or should be, located in the same folder as "rules.txt" (relative path: "text/oprules.txt"). In order to display the rules one should use "/oprules" command. Players with a rank equal to or grater than Admin can send oprules to other players.

Code: Select all
//
// Copyright 2012 - dzienny
//

using System.Collections.Generic;
using System.IO;

namespace MCDzienny
{
    class CmdOpRules : Command
    {
        public override string name { get { return "oprules"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "information"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }

        const string OpRulesFilePath = "text/oprules.txt";

        public override void Use(Player p, string message)
        {
            Player who = null;
            if (message != "")
            {
                if (p.group.Permission <= LevelPermission.Admin)
                {
                    Player.SendMessage(p, "You are not allowed to send /oprules to another player!");
                    return;
                }

                who = Player.Find(message);

                if (who == null)
                {
                    Player.SendMessage(p, "Couldn't find a player named " + message);
                    return;
                }
            }
            else
            {
                who = p;
            }

            if (!File.Exists(OpRulesFilePath))
                File.WriteAllText(OpRulesFilePath, "No rules entered yet!");

            string[] rules = File.ReadAllLines(OpRulesFilePath);

            Player.SendMessage(who, "Rules for Operators:");
            foreach (string s in rules)
                Player.SendMessage(who, s);
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "/oprules - displays rules for operators.");
            Player.SendMessage(p, "/oprules [player] - sends op-rules to a player.");
        }
    }
}
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: /oprules - displays rules for operators.

Postby creativemagic » 13 May 2012, 21:33

Thank you so much !
Owner of...
[Exclusive] Lava Survival
User avatar
creativemagic
 
Posts: 214
Joined: 12 Nov 2011, 20:26

Re: /oprules - displays rules for operators.

Postby dzienny » 13 May 2012, 21:39

creativemagic wrote:Thank you so much !

Whoah, that was a quick response :)
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: /oprules - displays rules for operators.

Postby creativemagic » 13 May 2012, 21:42

Just got on before going to bed... :D
Owner of...
[Exclusive] Lava Survival
User avatar
creativemagic
 
Posts: 214
Joined: 12 Nov 2011, 20:26

Re: /oprules - displays rules for operators.

Postby dzienny » 13 May 2012, 21:47

I've just noticed that I didn't change the class name from CmdRules to CmdOpRules. But it's fixed now.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: /oprules - displays rules for operators.

Postby dryfly21 » 15 May 2012, 04:04

dzienny wrote:I've just noticed that I didn't change the class name from CmdRules to CmdOpRules. But it's fixed now.

Seems Legit :D also will it be on the next update idk about you but I think it should :-/ along with /warn cmd but not my place to say
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /oprules - displays rules for operators.

Postby Ultima » 15 May 2012, 09:44

You can always place it in the command folder and autoload it on start. (texts/cmdautoload.txt)
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: /oprules - displays rules for operators.

Postby dryfly21 » 15 May 2012, 23:47

Ultima wrote:You can always place it in the command folder and autoload it on start. (texts/cmdautoload.txt)

bro do u think im dumb? i know how to do it. yes i know you where just trying to help but bro i am *not* new to using this program. im only new at coding in c#. also do you hate me or somthing?
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Re: /oprules - displays rules for operators.

Postby Ultima » 16 May 2012, 20:31

Question:

dryfly21 wrote:
dzienny wrote:I've just noticed that I didn't change the class name from CmdRules to CmdOpRules. But it's fixed now.

Seems Legit :D also will it be on the next update idk about you but I think it should :-/ along with /warn cmd but not my place to say


Response:

Ultima wrote:You can always place it in the command folder and autoload it on start. (texts/cmdautoload.txt)


1. I don't know how experienced you are
2. You don't have to randomly attack me.

I am only trying to help.
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: /oprules - displays rules for operators.

Postby dryfly21 » 19 May 2012, 18:41

Ultima wrote:Question:

dryfly21 wrote:
dzienny wrote:I've just noticed that I didn't change the class name from CmdRules to CmdOpRules. But it's fixed now.

Seems Legit :D also will it be on the next update idk about you but I think it should :-/ along with /warn cmd but not my place to say


Response:

Ultima wrote:You can always place it in the command folder and autoload it on start. (texts/cmdautoload.txt)


1. I don't know how experienced you are
2. You don't have to randomly attack me.

I am only trying to help.


I know I know I am sorry I freaked on or "attacked" you. I was mad that day and I tend to get madder when I read your msgs :-/
I know you only want(ed)to help
I am sorry. Will you forgive? No hard feelings?
dryfly21
 
Posts: 135
Joined: 07 Apr 2012, 03:27

Next

Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 9 guests

cron