command making

For all mod-related questions and custom code.
Post Reply
Silvytabitha
Offline
Posts: 50
Joined: December 29th, 2011, 11:42 am
Location: Australia
Contact:

command making

Post by Silvytabitha »

i have been able to edit vanillas version

i have taken out and edited commands;
how do i add commands;
so fair i copy what other commands have, but wheres the purpose go, like /write

this is my edited /slap code

Code: Select all

        static readonly CommandDescriptor CdSlap = new CommandDescriptor
        {
            Name = "Slap",
            IsConsoleSafe = true,
            NotRepeatable = false,
            Aliases = new[] { "sky""hit""punch" },
            Category = CommandCategory.Moderation,
            Permissions = new[] { Permission.Slap },
            Help = "Slaps a player to the sky.",
            Handler = Slap
        };

        static void Slap(Player player, Command cmd)
        {
            string name = cmd.Next();

            if (name == null)
            {
                player.Message("Please enter a name, or else you cannot slap someone,");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);

            if (target == null) return;
            

            if ((DateTime.Now - player.Info.LastUsedSlap).TotalSeconds < 1)
            {
                player.Message("&CYou can only use /Slap once every 1 seconds. Slow down.");
                return;
            }

            if (player.Can(Permission.Slap, target.Info.Rank))
            {
                Position slap = new Position(target.Position.X, target.Position.Y, (target.World.Map.Bounds.ZMax) * 32);
                Server.Players.CanSee(target).Message("{0} &swas slapped sky high by {1}", target.ClassyName, player.ClassyName);
                target.TeleportTo(slap);
                player.Info.LastUsedSlap = DateTime.Now;
                return;
            }

            else
            {
                player.Message("&sYou can only Slap players ranked {0}&S or lower",
                               player.Info.Rank.GetLimit(Permission.Slap).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
            }
        }
with this idea how do i make commands?

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

Re: command making

Post by BobKare »

If you'd wrote that command, you would have known.

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

Re: command making

Post by Jonty800 »

Silv didn't write this command, its exactly the same as my code except its been badly modified and will not work.

If you're asking about plugins such as my /Write, plugins are not a feature of fCraft just yet, they're coming soon. My /Slap command is not compatible with fCraft, if you have a reasonable understanding of programming then you'll be able to make it compatible yourself.
You cannot use certain BBCodes: [img].

Silvytabitha
Offline
Posts: 50
Joined: December 29th, 2011, 11:42 am
Location: Australia
Contact:

Re: command making

Post by Silvytabitha »

sorry i just edited a bit... Thanks anyway..

Post Reply