Proper teleportation

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
RmzVoid
Posts: 35
Joined: Fri Mar 10, 2006 1:40 pm
Location: Russia

Proper teleportation

Post 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?
Now modding L2J...
L2J server revision: 5522
L2J datapack revision: 9008
djmouse
Posts: 135
Joined: Tue Feb 07, 2012 4:48 am

Re: Proper teleportation

Post 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.
User avatar
RmzVoid
Posts: 35
Joined: Fri Mar 10, 2006 1:40 pm
Location: Russia

Re: Proper teleportation

Post by RmzVoid »

is this doing in instances XML files?
Now modding L2J...
L2J server revision: 5522
L2J datapack revision: 9008
djmouse
Posts: 135
Joined: Tue Feb 07, 2012 4:48 am

Re: Proper teleportation

Post by djmouse »

Sure
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: Proper teleportation

Post by UnAfraid »

Teleportation during enter world mostly ends up with critical error.
You should delay a little bit the teleport.
Image
User avatar
VlLight
L2j Veteran
L2j Veteran
Posts: 577
Joined: Fri Dec 14, 2007 11:58 am
Location: Russia

Re: Proper teleportation

Post 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> 
User avatar
RmzVoid
Posts: 35
Joined: Fri Mar 10, 2006 1:40 pm
Location: Russia

Re: Proper teleportation

Post by RmzVoid »

I will try it, thanks very much.
Now modding L2J...
L2J server revision: 5522
L2J datapack revision: 9008
User avatar
RmzVoid
Posts: 35
Joined: Fri Mar 10, 2006 1:40 pm
Location: Russia

Re: Proper teleportation

Post by RmzVoid »

VlLight wrote:I'm using this method for such things
Thx, this works.
Now modding L2J...
L2J server revision: 5522
L2J datapack revision: 9008
Post Reply