Jump to content

[Share]VoicedCommand Enchant Weapon(with chance)


Recommended Posts

There is a faster and better way to do with with chance and not with switch and cases.

 

Good idea though.

ty elfo :P i like this way :) by the way you mean this faster way?

 

int rnd = Rnd.get(100);

 

if(rnd < chance)?

 

anyway i like the case more

Link to comment
Share on other sites

The chance should have been made in the proper way. I mean the way you enchant with scrolls.

 

Also the check for the gold bars must be put before the switch statement, otherwise the player might get trolled :P.

 

Good job.

Link to comment
Share on other sites

The chance should have been made in the proper way. I mean the way you enchant with scrolls.

 

Also the check for the gold bars must be put before the switch statement, otherwise the player might get trolled :P.

 

Good job.

ty An4rchy :)

 

if i will put it before they will lose 4 gold bars for nothing, hmmm i don't know think about it and answer me... :P

Edit:i forgot that: i don't want with the "clasic" way i want something mine, because if i will add the "clasic" way they will say that i just copy it from the client packet... && is custom :P

Link to comment
Share on other sites

Edit:i forgot that: i don't want with the "clasic" way i want something mine, because if i will add the "clasic" way they will say that i just copy it from the client packet... && is custom :P

Oh ok then :)

 

if i will put it before they will lose 4 gold bars for nothing, hmmm i don't know think about it and answer me... :P

Not really, you can do it like this:

if (activeChar.getInventory().getItemByItemId(3470) == null || activeChar.getInventory().getItemByItemId(3470).getCount() < 4)

{

      activeChar.sendMessage("You need 4 gold bars to use this.");

      return false;

}

 

And under case 5, you will remove this GoldBars boolean.

 

This is just to inform players that they don't have the gold bars before the switch statement. Otherwise they might be pressing the command for 2 minutes(till they get case 5) and get trolled :P

 

Another thing i just checked... Do you want players to use it whenever they want, or if they use it 4 gold bars to be taken(despite if they got case 5)?

Link to comment
Share on other sites

Oh ok then :)

Not really, you can do it like this:

if (activeChar.getInventory().getItemByItemId(3470) == null || activeChar.getInventory().getItemByItemId(3470).getCount() < 4)

{

      activeChar.sendMessage("You need 4 gold bars to use this.");

      return false;

}

 

And under case 5, you will remove this GoldBars boolean.

 

This is just to inform players that they don't have the gold bars before the switch statement. Otherwise they might be pressing the command for 2 minutes(till they get case 5) and get trolled :P

 

Another thing i just checked... Do you want players to use it whenever they want, or if they use it 4 gold bars to be taken(despite if they got case 5)?

updated :)
Link to comment
Share on other sites

    final int GoldBarID = 3470;

    final int GoldBarCount = 4;

 

    final L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

    final int MaxEnchant = Config.ENCHANT_WEAPON_MAX; 

    final boolean CheckGoldBars = activeChar.getInventory().getItemByItemId(GoldBarID) == null || activeChar.getInventory().getItemByItemId(GoldBarID).getCount() < GoldBarCount;

    final boolean ActiveWeapon = activeChar.getActiveWeaponInstance() != null;

    final boolean MaxEnchantAllowed = activeChar.getActiveWeaponInstance().getEnchantLevel() < MaxEnchant;

    final boolean isNotRoDWeapon = activeChar.getActiveWeaponInstance().getItem().getItemType() != L2WeaponType.ROD;

    final boolean isInInvetory = Weapon.getLocation() == L2ItemInstance.ItemLocation.INVENTORY;    

    final boolean isParedol = Weapon.getLocation() == L2ItemInstance.ItemLocation.PAPERDOLL;

    final boolean itsMyWeapon = Weapon.getOwnerId() == activeChar.getObjectId();

 

These should be under the if (command bla bla check. There isn't something wrong with them, just saying for cleaner code.

 

Also, what about that ; at the end of this check:

if(command.startsWith("WepEnchant") && activeChar != null && activeChar.isOnline() == 1 && !activeChar.isOffline() || !activeChar.isFlying() || !activeChar.isAlikeDead() || !activeChar.is-beep-ted() || !activeChar.isInOlympiadMode() || !activeChar.isSitting());

:S

 

Another error:

else if (CheckGoldBars)

{

      activeChar.sendMessage("You need "+GoldBarCount+" gold bars to use this voiced command ");

      return false;

}

else

 

It needs to be if .... else. It can't start with else if.

Link to comment
Share on other sites

Hmmm..nice share..good idea..:)

 

Stop post counting son (This is the last warn)

 

Ontopic : Impressive and well thought.

Link to comment
Share on other sites

    final int GoldBarID = 3470;

    final int GoldBarCount = 4;

 

    final L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

    final int MaxEnchant = Config.ENCHANT_WEAPON_MAX; 

    final boolean CheckGoldBars = activeChar.getInventory().getItemByItemId(GoldBarID) == null || activeChar.getInventory().getItemByItemId(GoldBarID).getCount() < GoldBarCount;

    final boolean ActiveWeapon = activeChar.getActiveWeaponInstance() != null;

    final boolean MaxEnchantAllowed = activeChar.getActiveWeaponInstance().getEnchantLevel() < MaxEnchant;

    final boolean isNotRoDWeapon = activeChar.getActiveWeaponInstance().getItem().getItemType() != L2WeaponType.ROD;

    final boolean isInInvetory = Weapon.getLocation() == L2ItemInstance.ItemLocation.INVENTORY;    

    final boolean isParedol = Weapon.getLocation() == L2ItemInstance.ItemLocation.PAPERDOLL;

    final boolean itsMyWeapon = Weapon.getOwnerId() == activeChar.getObjectId();

 

These should be under the if (command bla bla check. There isn't something wrong with them, just saying for cleaner code.

 

Also, what about that ; at the end of this check:

if(command.startsWith("WepEnchant") && activeChar != null && activeChar.isOnline() == 1 && !activeChar.isOffline() || !activeChar.isFlying() || !activeChar.isAlikeDead() || !activeChar.is-beep-ted() || !activeChar.isInOlympiadMode() || !activeChar.isSitting());

:S

 

Another error:

else if (CheckGoldBars)

{

      activeChar.sendMessage("You need "+GoldBarCount+" gold bars to use this voiced command ");

      return false;

}

else

 

It needs to be if .... else. It can't start with else if.

check the code again is not error
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.

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.

 Share



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock