/Tpzone

For all mod-related questions and custom code.
Post Reply
Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

/Tpzone

Post by Jonty800 »

I know this has been rejected from suggestions in the past, but in case anyone would like this command, here is the source I wrote quite a while back.

Code: Select all

static readonly CommandDescriptor CdTPZone = new CommandDescriptor
        {
            Name = "Tpzone",
            IsConsoleSafe = false,
            Aliases = new[] { "tpz", "zonetp" },
            Category = CommandCategory.World | CommandCategory.Zone,
            Permissions = new[] { Permission.Teleport },
            Help = "Teleports you to the centre of a Zone listed in /Zones.",
            Usage = "/Tpzone ZoneName",
            Handler = TPZone
        };

        static void TPZone(Player player, Command cmd)
        {
            string zoneName = cmd.Next();
            if (zoneName == null){
                player.Message("No zone name specified. See &H/help tpzone");
                return;
            }else{
                Zone zone = player.World.Map.Zones.Find(zoneName);
                if (zone == null){
                    player.MessageNoZone(zoneName);
                    return;
                }
                Position zPos = new Position((((zone.Bounds.XMin + zone.Bounds.XMax) / 2) * 32),
                    (((zone.Bounds.YMin + zone.Bounds.YMax) / 2) * 32),
                    (((zone.Bounds.ZMin + zone.Bounds.ZMax) / 2) + 2) * 32);
                player.TeleportTo((zPos));
                player.Message("&WTeleporting you to zone " + zone.ClassyName);
            }
        }
Works perfectly.
Last edited by Jonty800 on May 8th, 2012, 1:45 pm, edited 3 times in total.
You cannot use certain BBCodes: [img].

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

Re: /Tpzone

Post by BobKare »

I will test it out :)

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: /Tpzone

Post by fragmer »

Tested, works exactly as advertised. One possible bug though - you use "&Z" colorcode in the "No zone name specified." message, that's not one of fCraft's standard ones.

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

Re: /Tpzone

Post by BobKare »

What is the code for "Error message" color?
I know System = &S, Help = &H, and the standard colors.

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: /Tpzone

Post by fragmer »

  • &S - System (default: yellow)
  • &Y - Say (default: green)
  • &H - Help/usage (default: Lime)
  • &R - Rules and announcements (default: green)
  • &P - Private and staff messages (default: aqua)
  • &I - IRC messages (default: purple)
  • &M - /Me messages (default: purple)
  • &W - Warnings and errors (default: red)

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

Re: /Tpzone

Post by BobKare »

Ty fragmer.
I'll write it down somewhere^^

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

Re: /Tpzone

Post by Jonty800 »

Thanks for spotting that lol, it's weird that is says &Z because I copied that bit from CdZoneList back in 0.53x haha.

Edit: I have no idea why there was &Z, was this ever a part of fCraft? I've noticed that its also in some of Glenn's code too, but its not in Color.cs. Hmmm :/
You cannot use certain BBCodes: [img].

Post Reply