buffer error L2J 

Newbie Spellweaver
Joined
Mar 1, 2006
Messages
86
Reaction score
0
i'm now trying to make my own npc buffer, don't want to use the released ones
got some weird error, in gameserver console it says
"Failed Executing Script <loc...> see init.py.error.log for details
in the log there's this
Code:
Error on: C:\l2jserver\dist\data\scripts\custom\15000_Buffer\__init__.py.error.log
Line: -1 - Column: -1

Traceback (innermost last):
  (no code object) at line 0
ValueError: Strings added to sha hashes must not contain characters with value > 255

makes no sense to me

my buffer file:
Code:
import sys
from java.lang import System
from java.util import Iterator
from com.l2jfree.gameserver.model.actor.instance import L2PcInstance
from com.l2jfree import L2DatabaseFactory
from com.l2jfree.gameserver.datatables import SkillTable
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

NPCID=15000
QID=15000
ADENAID=57
COST_NORMAL=0
COST_CHANT=0
COST_DANCE=0
COST_SONG=0
COST_KAMAEL=0
QNM="Buffer"
QN="15000_Buffer"
QDSCR="custom"
InitialHtml="15000.htm"
PLAYERNAME=st.getPlayer().getName()

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

def onEvent(self,event,st):
htmltext = event
count=st.getQuestItemsCount(ADENAID)
if count < 1  or st.getPlayer().getLevel() < 1 :
htmltext = "<html><head><body>Sorry, PLAYERNAME, but you don't have enough money.</body></html>"

else:
st.getPlayer().setTarget(st.getPlayer())

#Wind Walk
if event == "1":
st.takeItems(ADENA_ID, COST_NORMAL)
.setTarget(st.getPlayer()).useMagic(SkillTable.getInstance().getInfo(9951,1),False,False)
#st.getPlayer().restoreHPMP()
#return "15000-1.htm"
st.setState(COMPLETED)

if htmltext != event:
st.setState(COMPLETED)
st.exitQuest(1)
return htmltext

def onTalk (self,npc,player):
st = player.getQuestState(qn)
htmltext = "<html><head><body>I have nothing to say to you</body></html>"
st.setState(STARTED)
return InitialHtml

QUEST       = Quest(QID,str(QID) + "_" + QNM,QDSCR)
CREATED=State('Start',QUEST)
STARTED=State('Started',QUEST)
COMPLETED=State('Completed',QUEST)

QUEST.setInitialState(CREATED)

for npcId in NPC:
 QUEST.addStartNpc(NPCID)
 QUEST.addTalkId(NPCID)

I understand the code almost completely, but writing it is completely different...:?:
 
Ok, well first of all, at the beginning of your script you are defining a variable with something undefined yet (st.getPlayer().getName()), this needs to be put later in your code.
Also, you need to indent your code so it can be interpreted by the server correctly.
Try it this way:

Code:
import sys
from java.lang import System
from java.util import Iterator
from com.l2jfree.gameserver.model.actor.instance import L2PcInstance
from com.l2jfree import L2DatabaseFactory
from com.l2jfree.gameserver.datatables import SkillTable
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

NPCID=15000
QID=15000
ADENAID=57
COST_NORMAL=0
COST_CHANT=0
COST_DANCE=0
COST_SONG=0
COST_KAMAEL=0
InitialHtml="15000.htm"

#Why do you bother writing these 3 lines? just write it directly where you now 
#call these variables and save 3 lines of script
QNM="Buffer"
QN="15000_Buffer"
QDSCR="custom"



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

    def onEvent(self,event,st):
        st = player.getQuestState("15000_Buffer")
        PLAYERNAME = player.getName()
        if not st: return
        htmltext = event
        count=st.getQuestItemsCount(ADENAID)
        if count < 1  or st.getPlayer().getLevel() < 1 :
            htmltext = "<html><body>Sorry, " + PLAYERNAME + ", but you don't have enough money.</body></html>"
            return htmltext #if you dont return here, it will go on to cast the buffs anyway
        else:
            st.getPlayer().setTarget(st.getPlayer())
        #Wind Walk
        if event == "1":
            st.takeItems(ADENA_ID, COST_NORMAL)
So here, I did 4 things: change the place where you define the PLAYERNAME variable(will work now), change the way it's called in the Html(would not have worked before), defined your st variable(you had not defined it) and indented your script(at least the part I did will work, the rest needs to be done the same way)

I'll let you do the rest because(it's only my opinion) I think the way you are doing it is a bit pointless... You'll get a HUGE script to accomplish not much. In any case, it's a good exercise to learn :wink:
 
Upvote 0
well i knew bout the PLAYERNAME, i just didn't knew how to do it correctly, that was one thing i'd expected making this thread
didn't knew bout the st...
umm, not sure what "indent" means, the translator i used makes me think u mean those tabbed spaces
why are they needed?

P.S. thx so far :)
 
Upvote 0
umm, not sure what "indent" means, the translator i used makes me think u mean those tabbed spaces
why are they needed?

Yes, it's the tab spaces. It's used to define what actions are 'part' of another.
Here is an example(a theoretical one...):

Code:
if npc.getNpcId() in self.goodNpcs:
    self.attackedNpc.append(npc)
if npc.isInCombat():
    npc.setInvul(1)
in this example here is what will happen:
if the NPC's npcId is in the list self.goodNpc, then it will execute self.attackedNpc.append(npc), which will add the NPC to the self.attackedNpc list. Then, it will check if the NPC is in combat(even if it's not in the self.goodNpcs list, because the next 'if' is not indented as 'included' in the previous one), if he is in combat, it will set him as invulnerable.

Code:
if npc.getNpcId() in self.goodNpcs:
    self.attackedNpc.append(npc)
    if npc.isInCombat():
        npc.setInvul(1)
in this example here is what will happen:
if the NPC's npcId is in the list self.goodNpc, then it will execute self.attackedNpc.append(npc), which will add the NPC to the self.attackedNpc list. Then, it will check if the NPC is in combat(on if that NPC is in the self.goodNpcs list, since this 'if' is a part of the previous one and will only be checked if the first one was positive), if he is in combat, it will set him as invulnerable.

Code:
if npc.getNpcId() in self.goodNpcs:
self.attackedNpc.append(npc)
if npc.isInCombat():
npc.setInvul(1)
in this example here is what will happen:
It will check if the NPC is in the self.goodNpcs list, then the script will give out an error, because there is nothing in the script telling it what to do if the answer is 'true'... there is a next command, but it's not part of the 'if' condition, it's done as an independant one.
 
Upvote 0
lol, it's a shame we can't use {}...
would be much easier
well, thanks again, i'll keep going with that buffer
 
Upvote 0
Back