Page 1 of 1
Explain different
Posted: Sun Jan 25, 2015 5:38 pm
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
Re: Explain different
Posted: Tue Jan 27, 2015 3:47 pm
by Bencratus
Sorry for spam, I know it is not very good question, but someone can explain?
Thanks,
Bencratus
Re: Explain different
Posted: Tue Jan 27, 2015 3:55 pm
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
Re: Explain different
Posted: Tue Jan 27, 2015 3:59 pm
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:
???
Thanks,
Bencratus
Re: Explain different
Posted: Tue Jan 27, 2015 4:00 pm
by Sdw
Always use getActingPlayer, easier.
Re: Explain different
Posted: Tue Jan 27, 2015 4:01 pm
by Bencratus
Sdw wrote:Always use getActingPlayer, easier.
If it is the same and you say so.
Thanks,
Bencratus
Re: Explain different
Posted: Wed Jan 28, 2015 1:28 pm
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.