Explain different

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Explain different

Post by Bencratus »

Hello,

can someone explain different between:

Code: Select all

L2PcInstance player = character.getActingPlayer();

Code: Select all

L2PcInstance player = ((L2PcInstance) character);
SITUATIONS:
Example sending message, updating abnormalEffect, if kill mob he get aura (L2Attackable).
* These situations is just examples, I need to know difference between these 2 things...

Thanks,
Bencratus
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Re: Explain different

Post by Bencratus »

Sorry for spam, I know it is not very good question, but someone can explain?

Thanks,
Bencratus
Sdw
L2j Veteran
L2j Veteran
Posts: 855
Joined: Mon May 03, 2010 8:38 am
Location: France

Re: Explain different

Post by Sdw »

Basically there is "no differences".

There is plenty of stuff extending L2Character though, and that method will ensure you always get a player without any cast expection happening.

E.g : your character is actually a summon, getActingPlayer returns its owner
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Re: Explain different

Post by Bencratus »

Sdw wrote:Basically there is "no differences".

There is plenty of stuff extending L2Character though, and that method will ensure you always get a player without any cast expection happening.

E.g : your character is actually a summon, getActingPlayer returns its owner
Hi, Sdw,

so if character doesn't do anything, and example it is just a message, I can use:

Code: Select all

L2PcInstance player = ((L2PcInstance) character);
but if character is e.g. launching skill, I better use:

Code: Select all

character.getActingPlayer()
???

Thanks,
Bencratus
Sdw
L2j Veteran
L2j Veteran
Posts: 855
Joined: Mon May 03, 2010 8:38 am
Location: France

Re: Explain different

Post by Sdw »

Always use getActingPlayer, easier.
User avatar
Bencratus
Posts: 51
Joined: Wed Jan 07, 2015 11:38 pm
Contact:

Re: Explain different

Post by Bencratus »

Sdw wrote:Always use getActingPlayer, easier.
If it is the same and you say so.

Thanks,
Bencratus
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7008
Joined: Tue Aug 11, 2009 3:36 am

Re: Explain different

Post by Zoey76 »

To perform a cast you need to check if the object is the correct instance, with getActiveChar() you get the player, if the creature is a player or a summon and null otherwise.
Powered by Eclipse 4.34 ๐ŸŒŒ | Eclipse Temurin 21 โ˜• | MariaDB 11.3.2 ๐Ÿ—ƒ๏ธ | L2J Server 2.6.3.0 - High Five ๐Ÿš€

๐Ÿ”— Join our Discord! ๐ŸŽฎ๐Ÿ’ฌ
Post Reply