Jump to content

[Share]Custom PvP Related Hero Status + Announce including


Recommended Posts

Hello , latest not share done so i will share a shit now .. its nothing to be serius with .. just some small crappy codes that will make your server great :D

 

Lets start ,

 

*L2PcInstance

 

find

public void increasePvpKills()

 

you will see under it thoose

 

{
        // Add karma to attacker and increase its PK counter
        setPvpKills(getPvpKills() + 1);
        CustomHeroSystem();

         // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
        sendPacket(new UserInfo(this));
        sendPacket(new ExBrExtraUserInfo(this));
    }

 

Now , after this you have to add

 

public void CustomHeroSystem()
    {
    	L2PcInstance activeChar = L2PcInstance.getClient().getActiveChar();
    	
        if (activeChar.getPvpKills() >= 5000)
        {
        	activeChar.sendMessage("You are now a server hero for beign so great fighter!");
      Announcements.getInstance().announceToAll(activeChar.getName() + "Is now a server's hero!");
        	activeChar.setHero(true); 
        }

 

 

 

If it gives you errors in announcements , you simple press right click on the error and select import announcements , and TADAMM

 

 

ps , code is tested on L2JServer Gracia Final part ;) thanks!

Link to comment
Share on other sites

fix the typo on the

activeChar.sendMessage("You are now a server hero for beign so great fighter!");

beign =P

 

Thanks for sharing it for mxc.

Added at the list.

Link to comment
Share on other sites

Shit , cant you manually?We , Legendary members are so imba that we dont have edit post xD

Link to comment
Share on other sites

I've told you EXACTLY the same thing with your previous share..

 

So what this code does as we see it now.. Each time someone with more than 5000 pvps gets a pvp, he's being announced as a hero. Which is wrong. Should be displayed only the first time.

 

Anyway thanks for trying, but try more & improve it =)

Link to comment
Share on other sites

put a check if the char is already a hero? it can cause some NPE's and this what fakoykas said :)

 

if (!activeChar.isHero() && activeChar.getPvpCount() >= 5000)

{

;

}

Link to comment
Share on other sites

put a check if the char is already a hero? it can cause some NPE's and this what fakoykas said :)

 

if (!activeChar.isHero() && activeChar.getPvpCount() >= 5000)

{

;

}

Exactly what i told him at his other hero-related share. But he doesn't want to listen =(

Link to comment
Share on other sites

put a check if the char is already a hero? it can cause some NPE's and this what fakoykas said :)

 

if (!activeChar.isHero() && activeChar.getPvpCount() >= 5000)

{

;

}

 

ahh you are right. sorry :d (my mistake)

Link to comment
Share on other sites

Ok.. here's how it should be :D

 

public void CustomHeroSystem()

   {

       if (!isHero() && getPvpKills() == 5000)

       {

          //announce & message ONLY when they reach 5000 pvp.

          sendMessage("You are now a server hero for being so great fighter!");

          Announcements.getInstance().announceToAll(getName() + " Is now a server's hero!");

          setHero(true);

       }

 

and Now in EnterWorld.java

 

    if (!activeChar.isHero() && activeChar.getPvPKills > 5000)

          setHero(true);

 

So now the announce is only been announced if the char is not hero already and ONLY when he reaches 5000 pvps..

Also he doesn't lose hero at his relogin =)

 

Regards.

Link to comment
Share on other sites

Ok.. here's how it should be :D

 

public void CustomHeroSystem()

    {

        L2PcInstance activeChar = L2PcInstance.getClient().getActiveChar();

        if (!activeChar.isHero() && activeChar.getPvpKills() == 5000)

        {

          //announce & message ONLY when they reach 5000 pvp.

          activeChar.sendMessage("You are now a server hero for being so great fighter!");

          Announcements.getInstance().announceToAll(activeChar.getName() + "Is now a server's hero!");

          activeChar.setHero(true);

        }

 

and Now in EnterWorld.java

 

    if (!activeChar.isHero() && activeChar.getPvPKills > 5000)

          setHero(true);

 

So now the announce is only been announced if the char is not hero already and ONLY when he reaches 5000 pvps..

Also he doesn't lose hero at his relogin =)

 

Regards.

 

the only problem with this is this only for enterworld not after they make the pvp.

also you missed an if(activeChar == null) check.

 

Link to comment
Share on other sites

the only problem with this is this only for enterworld not after they make the pvp.

also you missed an if(activeChar == null) check.

Check the whole topic, it's just an addition to what HαRǾC« shared.

 

He has already added the method after setPvpKills(getPvpKills() + 1); so activeChar == null is not needed and neither in enterworld is needed as they are already there =)

Link to comment
Share on other sites

Check the whole topic, it's just an addition to what HαRǾC« shared.

 

He has already added the method after setPvpKills(getPvpKills() + 1); so activeChar == null is not needed and neither in enterworld is needed as they are already there =)

 

i checked and i dont see the npe check it needs to be in the public void CustomHeroSystem() because okay the activeChar is defined but the null check no

Link to comment
Share on other sites

Stef u cant get an npe if its already hero...

 

Definition of NPE: A null value where it shoulnt be null. full name of NPE = Null Pointer Exception extended class of RuntimeException.

 

And Inter.. u dont need a null check...

 

whats so hard?

L2PcInstance.java:

public void parsePvPCustomHero()
{
       if (!isHero() && getPvpKills() >= 5000)
       {
          //announce & message ONLY when they reach 5000 pvp.
          sendMessage("You are now a server hero for being such a great fighter!");
          Announcements.getInstance().announceToAll(activeChar.getName() + "Is now a server's hero!");
          setHero(true);
       }
}

EnterWorld.java

// You know the deal...
activeChar.parsePvPCustomHero();

 

And everything is manage in pc instance doooh!!

Is that hard?

 

Anyway nice work HαRǾC« ur getting better and better, keep it up :P

PS: And it shoud be getPvpKills() >= 5000 (biger or equal) else it will give hero status only if the player has 5000 if its 5001 bby hero :D

Link to comment
Share on other sites

Stef u cant get an npe if its already hero...

 

Definition of NPE: A null value where it shoulnt be null. full name of NPE = Null Pointer Exception extended class of RuntimeException.

 

And Inter.. u dont need a null check...

 

whats so hard?

L2PcInstance.java:

public void parsePvPCustomHero()
{
        if (!isHero() && getPvpKills() >= 5000)
        {
           //announce & message ONLY when they reach 5000 pvp.
           sendMessage("You are now a server hero for being such a great fighter!");
           Announcements.getInstance().announceToAll(activeChar.getName() + "Is now a server's hero!");
           setHero(true);
        }
}

EnterWorld.java

// You know the deal...
activeChar.parsePvPCustomHero();

 

And everything is manage in pc instance doooh!!

Is that hard?

 

Anyway nice work HαRǾC« ur getting better and better, keep it up :P

PS: And it shoud be getPvpKills() >= 5000 (biger or equal) else it will give hero status only if the player has 5000 if its 5001 bby hero :D

 

still only for enterworld not by instant after the pvp...and yes you can use the isHero() to avoid the null check anyway the check method should be in the increasePvpKills() too

Link to comment
Share on other sites

omg dude.. u just add in increasePvpKills() the call method: parsePvPCustomHero().

And its instantly after pvp doooh... besides that u dont need that check into increasePvpKills() if u can use it in parsePvPCustomHero(), it keeps the code clean... lolz

And also isHero is not a null check wtf ?:D that !ishero has to return false so that a normal hero dosent get parsed for nothing... and also its there if the player is already hero by pvp.. to skip the parsing method that way its more efficient.. dooh >.>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...