How i start server?

For all mod-related questions and custom code.
Post Reply
Playdude98
Offline
Posts: 24
Joined: July 16th, 2011, 5:09 am

How i start server?

Post 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

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: How i start server?

Post 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.

Playdude98
Offline
Posts: 24
Joined: July 16th, 2011, 5:09 am

Re: How i start server?

Post 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

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: How i start server?

Post 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("
        }
You cannot use certain BBCodes: [img].

User avatar
Moose
Offline
Posts: 14
Joined: January 18th, 2012, 6:16 am

Re: How i start server?

Post 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

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: How i start server?

Post 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.
You cannot use certain BBCodes: [img].

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: How i start server?

Post by BobKare »

I would suggest this:
Show

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: How i start server?

Post 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
Last edited by Jonty800 on February 4th, 2012, 10:30 am, edited 2 times in total.
You cannot use certain BBCodes: [img].

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: How i start server?

Post 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 ;)

Post Reply