Jump to content

Recommended Posts

Guest Elfocrash
Posted

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

 

Good idea though.

Posted

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

Posted

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.

Posted

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

Posted

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)?

Posted

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 :)
Posted

    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.

Posted

    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

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