Page 1 of 1

Proper teleportation

Posted: Wed Nov 14, 2012 7:50 am
by RmzVoid
I am create custom Npc
This NPC teleports player by request to a instanced zone.
I save in DB instanceId.
If player restarted while instance not expired all ok. But if player enters to game then instance zone expired he must be teleported to this NPC.

This is done by code:

Code: Select all

            player.setInstanceId(0);            if(player.isDead()) player.doRevive();            player.teleToLocation(116195, 16719, 10077);            player.broadcastStatusUpdate();            player.broadcastUserInfo(); 
I am place this code in EnterWorld packet.

but then it teleported he has a client crash with message:

Code: Select all

General protection fault! History: UMasterLevel::GetModel <- AActor::SetZone <- ULevel::SpawnActor <- (enchant_radiance) <- UMasterLevel::SpawnActor <- Init <- APawn::UpdateAbnormalState <- TickAllActors <- ULevel::Tick <- (NetMode=0) <- UMasterLevel::Tick <- TickLevel <- UGameEngine::Tick <- UpdateWorld <- MainLoop 
After that he normally enters the game and located in proper coodinates (116195, 16719, 10077).
But if player teleported from instance in usual way, no crash happens.

Any help? How to avoid crash?

Re: Proper teleportation

Posted: Wed Nov 14, 2012 8:04 am
by djmouse
You doing it a little bit wrong. AFAIR you can define a spawn point in xml, where player should be teleported after instance.

Re: Proper teleportation

Posted: Wed Nov 14, 2012 8:30 am
by RmzVoid
is this doing in instances XML files?

Re: Proper teleportation

Posted: Wed Nov 14, 2012 9:02 am
by djmouse
Sure

Re: Proper teleportation

Posted: Wed Nov 14, 2012 1:25 pm
by UnAfraid
Teleportation during enter world mostly ends up with critical error.
You should delay a little bit the teleport.

Re: Proper teleportation

Posted: Wed Nov 14, 2012 6:20 pm
by VlLight
I'm using this method for such things

Code: Select all

Index: java/com/l2jserver/gameserver/model/actor/L2Character.java===================================================================--- java/com/l2jserver/gameserver/model/actor/L2Character.java  (revision 5706)+++ java/com/l2jserver/gameserver/model/actor/L2Character.java  (working copy)@@ -778,7 +778,34 @@            teleToLocation(x, y, z, heading, 0);        }    }-   ++   /** Provides delayed teleportation */+   public void scheduleTeleport(int x, int y, int z, boolean randomOffset, long delay)+   {+       ThreadPoolManager.getInstance().scheduleGeneral(this.new TeleportTask(x, y, z, randomOffset), delay);+   }++   private class TeleportTask implements Runnable+   {+       private final int _x;+       private final int _y;+       private final int _z;+       private final boolean _randomOffset;++       private TeleportTask(int x, int y, int z, boolean randomOffset)+       {+           _x = x;+           _y = y;+           _z = z;+           _randomOffset = randomOffset;+       }+       @Override+       public void run()+       {+           L2Character.this.teleToLocation(_x, _y, _z, _randomOffset);+       }+   }+    /**     * Launch a physical attack against a target (Simple, Bow, Pole or Dual).<br>     * <B><U>Actions</U>:</B> 

Re: Proper teleportation

Posted: Wed Nov 14, 2012 9:37 pm
by RmzVoid
I will try it, thanks very much.

Re: Proper teleportation

Posted: Wed Dec 26, 2012 7:01 pm
by RmzVoid
VlLight wrote:I'm using this method for such things
Thx, this works.