Page 1 of 1

command making

Posted: April 2nd, 2012, 7:23 am
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?

Re: command making

Posted: April 2nd, 2012, 9:16 am
by BobKare
If you'd wrote that command, you would have known.

Re: command making

Posted: April 2nd, 2012, 10:42 am
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.

Re: command making

Posted: April 3rd, 2012, 1:25 am
by Silvytabitha
sorry i just edited a bit... Thanks anyway..