Page 1 of 1

How i start server?

Posted: February 3rd, 2012, 10:43 pm
by Playdude98
I have made a command with some help of bob and also am wondering how do i start the server with the command

Re: How i start server?

Posted: February 3rd, 2012, 11:48 pm
by BobKare
The command we to started on isn't even close to done.
And you must compile the files by opening the fCraft file in the main folder.

Re: How i start server?

Posted: February 4th, 2012, 2:56 am
by Playdude98

Code: Select all

        #region Review

        static readonly CommandDescriptor CDReview = new CommandDescriptor
        {
            Name = Review,
            Category = CommandCategory.Chat,
            Aliases = new [] { "CheckBuild" },
            IsConsoleSafe = false,
            NotRepeatable = false,
            DisableLogging = true,
            Permissions = new [] { Permission.Chat },
            Usage = "/Review",
            Help = "Requests staff to review your build",
            Handler = ReviewHandler
        };

        static void ReviewHandler( Player player, Command cmd) {

            player.messagenow("Player Want an OP to review his/her build!");
        }

        #endregion

Re: How i start server?

Posted: February 4th, 2012, 3:04 am
by Jonty800

Code: Select all

        static readonly CommandDescriptor CDReview = new CommandDescriptor
        {
            Name = "Review",
            Category = CommandCategory.Chat,
            Aliases = new [] { "CheckBuild" },
            IsConsoleSafe = false,
            NotRepeatable = false,
            DisableLogging = true,
            Permissions = new [] { Permission.Chat },
            Usage = "/Review",
            Help = "Requests staff to review your build",
            Handler = ReviewHandler
        };

       internal static void ReviewHandler( Player player, Command cmd) {
           Server.Players.Message("{0}&S would like an OP to review his/her build!", player.ClassyName);
        }

Your code commented:

Code: Select all

static readonly CommandDescriptor CDReview = new CommandDescriptor //lowercase for the 'D' in CDReview
        {
            Name = Review, //name needs to be a string. "Review",
            Category = CommandCategory.Chat,
            Aliases = new [] { "CheckBuild" },
            IsConsoleSafe = false,
            NotRepeatable = false,
            DisableLogging = true,
            Permissions = new [] { Permission.Chat },
            Usage = "/Review",
            Help = "Requests staff to review your build",
            Handler = ReviewHandler
        };

        static void ReviewHandler( Player player, Command cmd) { //use internal static void

            player.messagenow("Player Want an OP to review his/her build!"); //never use MessageNow, use Message instead. But this will only send the player a message, not the server. So use Server.Players.Message("
        }

Re: How i start server?

Posted: February 4th, 2012, 4:47 am
by Moose
Playdude98 wrote:

Code: Select all

        #region Review

        static readonly CommandDescriptor CDReview = new CommandDescriptor
        {
            Name = Review,
            Category = CommandCategory.Chat,
            Aliases = new [] { "CheckBuild" },
            IsConsoleSafe = false,
            NotRepeatable = false,
            DisableLogging = true,
            Permissions = new [] { Permission.Chat },
            Usage = "/Review",
            Help = "Requests staff to review your build",
            Handler = ReviewHandler
        };

        static void ReviewHandler( Player player, Command cmd) {

            player.messagenow("Player Want an OP to review his/her build!");
        }

        #endregion
just a small suggestion:

replace:

Code: Select all

            player.messagenow("Player Want an OP to review his/her build!");
with:

Code: Select all

            Server.Players.Message("&SPlayer {0}&S Would like an OP to review his/her build!", player.ClassyName);
also, why is

Code: Select all

            IsConsoleSafe = false,
false?


-EDIT: woops, didn't see Jonty's post. :P

Re: How i start server?

Posted: February 4th, 2012, 5:48 am
by Jonty800
IsConsoleSafe pretty much means "can console use this command"

While the answer is "yes", you do not however want console to be reviewed. Console is not a player :P.

So I guess that's why he set it to false.

Re: How i start server?

Posted: February 4th, 2012, 9:51 am
by BobKare
I would suggest this:
Show

Re: How i start server?

Posted: February 4th, 2012, 10:14 am
by Jonty800
I would suggest this, it's more practical

Code: Select all

static readonly CommandDescriptor cdReview = new CommandDescriptor
        {
            Name = "Review",
            Category = CommandCategory.Chat,
            IsConsoleSafe = true,
            Usage = "/review",
            NotRepeatable = true,
            Help = "Request an Op to review your build.",
            Handler = Review
        };

        internal static void Review(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            var recepientList = Server.Players.Can(Permission.ReadStaffChat)
                                              .NotIgnoring(player)
                                              .Union(player);
            string message = String.Format("{0}&6 would like staff to check their build", player.ClassyName);
            recepientList.Message(message);
            var ReviewerNames = Server.Players
                                         .CanBeSeen(player)
                                         .Where(r => r.Can(Permission.Promote, player.Info.Rank));
            if (ReviewerNames.Count() > 0)
            {
                player.Message("&WOnline players who can review you: {0}", ReviewerNames.JoinToString(r => String.Format("{0}&S", r.ClassyName)));
                return;
            }
            else
                player.Message("&WThere are no players online who can review you. A member of staff needs to be online.");
        }
Edit: as a note, I wouldn't recommend using Chat.SendStaff for something like this. SendStaff uses

Code: Select all

String.Format( "&P(staff){0}&P: {1}",
                                                     player.ClassyName,
                                                     rawMessage );
This means that your message will only send to staff, but as (staff)Jonty800 Jonty800 would like an op to check their build

You can make your own String.Format instead like I have.

Code: Select all

string message = String.Format("{0}&6 would like staff to check their build", player.ClassyName);
then you need to make a list of everyone who you want to send the message to. You can do this two ways I guess.

Either

Code: Select all

foreach(Player p in Server.Players)
{
if(p.Can(Permission.ReadStaffChat)) //staff ya?
p.Message(message);
}
or even better

Code: Select all

var recepientList = Server.Players.Can(Permission.ReadStaffChat) //staff
                                              .NotIgnoring(player) //who are not ignoring the player
                                              .Union(player); //and send the player the message too
            string message = String.Format("{0}&6 would like staff to check their build", player.ClassyName); 
            recepientList.Message(message); //you've got mail

Re: How i start server?

Posted: February 4th, 2012, 10:28 am
by BobKare
Of course, Jonty, but it's his first command, and I wanted to make it as easy as possible, and as close as possible to his original command ;)