Secret Experience

Secret Experience (https://secretexperience.net/index.php)
-   [L2J] Dúvidas Solucionadas (https://secretexperience.net/forumdisplay.php?f=653)
-   -   Erro de Script (https://secretexperience.net/showthread.php?t=14078)

CavaleiroNegro 04-10-2009 06:45 AM

Erro de Script
 
Bom pessoal vamos la.

Estou mexeno numa rev EMU Gracia CT2 aqui e fazendo um NPC Enchante.

Consegui fazer os scripts tudo certinho porém acontece isso ao clicar para enchantar a arma :


[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]

[Somente Usuários Registrados Podem Visualizar os Links Desta PáginaClique aqui para se Registrar]

Código:

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

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)

Quem puder me ajudar para saber qual seria o erro ficarei grato...(Analizei aqui porém não sei qual o poblema real,senão me engano é por causa do caminho java da rev)

Inspector 04-10-2009 07:30 AM

:wideeyed: veio c tu vive ajudando a gente agora pediu ajuda a coisa ta preta em so pra dar 1 opiniao eu vi perdido por ai 1 npc c nao me engano funfando desse

ai q vc quer fazer , e se vc pegasse ele e desse uma analisada nele nao ajudaria ? so uma opiniao calma ai so o leigo aqui ^^ :wideeyed:

CavaleiroNegro 04-10-2009 08:32 AM

@Inspector :


Caso quiser postar a script dele funcionando sera bom tb...


Em outras rev eu sei fazer o NPC funcionar normalmente hehehhee. c(:

O poblema mesmo é no caso do EMU pelo estilo de script dele ser diferente dos servidores que trabalho.

Mesmo assim obrigado pela opinião...


De noite estarei on denovo conferindo as respostas,Desde ja Obrigado...

paytaly 04-10-2009 08:50 AM

Veja se assim funciona:
Código:

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)


Inspector 04-10-2009 08:31 PM

@cavaleironegro

velho ta add como amigo la ja so vi agora o pedido ^~

e sobre o npc velho eu vi ele numa rev q baixei de rgacia final ou gracia pt 2 nem lembro vo cacar essa rev aqui ( 2 hd de 1 tera =p)

e assim q eu achar pego o npc e upo ele e te mando o link pra tu dar um xeretada

so torce ai rpa eu nao ter deletado a rev mas mesmo assim eu te aviso ^^

c ajudar dai vai ser legal c nao tomara q vc arrume ele ai :cute:

----------

po c servir npc e encantar no ragnarok tenhu uns 20 tipos aqui uahauhauhauahuahuahauha

CavaleiroNegro 05-10-2009 02:43 AM

@Paytaly :

Passei por despercebido disso heheh obrigado...


Uma coisa que fiquei em duvida para selecionar a quantidade de enchantes em cada botão é na html mesmo ou no script ?


@Inspector :

Obrigado por tentar me ajudar...

Inspector 05-10-2009 05:53 AM

@cavaleironegro

ai ta o codigo do npc q citei a vc

Código:

import sys
from net.sf.l2j import Config
from net.sf.l2j.gameserver.model.quest import State
from net.sf.l2j.gameserver.model.quest import QuestState
from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

qn = "99940_SafeEnchant"

print "..............! - Importing Custom: +10 Auto-Enchant - !.............."

QuestId    = 99940
QuestName  = "SafeEnchant"
QuestDesc  = "custom"

ENCHANT_CHECK    = 1

AMOUNT_OF_ENCHANT    = 10

PAYMENT_ITEM_ID    = 57
PAYMENT_AMOUNT    = 1000000000

ENCHANT_NPC = 21
weapons = ['Sword','Blunt','Dagger','Bow','Pole','Etc','Fist','Dual Sword','Dual Fist','Big Sword','Big Blunt','Ancient','Crossbow','Rapier','Dual Dagger']
armors = ['Light','Heavy','Magic','Shield','Sigil']
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 99940_SafeEnchant enchantItem_" + str(Item.getObjectId()) +"\">" + Item.getItem().getName() + "+" + str(Item.getEnchantLevel()) + "</a><br>"
      if htmltext == "":
        htmltext = "You have no enchantable items equiped or in your inventory."
      htmltext = "<html><title>Auto-Enchanter By RevoltadOl</title><body>Seu Item para ser Enchantado Precisa estar +10.<br>Por Favor Selecione Um Item a ser Enchantado na Lista Abaixo:<br><br>" + htmltext + "</body></html>"
    elif 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
      Item = st.getPlayer().getInventory().getItemByObjectId(objId )
      if Item :
        itemType = Item.getItem().getItemType().toString()
        itemEnchant = Item.getEnchantLevel()
        if st.getQuestItemsCount(PAYMENT_ITEM_ID) >= PAYMENT_AMOUNT :
          if (itemType in weapons and itemEnchant >= ENCHANT_CHECK) or (itemType in armors and itemEnchant >= ENCHANT_CHECK) or (itemType in jewels and itemEnchant >= ENCHANT_CHECK) :
              htmltext = "notPlusZero.htm"
          else :
            Item.setEnchantLevel(itemEnchant+AMOUNT_OF_ENCHANT)
            st.takeItems(PAYMENT_ITEM_ID, PAYMENT_AMOUNT)
            htmltext = "Congratulations.htm"
        else :
          htmltext = "notEnoughItems.htm"
      else :
        htmltext = "Error.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 = "Start.htm"
    return htmltext

QUEST      = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)

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

nao sei c ta certo nao sei mecher nesse trem nao mas ta ai c algo te ajudar :laugh:

CavaleiroNegro 05-10-2009 06:49 AM

@Inspector:

Consegui fazer funcionar aqui com a minha script anterior mesmo hehehhe

Fiz algumas alterações nela e deu tudo certo...

Mesmo assim muito obrigado,agora chego a parte de eu fazer event nessa script... c(:


@Paytaly :

Mais uma vez obrigado....


Horários baseados na GMT -3. Agora são 01:59 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.