Page 1 of 1

Wedding question

Posted: Fri Jan 07, 2011 10:12 pm
by papadkostas
hey all :D
i wanted to make when someone trying to gotolove, send a message to partner that his love coming to him with a system message..
i got edited some lines of wedding.java(almost at the EOF)
but i'm not sure(eclipse didnt showed me any warning/error) if its the right way to do this..or if i can make it much more short edit that the one i did!
and by the way dont flame me plz for a such an easy question for you..
cause i'm just a newbie that tryes to learn and be a better one in future and help our community :|
excuse me that i didnt used

Code: Select all

  but i didnt know how and if it is possible to highlight with color!
red colored = added code  :) 

EscapeFinalizer ef = new EscapeFinalizer(activeChar,[color=#FF0000]partner,[/color] partner.getX(), partner.getY(), partner.getZ(), partner.isIn7sDungeon());
        // continue execution later
        activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, teleportTimer));
        activeChar.forceIsCasting(GameTimeController.getGameTicks() + teleportTimer / GameTimeController.MILLIS_IN_TICK);
        
        return true;
    }
    
    static class EscapeFinalizer implements Runnable
    {
        private L2PcInstance _activeChar;
       [color=#FF0000]private L2PcInstance _partnerId;[/color]
        private int _partnerx;
        private int _partnery;
        private int _partnerz;
        private boolean _to7sDungeon;
        
        EscapeFinalizer(L2PcInstance activeChar,L2PcInstance partnerId, int x, int y, int z, boolean to7sDungeon)
        {
            _activeChar = activeChar;
          [color=#FF0000] _partnerId = partnerId;[/color]
            _partnerx = x;
            _partnery = y;
            _partnerz = z;
            _to7sDungeon = to7sDungeon;
        }
        
        public void run()
        {
            if (_activeChar.isDead())
                return;
            
            if(SiegeManager.getInstance().getSiege(_partnerx, _partnery, _partnerz) != null && SiegeManager.getInstance().getSiege(_partnerx, _partnery, _partnerz).getIsInProgress())
            {
                _activeChar.sendMessage("Your partner is in siege, you can't go to your partner.");
                return;
            }
            
            _activeChar.setIsIn7sDungeon(_to7sDungeon);
            _activeChar.enableAllSkills();
            _activeChar.setIsCastingNow(false);
            
            try
            {
                _activeChar.teleToLocation(_partnerx, _partnery, _partnerz);
              [color=#FF0000] _partnerId.sendMessage("Your partner is teleporting to you!");[/color]
            }
and..thanks for your time!  :wink:

Re: Wedding question

Posted: Sat Jan 08, 2011 3:40 am
by Deadmeat
Try this, add the 6 lines that say add this line.

Code: Select all

    static class EscapeFinalizer implements Runnable    {        private L2PcInstance _activeChar;        private int _partnerx;        private int _partnery;        private int _partnerz;        private boolean _to7sDungeon;        L2PcInstance partner;      <----Add this Line        partner = L2World.getInstance().getPlayer(_partnerId);    <----Add this Line        EscapeFinalizer(L2PcInstance activeChar, int x, int y, int z, boolean to7sDungeon)        {            _activeChar = activeChar;            _partnerx = x;            _partnery = y;            _partnerz = z;            _to7sDungeon = to7sDungeon;        }                public void run()        {            if (_activeChar.isDead())                return;                        if(SiegeManager.getInstance().getSiege(_partnerx, _partnery, _partnerz) != null && SiegeManager.getInstance().getSiege(_partnerx, _partnery, _partnerz).getIsInProgress())            {                _activeChar.sendMessage("Your partner is in siege, you can't go to your partner.");                return;            }                        _activeChar.setIsIn7sDungeon(_to7sDungeon);            _activeChar.enableAllSkills();            _activeChar.setIsCastingNow(false);                        try            {                _activeChar.teleToLocation(_partnerx, _partnery, _partnerz);                if (partner != null)   <----Add this Line                {     <----Add this Line                   partner.sendMessage("Your partner is teleporting to you!");   <----Add this Line                }     <----Add this Line            }            catch (Exception e)            {                _log.log(Level.SEVERE, "", e);            }        }    }

Re: Wedding question

Posted: Sat Jan 08, 2011 10:48 pm
by papadkostas
:D i'll try it ..and i'll post what happened in both case's..
thank you :wink:

Re: Wedding question

Posted: Sun Jan 09, 2011 8:46 pm
by Ralm
Nice add =) I like it.

I allways saw wedding mod a bit simple. Lets do it more funny and usefull =)

Re: Wedding question

Posted: Sun Jan 09, 2011 9:14 pm
by jurchiks
What, no null checks?
...

Re: Wedding question

Posted: Mon Jan 10, 2011 5:54 am
by Deadmeat
send message is with the teleport command what do you need the null check for?

Re: Wedding question

Posted: Mon Jan 10, 2011 9:40 pm
by jurchiks
L2World.getInstance().getPlayer(_partnerId);
this can easily give you a null

Re: Wedding question

Posted: Tue Jan 11, 2011 6:03 am
by Deadmeat
No problem I added a null check for partner.

Turn line numbers off so you can see the code without word wrap.

Re: Wedding question

Posted: Tue Jan 11, 2011 1:17 pm
by jurchiks
Ahh, the null check should be before the EscapeFinalizer is initialized, because partner.getX() can already throw a NPE.
I'm rewriting the wedding mod, there's lots of useless stuff there.