Zepheus.Zone.Game.ZoneCharacter.ChangeMap C# (CSharp) Method

ChangeMap() public method

public ChangeMap ( ushort ID, int x = -1, int y = -1, short instance = -1 ) : void
ID ushort
x int
y int
instance short
return void
        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");
            }
        }

Usage Example

Example #1
0
 private void Movetoplayer(ZoneCharacter character, params string[] param)
 {
     string player = param[1];
     ZoneClient playerc = ClientManager.Instance.GetClientByName(player);
     character.ChangeMap(playerc.Character.MapID, playerc.Character.Position.X, character.Position.Y);
 }
All Usage Examples Of Zepheus.Zone.Game.ZoneCharacter::ChangeMap