For all mod-related questions and custom code.
Jonty800
Offline Posts: 280 Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:
Post
by Jonty800 » February 3rd, 2012, 4:18 am
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
Post
by BobKare » February 3rd, 2012, 9:15 am
I will test it out
fragmer
fCraft Developer Offline Posts: 1386 Joined: May 21st, 2011, 10:53 pm
Post
by fragmer » February 3rd, 2012, 9:59 am
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
Post
by BobKare » February 3rd, 2012, 11:11 am
What is the code for "Error message" color?
I know System = &S, Help = &H, and the standard colors.
fragmer
fCraft Developer Offline Posts: 1386 Joined: May 21st, 2011, 10:53 pm
Post
by fragmer » February 3rd, 2012, 2:01 pm
&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
Post
by BobKare » February 3rd, 2012, 2:27 pm
Ty fragmer.
I'll write it down somewhere^^
Jonty800
Offline Posts: 280 Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:
Post
by Jonty800 » February 3rd, 2012, 2:39 pm
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].