AbsolutePower Posted April 10, 2012 Posted April 10, 2012 (edited) del Edited November 11, 2018 by AbSoLuTePoWeR
Guest Elfocrash Posted April 10, 2012 Posted April 10, 2012 There is a faster and better way to do with with chance and not with switch and cases. Good idea though.
AbsolutePower Posted April 10, 2012 Author Posted April 10, 2012 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
An4rchy Posted April 10, 2012 Posted April 10, 2012 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.
AbsolutePower Posted April 10, 2012 Author Posted April 10, 2012 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
AbsolutePower Posted April 11, 2012 Author Posted April 11, 2012 only IL ? you can put it everywhere you want :)
An4rchy Posted April 11, 2012 Posted April 11, 2012 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)?
AbsolutePower Posted April 11, 2012 Author Posted April 11, 2012 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 :)
An4rchy Posted April 11, 2012 Posted April 11, 2012 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.
CryStaliN Posted April 11, 2012 Posted April 11, 2012 Hmmm..nice share..good idea..:) Stop post counting son (This is the last warn) Ontopic : Impressive and well thought.
AbsolutePower Posted April 11, 2012 Author Posted April 11, 2012 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
AbsolutePower Posted April 12, 2012 Author Posted April 12, 2012 Ontopic : Impressive and well thought. ty mate :)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now