L2J-FR
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.


Forum pour réunir les administrateurs de serveur L2
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  Connexion  
Le Deal du moment : -28%
Brandt LVE127J – Lave-vaisselle encastrable 12 ...
Voir le deal
279.99 €

 

 Erreur python [Résolue]

Aller en bas 
3 participants
AuteurMessage
Spanky

Spanky


Nombre de messages : 392
Age : 42
Localisation : Osaka, Japon
Date d'inscription : 01/12/2007

Erreur python [Résolue] Empty
MessageSujet: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 07:49 pm

l'erreur
Code:
Line: -1 - Column: -1

Traceback (innermost last):
  File "__init__.py", line 8, in ?
ImportError: cannot import name L2NpcTemplate


le code

Code:
import sys
from com.l2jfree.gameserver.model.quest             import State
from com.l2jfree.gameserver.model.quest             import QuestState
from com.l2jfree.gameserver.datatables             import NpcTable
from com.l2jfree.gameserver.templates             import L2NpcTemplate
from com.l2jfree.gameserver.model.actor.instance      import L2PcInstance
from com.l2jfree.gameserver.datatables           import SpawnTable
from com.l2jfree.gameserver.datatables            import ItemTable
from com.l2jfree.gameserver.network.serverpackets   import RadarControl
from com.l2jfree.gameserver.model.quest.jython       import QuestJython as JQuest

qn = "8002_MobInfo"

NPC = [32340]

class Quest (JQuest) :

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

   def onAdvEvent (self,event,npc,player) :

      def message (text) :
         return L2PcInstance.sendMessage (player, text)

   #main sub begin
      htmltext = "mobinfo.htm"
      st = player.getQuestState(qn)
      if not st: return htmltext
      #ha ha
      if st.getQuestItemsCount(57) < 10:
         message ("Vous n'avez pas d'argent pour payer mes services.")
         return
      st.takeItems(57,10)
      #take 10 adenas for every search
      text = "mobinfo.htm"
      search_by = ''
      param = ''
      page = ''
      inputs = event.split (' ')
      length = len(inputs)
      if length < 3: return htmltext
      search_by = inputs[0]
      #get input data
      if search_by == "m":
         x = int(inputs[1])
         y = int(inputs[2])
         z = int(inputs[3])
      else:
         if inputs[1].isdigit():
            page = int(inputs[1])
         else:
            message ("nom de recherche incorrecte!")
            return htmltext
         for i in range(2,length):
            param += inputs[i] + " "
         param = param.strip()

      #find by level
      if search_by == "l" :
         if param.isdigit():
            level = int(param)
            if not (level > 0 and level <100):
               return "Merci dentrer un lvl compris entre 1 et 99."
            npcData = []
            for t in NpcTable.getInstance().getAllTemplates().values():
               if  t.getLevel() == level:
                  npcData.append(t)
            if npcData:
               length = len(npcData)
               maxPerPage = 15
               maxPages = int(length / maxPerPage)
               if length > maxPerPage * maxPages: maxPages = maxPages + 1
               if page > maxPages: page = maxPages
               start = maxPerPage * page
               end = length
               if (end - start) > maxPerPage: end = start + maxPerPage
               text = "<html><title>Mobs info, created by lunawang, Lonelyheavens.com</title><body>"
               text += "<table width=260><tr>"
               if page == 0:
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo l "+ str(page-1) + " " + str(level) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               text += "<td width=180><center><a action=\"bypass -h Quest 8002_MobInfo\">Search Result by Level</a><br>Lvl:" + str(level) + " Found:" + str(length) + " Page:" + str(page+1)+ "/" + str(maxPages) +"</center></td>"
               if (page + 1) < maxPages:
                  text += "<td width=40><button value=\"Next\" action=\"bypass -h Quest 8002_MobInfo l "+ str(page+1) + " " + str(level) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40></td>"
               text += "</tr></table>"
               text += "<table width=\"100%\">"
               text += "<tr><td><font color=\"LEVEL\">Name</font></td><td width=70><font color=\"LEVEL\">Drop&Spoil</font></td></tr>"
               for i in range(start,end):
                  intagro = npcData[i].getAggroRange()
                  if intagro > 0: agro = "<font color=\"LEVEL\">*</font>"
                  else: agro = " "
                  name = npcData[i].getName()
                  if name == '' or name == ' ' or name == '  ':
                     name = "noname"
                  text += "<tr><td><a action=\"bypass -h Quest 8002_MobInfo s 0 " + str(npcData[i].getNpcId()) + "\">" + name + "</a>" + agro + "</td>"
                  text += "<td><center><button value=\"Show\" action=\"bypass -h Quest 8002_MobInfo d 0 " + str(npcData[i].getNpcId()) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr>"
               text += "</table>"
               text += "</body></html>"
               return text
            else:
               message ("pas de npc avec se level " + str(level) + ".")
         else:
            message ("merci dentrer un nombre compris entre 1 to 99")
      #find by name
      if search_by == "n" :
         count = len(param)
         if count > 3:
            name = param.replace('_',' ')
            npcData = []
            for t in NpcTable.getInstance().getAllTemplates().values():
               if name.lower() in t.getName().lower():
                  npcData.append(t)
            if npcData:
               length = len(npcData)
               maxPerPage = 15
               maxPages = int(length / maxPerPage)
               if length > maxPerPage * maxPages: maxPages = maxPages + 1
               if page > maxPages: page = maxPages
               start = maxPerPage * page
               end = length
               if (end - start) > maxPerPage: end = start + maxPerPage
               text = "<html><title>Mobs info, created by lunawang, Lonelyheavens.com</title><body>"
               text += "<table width=260><tr>"
               if page == 0:
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo n "+ str(page-1) + " " + str(name) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               text += "<td width=180><center><a action=\"bypass -h Quest 8002_MobInfo\">Search Result by Level</a><br>Name:" + str(name) + " Found:" + str(length) + " Page:" + str(page+1)+ "/" + str(maxPages) +"</center></td>"
               if (page + 1) < maxPages:
                  text += "<td width=40><button value=\"Next\" action=\"bypass -h Quest 8002_MobInfo n "+ str(page+1) + " " + str(name) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40></td>"
               text += "</tr></table>"
               text += "<table width=\"100%\">"
               text += "<tr><td><font color=\"LEVEL\">Name</font></td><td><font color=\"LEVEL\">Level</font></td><td width=60><font color=\"LEVEL\">Drop&Spoil</font></td></tr>"
               for i in range(start,end):
                  intagro = npcData[i].getAggroRange()
                  if intagro > 0: agro = "<font color=\"LEVEL\">*</font>"
                  else: agro = " "
                  text += "<tr><td><a action=\"bypass -h Quest 8002_MobInfo s 0 " + str(npcData[i].getNpcId()) + "\">" + npcData[i].getName() + "</a></td>" + "<td>" + str(npcData[i].getLevel()) + agro + "</td>"
                  text += "<td><center><button value=\"Show\" action=\"bypass -h Quest 8002_MobInfo d 0 " + str(npcData[i].getNpcId()) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr>"
               text += "</table>"
               text += "</body></html>"
               return text
            else:
               message ("Not found NPC name " + str(name) + ".")
         else:
            message ("Please enter 4 or more chars!")

      #show spawns for ID
      if search_by == "s" :
         id = int(param)
         text = ''
         SpawnData = []
         npcData = NpcTable.getInstance().getTemplate(id)
         for t in SpawnTable.getInstance().getSpawnTable().values():
            if  t.getNpcId() == id:
               SpawnData.append(t)
         if SpawnData:
            length = len(SpawnData)
            maxPerPage = 15
            maxPages = int(length / maxPerPage)
            if length > maxPerPage * maxPages: maxPages = maxPages + 1
            if page > maxPages: page = maxPages
            start = maxPerPage * page
            end = length
            if (end - start) > maxPerPage: end = start + maxPerPage
            intagro = npcData.getAggroRange()
            if intagro > 0: agro = "<font color=\"LEVEL\">*</font>"
            else: agro = " "
            text = "<html><title>Mobs info,created by Lunawang, lonelyheavens.com</title><body>"
            text += "<table width=260><tr>"
            if page == 0:
               text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo l 0 " + str(npcData.getLevel()) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
            else :
               text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo s "+ str(page-1) + " " + str(id) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
            text += "<td width=180><center><a action=\"bypass -h Quest 8002_MobInfo\">Spawns Search Result</a></center></td>"
            if (page + 1) < maxPages:
               text += "<td width=40><button value=\"Next\" action=\"bypass -h Quest 8002_MobInfo s "+ str(page+1) + " " + str(id) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
            else :
               text += "<td width=40></td>"
            text += "</tr></table>"
            text += "<center><font color=\"LEVEL\">Level " + str(npcData.getLevel()) + " - " + str(npcData.getName()) + agro + "</font><br>"
            text += "Found:" + str(length) + " Page:" + str(page+1)+ "/" + str(maxPages) +"</center>"
            text += "<table width=\"100%\">"
            text += "<tr><td><center><font color=\"LEVEL\">X        Y        Z</font></center></td></tr>"
            for i in range(start,end):
               xyz = str(SpawnData[i].getLocx()) + " " + str(SpawnData[i].getLocy()) + " " + str(SpawnData[i].getLocz())
               text += "<tr><td><center><a action=\"bypass -h Quest 8002_MobInfo m " + xyz + "\">" + xyz + "</center></td></tr>"
            text += "</table>"
            text += "</body></html>"
            return text
         else:
            message ("Not found spawn for level " + str(npcData.getLevel()) + " - " + npcData.getName() + ".")

      #show Radar
      if search_by == "m" :
         st.addRadar(x,y,z)
         return
   
      # drop and spoil show
      if search_by == "d":
         id = int(param)
         DropData = []
         SweepData = []
         npcData = NpcTable.getInstance().getTemplate(id)
         intagro = npcData.getAggroRange()
         if intagro > 0: agro = "<font color=\"LEVEL\">*</font>"
         else: agro = " "
         if npcData.getDropData():
            for cat in npcData.getDropData():
               for drop in cat.getAllDrops():
                  DropData.append(drop)
                  SweepData.append(cat)
            if DropData:
               length = len(DropData)
               maxPerPage = 15
               maxPages = int(length / maxPerPage)
               if length > maxPerPage * maxPages: maxPages = maxPages + 1
               if page > maxPages: page = maxPages
               start = maxPerPage * page
               end = length
               if (end - start) > maxPerPage: end = start + maxPerPage
               text = "<html><title>Mobs info,created by Lunawang, lonelyheavens.com</title><body>"
               text += "<table width=260><tr>"
               if page == 0:
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo l 0 " + str(npcData.getLevel()) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40><button value=\"Back\" action=\"bypass -h Quest 8002_MobInfo d "+ str(page-1) + " " + str(id) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               text += "<td width=180><center><a action=\"bypass -h Quest 8002_MobInfo\">Drop and Spoil Result</a></center></td>"
               if (page + 1) < maxPages:
                  text += "<td width=40><button value=\"Next\" action=\"bypass -h Quest 8002_MobInfo d "+ str(page+1) + " " + str(id) + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
               else :
                  text += "<td width=40></td>"
               text += "</tr></table>"
               text += "<center><font color=\"LEVEL\">Level " + str(npcData.getLevel()) + " - " + str(npcData.getName()) + agro + "</font><br>"
               text += "Found:" + str(length) + " Page:" + str(page+1)+ "/" + str(maxPages) +"</center>"
               text += "<table width=260>"
               i = 0
               for i in range(start,end):
                  itemname = ItemTable.getInstance().getTemplate(DropData[i].getItemId()).getName()
                  type = ""
                  if DropData[i].isQuestDrop():
                     type = "Qu"
                  if SweepData[i].isSweep():
                     type = "<font color=\"LEVEL\">Sw</font>"
                  else:
                     type = ""
                  text += "<tr>"
                  text += "<td width=\"100%\">" + itemname + "</td>"
                  text += "<td width=35>" + type + "</td>"
                  text += "<td width=90>" + str(float(DropData[i].getChance())/10000) + "</td>"
                  text += "</tr>"
               text += "</table>"
               text += "</body></html>"
         else:
            message ("Not found drop and spoil data for Level " + str(npcData.getLevel()) + " - " + str(npcData.getName()))
         return text
   # TODO still in development            
      if search_by == "i":
         id = 2027
         DropData = []
         SweepData = []
         npcData = NpcTable.getInstance().getTemplate(id)
         
         return text
   # end of def onAdvEvent (self,event,npc,player)
#      st.exitQuest(1)
      return htmltext

   def onTalk (Self,npc,player):
      npcId = npc.getNpcId()
      if npcId in NPC :
         htmltext = "mobinfo.htm"
      return htmltext

QUEST = Quest(8002,qn,"custom")

for i in NPC:
   QUEST.addStartNpc(i)
   QUEST.addTalkId(i)


Dernière édition par Spanky le 28/04/09, 10:10 pm, édité 1 fois
Revenir en haut Aller en bas
http://www.lonelyheavens.com
Respawner

Respawner


Nombre de messages : 1620
Age : 35
Date d'inscription : 20/04/2006

Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 09:21 pm

Code:
  File "__init__.py", line 8, in ?
ImportError: cannot import name L2NpcTemplate
Ça dit tout ... "Erreur à la ligne 8, je ne peux pas importer L2NpcTemplate".
Revenir en haut Aller en bas
http://www.respawner.fr/
Skatershi

Skatershi


Nombre de messages : 1305
Age : 35
Date d'inscription : 09/11/2006

Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 09:26 pm

Exact, l'import est faux (et n'existe pas dans ce dossier d'ailleurs)

Ta ligne :
Code:

from com.l2jfree.gameserver.templates            import L2NpcTemplate

Devient ...
Code:

from com.l2jfree.gameserver.templates.chars            import L2NpcTemplate
Revenir en haut Aller en bas
Spanky

Spanky


Nombre de messages : 392
Age : 42
Localisation : Osaka, Japon
Date d'inscription : 01/12/2007

Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 09:40 pm

Merci beaucoup pour vos réponses
Revenir en haut Aller en bas
http://www.lonelyheavens.com
Skatershi

Skatershi


Nombre de messages : 1305
Age : 35
Date d'inscription : 09/11/2006

Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 09:51 pm

Le petit résolu à rajouter si tout est ok ? Rolling Eyes
Revenir en haut Aller en bas
Spanky

Spanky


Nombre de messages : 392
Age : 42
Localisation : Osaka, Japon
Date d'inscription : 01/12/2007

Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty28/04/09, 10:15 pm

Edit du titre +htm demander par loup
Code:
<html><title>Mobs info, created by lunawang for lonelyheavens.com</title><body>
<center>
Search for NPC:
<table width=270>
<tr>
    <td width=135><center>Level/Name/Part:</center></td>
    <td width=135><center><edit var="var" width=110 height=15></center></td>
</tr>
</table>
<br>
<table width=270>
<tr>
    <td width=135><center><button value="By Level" action="bypass -h Quest 8002_MobInfo l 0 $var" width=75 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></center></td>
    <td width=135><center><button value="By Name"  action="bypass -h Quest 8002_MobInfo n 0 $var" width=75 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></center></td>
</tr>
</table>
<br><br>
For find by Level, enter number in<font color="LEVEL"> 1 to 99</font>!<br>
Atention: Every search you will be cost<font color="LEVEL"> 10 </font>adena.
</center>
</body></html>
Revenir en haut Aller en bas
http://www.lonelyheavens.com
Contenu sponsorisé





Erreur python [Résolue] Empty
MessageSujet: Re: Erreur python [Résolue]   Erreur python [Résolue] Empty

Revenir en haut Aller en bas
 
Erreur python [Résolue]
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Erreur Script Python
» [Resolue]Petit probleme php
» [Resolue]Death match event?
» [RESOLU]Npc script python
» Aide quete python

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
L2J-FR :: Général :: Aides et Conseils-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser