Tópico: Erro de Script
Ver um Único Post
Antigo 04-10-2009, 08:50 AM   #4
paytaly
playstation
 
Avatar de paytaly
 
Registrado em: Dec 2008
Localização: Belo Horizonte
Posts: 1,284
Agradeceu: 118
Agradecido 1,503 Vezes em 772 Posts
Achei Ruim:
Acharam ruim Vezes em Posts
Meu Estado:
Enviar mensagem via Windows Live Messenger para paytaly
Nome Real: Marcelo

Inventório de paytaly

Padrão

Veja se assim funciona:
Código: [Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]
import sys
from net.l2emuproject.gameserver.model.quest import State
from net.l2emuproject.gameserver.model.quest import QuestState
from net.l2emuproject.gameserver.model.quest.jython import QuestJython as JQuest
from net.l2emuproject import Config

qn = "safe_enchant"

ENCHANT_NPC = 90000
weapons = ['Sword','Blunt','Dagger','Bow','Pole','Etc','Fist','Dual Sword','Dual Fist','Big Sword','Big Blunt','Ancient','Crossbow','Rapier']
armors = ['Light','Heavy','Magic','Shield']
jewels = ['None']
acceptableItemTypes = weapons+armors+jewels

class Quest (JQuest) :

  def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

  def onEvent (self,event,st) :
    if event == "choose_item" :
      htmltext = ""
      for Item in st.getPlayer().getInventory().getItems():
        # given an item instance, get the item template to check what type it is
        itemType = Item.getItem().getItemType().toString()
        itemGrade = Item.getItem().getCrystalType()
        if itemType in acceptableItemTypes and itemGrade > 0 :
          htmltext += "<a action=\"bypass -h Quest safe_enchant enchantItem_" + str(Item.getObjectId()) +"\">" + Item.getItem().getName() + "+" + str(Item.getEnchantLevel()) + "</a><br>"
      if htmltext == "":
        htmltext = "You have no enchantable items in your inventory"
      htmltext = "<html><body>Enchanter:<br>Please choose which item you wish me to enchant, from the below list:<br>" + htmltext + "</body></html>"
    if event.startswith("enchantItem_"):
      # get the object id out of the event string
      objId = int(event.replace("enchantItem_", ""))
      # to avoid exploitation, check if the stored objectId still corresponds to an existing item
      # and if that item is still not equipped
      Item = st.getPlayer().getInventory().getItemByObjectId(objId )
      if Item and not Item.isEquipped() :
        itemType = Item.getItem().getItemType().toString()
        itemEnchant = Item.getEnchantLevel()
        if st.getQuestItemsCount(57) >= 10 :
           if (itemType in weapons and itemEnchant >= Config.ENCHANT_MAX_WEAPON) or (itemType in armors and itemEnchant >= Config.ENCHANT_MAX_ARMOR) or (itemType in jewels and itemEnchant >= Config.ENCHANT_MAX_JEWELRY) :
              htmltext = "reachedMaxEnchant.htm"
           else :
             Item.setEnchantLevel(itemEnchant+1)
             st.takeItems(57, 1000000)
             htmltext = "congratulations.htm"
        else :
          htmltext = "notEnoughItems.htm"
      else :
        htmltext = "cheater.htm"
    return htmltext

  def onTalk (self,npc,player):
    htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>"
    st = player.getQuestState(qn)
    if not st : return htmltext
    if npc.getNpcId() == ENCHANT_NPC :
       htmltext = "1.htm"
    return htmltext

QUEST    = Quest(9000,qn,"Custom")

QUEST.addStartNpc(ENCHANT_NPC)
QUEST.addTalkId(ENCHANT_NPC)

__________________
Há! Só posso rir de quem quer vender o que mal sabe fazer...
Quer ser respondido direito!? Não faça perguntas idiotas. (Y)
paytaly está offline   Responder com Citação
O seguinte membro ao lado disse Obrigado(a) a : paytaly por gostar deste Post :
CavaleiroNegro (05-10-2009)