[HELP] Custom NPC, with jscript quest L2J 

Newbie Spellweaver
Joined
Apr 12, 2007
Messages
15
Reaction score
0
Hello,
I have been working on a Custom NPC trader in Jscript for some days now, i cant see where the problem is..
Ingame the npc just tell me this:
Sonixdk - [HELP] Custom NPC, with jscript quest - RaGEZONE Forums

It should be a trader who gives SP for Glittering medals, since SP is mush worth in my server :happy:..

Here is the __init__.py file (ITS NEW I Editted it)
Code:
###*********************************
### SpellPoint Trader
###    By Sonix
###*********************************

qn = "5050_SPtrader"
QuestId     = 5050
QuestName   = "SPtrader"
QuestDesc   = "custom"
InitialHtml = "1.htm"

#NPC that being involved
NPC=[37056]

#Item that will be traded
GMedal = 6393

import sys
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

class Quest (JQuest) :

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


 def onEvent (self,event,st) :
    htmltext = event

#Buy 10000 SP for 1 Glittering Medal
    if event == "1":
         if st.getQuestItemsCount(GMedal) >= 1:
            st.takeItems(GMedal,1)
            st.addExpAndSp(0,10000)
            htmltext = "You have succesfully purchased 10000 extra SP."
         else:
             htmltext = "You do not have enough items." 

#Buy 50000 SP for 5 Glittering Medal
    if event == "2":
         if st.getQuestItemsCount(GMedal) >= 5:
            st.takeItems(GMedal,5)
            st.addExpAndSp(0,50000)
            htmltext = "You have succesfully purchased 50000 extra SP."
         else:
             htmltext = "You do not have enough items." 

#Buy 100000 SP for 10 Glittering Medal
    if event == "3":
         if st.getQuestItemsCount(GMedal) >= 10:
            st.takeItems(GMedal,10)
            st.addExpAndSp(0,100000)
            htmltext = "You have succesfully purchased 100000 extra SP."
         else:
             htmltext = "You do not have enough items." 

    if event == "0":
      htmltext = "Training has been canceled."
    
    if htmltext != event:
      st.setState(COMPLETED)
      st.exitQuest(1)

    return htmltext

 def onTalk (Self,npc,player):

   npcId = npc.getNpcId()
   st = player.getQuestState(qn)
   htmltext = "<html><body>I have nothing to say to you.</body></html>"
   st.set("cond","0")
   st.setState(STARTED)
   return InitialHtml

### Quest class and state definition
QUEST       = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)
CREATED     = State('Start',     QUEST)
STARTED     = State('Started',   QUEST)
COMPLETED   = State('Completed', QUEST)

QUEST.setInitialState(CREATED)

QUEST.addStartNpc(37056)
# SP Trader Reilu
QUEST.addTalkId(37056)

And here is the HTM file in data/html/default/...
Code:
<html><title>SP Trader - Reilu</title>
<body>
Reilu:<br>
Hi Stranger
<br>
<a action="bypass -h npc_%objectId%_Quest 1007_spt">Who are you?</a>
</body>
</html>

And here should the NPC Start when u press Who are you?
Code:
<html><body>SP Trader Reilu:<br><br>
I am Reilu and i am expert in train SP... <br>
But i dont train you for free, If you get me <font color="FFBB00">Glittering Medals</font> i will train you.<br><br>
<center>
<a action="bypass -h Quest 1007_SPt 3.htm"> 10000 SP </a><br>
<a action="bypass -h Quest 1007_SPt 4.htm"> 50000 SP </a><br>
<a action="bypass -h Quest 1007_SPt 5.htm"> 100000 SP </a><br>
<a action="bypass -h Quest 1007_SPt 2.htm"> How to get those Medals? </a></center><br>
</body></html>

Please help me, or tell me if there is a syntex error or something heh, this is my first jscript.

Thanks
 
Last edited:
If your using L2jfree, i know the code changed from CT1.5 to CT2. So in the import you need to change it from
Code:
print "importing custom: 1007_spt"
import sys
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
To
Code:
from com.l2jfree.gameserver.model.quest        import State
from com.l2jfree.gameserver.model.quest        import QuestState
from com.l2jfree.gameserver.model.quest.jython import QuestJython as JQuest
the net.sf.l2j.gameserver.model changed to com.l2jfree.gameserver.model Thats probly your problem, if all your other code is correct. All older NPC's were changed over like that in the new datapacks for l2jfree. Thats probly why it isnt even importing your Script.
 
Upvote 0
It still not loading my script, btw i am using 1.5

Here is an example on a script in a quest
Code:
# Made by Mr. Have fun! Version 0.2
import sys
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 = "1_LettersOfLove1"
#NPCs 
DARIN  = 30048 
ROXXY  = 30006 
BAULRO = 30033 
#ITEMS 
DARINGS_LETTER     = 687 
RAPUNZELS_KERCHIEF = 688 
DARINGS_RECEIPT    = 1079 
BAULS_POTION       = 1080 
 
#REWARD 
NECKLACE = 906
 
class Quest (JQuest) :
 def __init__(self,id,name,descr):
     JQuest.__init__(self,id,name,descr)
     self.questItemIds = [DARINGS_LETTER, RAPUNZELS_KERCHIEF, DARINGS_RECEIPT, BAULS_POTION]

In "data/jscript" i have a __init__.py file without anything
In "data/jscript/custom" i also have __init__.py file with:
Code:
__all__ = [
'1007_SPt',
]
print ""
print "importing custom data ..."
from data.jscript.custom import *
print "... done"
print ""
Is it wrong or something?
 
Upvote 0
Ok, i just assumed u had CT2 datapack, cause of gracia.

I dont know much about the script itself, everything looks fine to me. Possibly not added correctly into the scripts.cfg?
 
Upvote 0
scripts.cfg, loads all the quest, custom's, etc. Back in c4/c5 it used to be loaded in the __init__.py Inside the scripts folder. now everything is in the scripts.cfg inside the data/ folder.
 
Upvote 0
scripts.cfg, loads all the quest, custom's, etc. Back in c4/c5 it used to be loaded in the __init__.py Inside the scripts folder. now everything is in the scripts.cfg inside the data/ folder.

When i do that, in Game server console:
Code:
=======================================================-[ Events/ScriptEngine ]
INFO Loading Server Scripts
WARNING Failed executing script: E:\L2 Server\CT1.5_L2JFree_3774\L2Gracia\dist\d
ata\scripts\custom\5050_SPtrader\__init__.py. See __init__.py.error.log for deta
ils.

and in the error.log file:
Code:
Error on: E:\L2 Server\CT1.5_L2JFree_3774\L2Gracia\dist\data\scripts\custom\5050_SPtrader\__init__.py.error.log
Line: -1 - Column: -1
Traceback (innermost last):
  File "__init__.py", line 78, in ?
TypeError: net.sf.l2j.gameserver.model.quest.State(): expected 0 args; got 2

Line 78:
Code:
CREATED     = State('Start',     QUEST)
 
Upvote 0
I might figured it out, i will test it tomorrow, i think its because i have 2x of them, because i have one in data/scripts and one in data/jscripts, thats might making confuse in the importing..
 
Upvote 0
so your script is not loading?
did you tryed to add this line on you gameserver\data\scripts.cfg
Code:
custom/5050_SPtrader/__init__.py
?

or try to change the quest id. may it is already in use.
I try change the ID, maybe this means it got 2 of the ids:
Code:
Traceback (innermost last):
  File "__init__.py", line 78, in ?
TypeError: net.sf.l2j.gameserver.model.quest.State(): expected 0 args; got 2

I will post if it Works or Not
 
Upvote 0
Well not working.. some Scripters who can tell me what this exacly means:
Code:
Error on: ....\data\scripts\custom\9998_SPtrader\__init__.py.error.log
Line: -1 - Column: -1
Traceback (innermost last):
  File "__init__.py", line 78, in ?
TypeError: net.sf.l2j.gameserver.model.quest.State(): expected 0 args; got 2

Code:
###*********************************
### SpellPoint Trader
###    By Sonix
###*********************************
 
qn = "9998_SPtrader"
QuestId     = 9998
QuestName   = "SPtrader"
QuestDesc   = "custom"
InitialHtml = "1.htm"
 
#NPC that being involved
NPC=[37056]
 
#Item that will be traded
GMedal = 6393
 
import sys
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
 
class Quest (JQuest) :
 
 def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
 
 
 def onEvent (self,event,st) :
    htmltext = event
 
#Buy 10000 SP for 1 Glittering Medal
    if event == "1":
         if st.getQuestItemsCount(GMedal) >= 1:
            st.takeItems(GMedal,1)
            st.addExpAndSp(0,10000)
            htmltext = "You have succesfully purchased 10000 extra SP."
         else:
             htmltext = "You do not have enough items." 
 
#Buy 50000 SP for 5 Glittering Medal
    if event == "2":
         if st.getQuestItemsCount(GMedal) >= 5:
            st.takeItems(GMedal,5)
            st.addExpAndSp(0,50000)
            htmltext = "You have succesfully purchased 50000 extra SP."
         else:
             htmltext = "You do not have enough items." 
 
#Buy 100000 SP for 10 Glittering Medal
    if event == "3":
         if st.getQuestItemsCount(GMedal) >= 10:
            st.takeItems(GMedal,10)
            st.addExpAndSp(0,100000)
            htmltext = "You have succesfully purchased 100000 extra SP."
         else:
             htmltext = "You do not have enough items." 
 
    if event == "0":
      htmltext = "Training has been canceled."
 
    if htmltext != event:
      st.setState(COMPLETED)
      st.exitQuest(1)
 
    return htmltext
 
 def onTalk (Self,npc,player):
 
   npcId = npc.getNpcId()
   st = player.getQuestState(qn)
   htmltext = "<html><body>I have nothing to say to you.</body></html>"
   st.set("cond","0")
   st.setState(STARTED)
   return InitialHtml
 
### Quest class and state definition
QUEST       = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)
CREATED     = State('Start',     QUEST) [COLOR=red]<--LINE 78[/COLOR]
STARTED     = State('Started',   QUEST)
COMPLETED   = State('Completed', QUEST)
 
QUEST.setInitialState(CREATED)
 
QUEST.addStartNpc(37056)
# SP Trader Reilu
QUEST.addTalkId(37056)
 
Upvote 0
the problem is in the line 78.
open the file with notepad, press ctrl+g, type 78 and go
see if you found the error on that line or around.

ps: it will not be exactly on line 78 cuz of the comments (all lines that starts with # are comments only)
sorry for my english
 
Upvote 0
Back