Voice enchant
L2jServer
EnchantWeapon.java package net.sf.l2j.gameserver.handler.voicedcommandhandlers; import net.sf.l2j.Config; import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; import net.sf.l2j.gameserver.model.Inventory; import net.sf.l2j.gameserver.model.actor.instance.L2ItemInstance; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; import net.sf.l2j.gameserver.network.serverpackets.EnchantResult; import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate; import net.sf.l2j.gameserver.network.serverpackets.ItemList; import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate; import net.sf.l2j.gameserver.network.serverpackets.SystemMessage; import net.sf.l2j.gameserver.templates.L2WeaponType; import net.sf.l2j.util.random.Rnd; /** * * Author AbsolutePower * **/ public class EnchantWeapon implements IVoicedCommandHandler { private static final String[] VOICED_COMMANDS = { "WepEnchant" }; public boolean useVoicedCommand(String command, final L2PcInstance activeChar, String target) { if(command.startsWith("WepEnchant") && activeChar != null && activeChar.isOnline() == 1 && !activeChar.isOffline() || !activeChar.isFlying() || !activeChar.isAlikeDead() || !activeChar.is-beep-ted() || !activeChar.isInOlympiadMode() || !activeChar.isSitting()); TryEnchant(activeChar); return true; } public void TryEnchant(final L2PcInstance activeChar) { final boolean CheckGoldBars = activeChar.getInventory().getItemByItemId(3470)== null || activeChar.getInventory().getItemByItemId(3470).getCount() < 4; if (CheckGoldBars) { activeChar.sendMessage("You need 4 gold bars to use this voiced command"); return; } else switch (Rnd.get(10)) { case 0: activeChar.sendMessage("Nothing happened try again"); break; case 1: activeChar.sendMessage("Nothing happened try again"); break; case 2: activeChar.sendMessage("Nothing happened try again"); break; case 3: activeChar.sendMessage("Nothing happened try again"); break; case 4: activeChar.sendMessage("Nothing happened try again"); break; case 5: final L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); final int MaxEnchant = Config.ENCHANT_WEAPON_MAX; 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(); final int GoldBarID = 3470; final int GoldBarCount = 4; if(ActiveWeapon && MaxEnchantAllowed && isNotRoDWeapon && isInInvetory && isParedol && itsMyWeapon) { activeChar.destroyItem("EnchantGb", GoldBarID, GoldBarCount, null, false); Weapon.setEnchantLevel(Weapon.getEnchantLevel() + 1); Weapon.updateDatabase(); activeChar.sendPacket(new EnchantResult(Weapon.getEnchantLevel())); activeChar.sendPacket(new ItemList(activeChar, false)); activeChar.sendPacket(new InventoryUpdate()); activeChar.sendPacket(new StatusUpdate(activeChar)); activeChar.broadcastUserInfo(); SystemMessage sm; sm = SystemMessage.sendString(GoldBarCount + "gold bars destroyed"); sm = SystemMessage.sendString("You have successfully enchant your " + Weapon.getItemName() + " to " + "+" + Weapon.getEnchantLevel()); activeChar.sendPacket(sm); } else activeChar.sendMessage("Be careful there are some rules you must follow:You must have 4 gold bars, your weapon must be smaller than " + Config.ENCHANT_WEAPON_MAX + ", you must wear your weapon, you can't enchant rod weapons"); break; case 6: activeChar.sendMessage("Nothing happened try again"); break; case 7: activeChar.sendMessage("Nothing happened try again"); break; case 8: activeChar.sendMessage("Nothing happened try again"); break; case 9: activeChar.sendMessage("Nothing happened try again"); break; default: activeChar.sendMessage("Nothing happened try again"); break; } } @Override public String[] getVoicedCommandList() { return VOICED_COMMANDS; } }VoicedCommandHandler.java registerVoicedCommandHandler(new EnchantWeapon()); import net.sf.l2j.gameserver.handler.voicedcommandhandler s.EnchantWeapon; :redlol: Палучилось захотел поделица, voice команда аля точим пуху ;) P.S. 50% взял у Америкосов. |
Re: Voice enchant
Кидайте код под
PHP код:
А нафига вам Switch в коде? if (Rnd.get(10) == 5) { L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); int MaxEnchant = Config.ENCHANT_WEAPON_MAX; boolean ActiveWeapon = activeChar.getActiveWeaponInstance() != null; boolean MaxEnchantAllowed = activeChar.getActiveWeaponInstance().getEnchantLevel() < MaxEnchant; boolean isNotRoDWeapon = activeChar.getActiveWeaponInstance().getItem().getItemType() != L2WeaponType.ROD; boolean isInInvetory = Weapon.getLocation() == L2ItemInstance.ItemLocation.INVENTORY; boolean isParedol = Weapon.getLocation() == L2ItemInstance.ItemLocation.PAPERDOLL; boolean itsMyWeapon = Weapon.getOwnerId() == activeChar.getObjectId(); int GoldBarID = 3470; int GoldBarCount = 4; if(ActiveWeapon && MaxEnchantAllowed && isNotRoDWeapon && isInInvetory && isParedol && itsMyWeapon) { activeChar.destroyItem("EnchantGb", GoldBarID, GoldBarCount, null, false); Weapon.setEnchantLevel(Weapon.getEnchantLevel() + 1); Weapon.updateDatabase(); activeChar.sendPacket(new EnchantResult(Weapon.getEnchantLevel())); activeChar.sendPacket(new ItemList(activeChar, false)); activeChar.sendPacket(new InventoryUpdate()); activeChar.sendPacket(new StatusUpdate(activeChar)); activeChar.broadcastUserInfo(); SystemMessage sm = SystemMessage.sendString(GoldBarCount + "gold bars destroyed"); sm = SystemMessage.sendString("You have successfully enchant your " + Weapon.getItemName() + " to " + "+" + Weapon.getEnchantLevel()); activeChar.sendPacket(sm); } else activeChar.sendMessage("Be careful there are some rules you must follow:You must have 4 gold bars, your weapon must be smaller than " + Config.ENCHANT_WEAPON_MAX + ", you must wear your weapon, you can't enchant rod weapons"); } else activeChar.sendMessage("Nothing happened try again"); |
Re: Voice enchant
Цитата:
|
Re: Voice enchant
Цитата:
|
Re: Voice enchant
!activeChar.is-beep-ted() - это на что проверка?:D
|
Re: Voice enchant
Цитата:
Цитата:
Добавлено через 22 минуты Mods.properties Сюда запилил такие строки #---------------------------------------# # Custom Recomends System # #---------------------------------------# #.buyrec Включен ? AlowBuyRec = True #ID итема? RecItemID = 57 #Количество итемов? RecPrice = 50000000 #Количество реков? RecReward = 1 Config.java Добавил REC_BUY = Boolean.parseBoolean(Mods.getProperty("AlowBuyRec", "True")); REC_ITEM_ID = Integer.parseInt(Mods.getProperty("RecItemID", "57")); REC_PRICE = Integer.parseInt(Mods.getProperty("RecPrice", "50000000")); REC_REWARD = Integer.parseInt(Mods.getProperty("RecReward", "1"));BuyRec.java Создал вписал package net.sf.l2j.gameserver.handler.voicedcommandhandlers; import net.sf.l2j.Config; import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance; public class BuyRec implements IVoicedCommandHandler { private static final String[] VOICED_COMMANDS = {"buyrec"}; public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target) { if (command.equalsIgnoreCase("buyrec")) { if(activeChar.getInventory().getItemByItemId(Config.REC_ITEM_ID) != null && activeChar.getInventory().getItemByItemId(Config.REC_ITEM_ID).getCount() >= Config.REC_PRICE) { activeChar.getInventory().destroyItemByItemId("Rec", Config.REC_ITEM_ID, Config.REC_PRICE, activeChar, activeChar.getTarget()); activeChar.setRecomHave(activeChar.getRecomHave() + Config.REC_REWARD); activeChar.sendMessage("You Have Earned "+Config.REC_REWARD+" Recomends."); activeChar.broadcastUserInfo(); } else { activeChar.sendMessage("You don't have enought items"); return true; } } return false; } public String[] getVoicedCommandList() { return VOICED_COMMANDS; } }VoicedCommandHandler.java Вписал registerVoicedCommandHandler(new buyrec()); import net.sf.l2j.gameserver.handler.voicedcommandhandler s.buyrec;GS молчит но команда .buyrec непашет. (Не подскажете где ошибся?) |
Re: Voice enchant
Sisi, советую прочитать для себя Java Code Conventions: http://www.oracle.com/technetwork/ja...oc-136057.html, особенно раздел 9 - Naming Conventions, потом самому же будет приятно читать свой код. Режет глаз метод с большой буквы, ровно как и метод с тире в его имени :)
|
Re: Voice enchant
Цитата:
|
Re: Voice enchant
Цитата:
|
Текущее время: 03:54. Часовой пояс GMT +3. |
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd. Перевод: zCarot