public void ChangeMap(ushort ID, int x = -1, int y = -1, short instance = -1)
{
if (ID > 120)
{
Log.WriteLine(LogLevel.Warn, "Character trying to warp to unexisting map: {0}", ID);
DropMessage("Unable to transfer to this map. Error code 10");
return;
}
ZoneData zci = Program.GetZoneForMap(ID);
if (zci != null)
{
var v = zci.MapsToLoad.Find(m => m.ID == ID);
int tox = 0;
int toy = 0;
if (x < 0 || y < 0)
{
tox = v.RegenX;
toy = v.RegenY;
}
else
{
tox = x;
toy = y;
}
// Try setting up transfer.
ushort RandomID = (ushort)Program.Randomizer.Next(0, ushort.MaxValue);
InterHandler.TransferClient(zci.ID, this.Client.AccountID, this.Client.Username, this.Name, RandomID, this.Client.Admin, this.Client.Host);
Map.RemoveObject(MapObjectID);
Position.X = tox;
Position.Y = toy;
character.Map = (byte)ID;
Save();
Handler6.SendChangeZone(this, ID, tox, toy, zci.IP, zci.Port, RandomID);
}
else
{
DropMessage("Unable to transfer to this map. Error code 1");
}
}