Jump to content
  • 0

[Help]Restrict Castle Cloaks to be used only by castle owners


Question

Posted

As the title says, on my server I have the custom cloaks (Aden Cloak, Dion Cloak, etc...) and I want only the members that own that castle to equip them. And if they loose the castle, they loose the cloak.

Kinda like the "The Lord's Crown".

I have been editing some java code inside the chamberlain configuration but it hasn't worked.

Here is the code i came up with:

 

else if (actualCommand.equals("give_cloak"))

{

if (siegeBlocksFunction(player))

return;

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

 

if (player.isClanLeader() && _castleId==5) <-I made that custom, so that the castle was Aden

{

if (player.getInventory().getItemByItemId(64000) == null)<-Aden Cloak ID

{

L2ItemInstance crown = player.getInventory().addItem("Aden Cloak", 64000, 1, player, this);

SystemMessage ms = new SystemMessage(SystemMessageId.EARNED_ITEM);

ms.addItemName(crown);

player.sendPacket(ms);

 

html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/chamberlain-gavecrown.htm");

html.replace("%CharName%", String.valueOf(player.getName()));

html.replace("%FeudName%", String.valueOf(getCastle().getName()));

}

else

html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/chamberlain-hascrown.htm");

}

else

html.setFile(player.getHtmlPrefix(), "data/html/chamberlain/chamberlain-noprivs.htm");

 

player.sendPacket(html);

return;

}

 

 

 

Ofcourse after that i edited the chamberlain html and added this line:

<a action="bypass -h npc_%objectId%_give_cloak">Aden Cloak</a><br>

7 answers to this question

Recommended Posts

  • 0
Posted

i wont code it for you, but ima give you some tips.

 

In l2j every npc can get the current castle his in("this.getCastle()" - the chamberline in this instance or w/e the name), so you gotta do a simple switch case with castles then you can use your method to give the lord the cloak. And for the losing part, check CrownManager, you'll see there the methods when the crown gets destroyed.

 

The npc instance should look like this:


 int cloakId = 0;
 switch(this.getCastle().getCastleId())
 {
    case 1: cloakId = 12345; break;
    case 2: cloakId = 12345; break;
    case 3: cloakId = 12345; break;
    case 4: cloakId = 12345; break;
    case 5: cloakId = 12345; break;
    case 6: cloakId = 12345; break;
    case 7: cloakId = 12345; break;
    case 8: cloakId = 12345; break;
    case 9: cloakId = 12345; break;
 }

 if(cloakId > 0)
 {
    // Do stuff
 }

 

hope it helped, cheers

  • 0
Posted

Well, i custom coded it, i got it to work to GIVE the cloaks per castle, but now i want to know how to implement item restriction, like giran cloak can only be used by people that own the giran castle.

mmm, i have to do smth similar to that too for one of my projects, tho im new to gracia and up, ill have your answer after i dig up more info today :P

 

Later edit: My lil research leaded me to this, the cloaks being equipped and so on is handled client side, so in order to get them working to your method is to crack the system folder, requires client mod. (Witch i kinda lack info)

 

But i think i came up with a cheat, you can lie to the client about wearing a cloak xD

You can do it like so:

      - Set a new item with is the cloak item as 'back' bodypart

      - Edit the userinfo packet and charinfo packet to broadcast the user using a cloak.

  • 0
Posted

Well, you guys both wrong:P

After a couple of hours of searching and some help from my friends at L2J, i figured it out. Its not client side, its not core side. Its server side. All inside the xml. Must add a new condition like this:

 

<cond msgId="1518">

<and>

<player castle="5" /> <-Castle id

<player pledgeClass="2" /> <- Player rank. In this case: Heir(clan members).

</and>

</cond>

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
Answer this question...

×   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...