Jump to content
  • 0

Well i was trying to transfer a ...


Question

Posted

... Script that was shared in l2jfree to l2j. here's the link of the original.

http://rapidshare.com/files/157614369/8891_NumberGame.zip.html

So here's what i did. I copied the files in the customs folder.Edit the npy in the customs folder.Edit the scripts.xm(or w/e) so it can load.

 

and edited the game script __init__.py for the script and it looks like this.

#Author: JIV
#Based on 662_AGameOfCards by minlexx, cleanup by Emperorc

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
from net.sf.l2j.gameserver.cache import HtmCache

print "importing custom: 8891: NumberGame"

qn = "8891_NumberGame"

NPC=[100402]
QuestId     = 8891
QuestName   = "NumberGame"
QuestDesc   = "custom"
InitialHtml = "QuestInProgress.htm"
ItemID      = 3487 #Beleth Gold Dragon
Amount      = 10

BEWS = 6577 # B Scroll: Enchant Weapon S
BEAS = 6578 # B Scroll: Enchant Armor  S

BS_TEXT = [
    "No, number is bigger.",
    "No, number is smaller.",
    "<font color=""FFFF33"">Yes, that's my number!</font>"
]

#prize - [[iD,amount], ... ]
REWARDS = {
    1  : [[bEWS,5],[bEAS,5]],
    2  : [[bEWS,4],[bEAS,5]],
    3  : [[bEWS,4],[bEAS,4]],
    4  : [[bEWS,3],[bEAS,4]],
    5  : [[bEWS,3],[bEAS,3]],
    6  : [[bEWS,2],[bEAS,3]],
    7  : [[bEWS,2],[bEAS,2]],
    8  : [[bEWS,1],[bEAS,2]],
    9  : [[bEWS,1],[bEAS,1]],
    10 : [[bEAS,1]],
}

Button_Text="bypass -h Quest 8891_NumberGame test.htm $qbox"

class Quest (JQuest) :

def __init__(self,id,name,descr):
   JQuest.__init__(self,id,name,descr)
   self.games = {}
   self.tips = {}
   
def onEvent (self,event,st) :
     htmltext = event
     name = st.getPlayer().getName()
     won=0
     if event == "PlayBegin.htm":
         if st.getQuestItemsCount(ItemID) < Amount:    # Not enough items
             return "<html><body>You dont have enough items<br>You need "+str(Amount)+" Beleth Gold Coins</body></html>"
         st.takeItems(ItemID,Amount)                   # take items ...
         self.games[name] = [0,0]                      #[ThinkedNumber, TipsCount]
         self.tips[name] = [0,0,0,0,0,0,0,0,0,0]       #10 tips
         self.games[name][0] = st.getRandom(999) + 1
     elif event == "PlayField.htm":
         sub=0
         link1 = link2 = link3 = link4 = link5 = link6 = link7 = link8 = link9 = link10 = prizestr = button = again = ""
         if self.games[name][1] > sub :                #print all tips on every change
             if self.tips[name][sub] == self.games[name][0]:
                link1=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link1=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link1=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link2=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link2=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link2=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link3=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link3=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link3=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link4=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link4=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link4=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link5=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link5=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link5=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link6=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link6=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link6=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link7=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link7=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link7=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link8=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link8=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link8=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link9=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link9=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link9=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
             sub +=1 
         if self.games[name][1] > sub :
             if self.tips[name][sub] == self.games[name][0]:
                link10=str(self.tips[name][sub])+" - "+BS_TEXT[2]
                won=1
             elif self.tips[name][sub] > self.games[name][0]:
                link10=str(self.tips[name][sub])+" - "+BS_TEXT[1]
             else: link10=str(self.tips[name][sub])+" - "+BS_TEXT[0] 
         if self.games[name][1] != 0 : prizestr=str(10-self.games[name][1])+" tries left."
         if won==1 :
             #player won
             button=""  #disable button
             again= "<a action=\"bypass -h Quest 8891_NumberGame QuestInProgress.htm\">Play again.</a><br>"
             prizestr="Congratulation, you won at <font color=""3366FF"">"+str(self.games[name][1])+".</font> try."
             for item,amt in REWARDS[self.games[name][1]] :
                 st.giveItems(item,amt) #give prize
         elif won==0 and self.games[name][1]==10 :  
             #player loss
             button="" #disable button
             again= "<a action=\"bypass -h Quest 8891_NumberGame QuestInProgress.htm\">Play again.</a><br>"
             prizestr="You Lose! It was number <font color=""ff6666"">"+str(self.games[name][0])+"</font>." 
         else : button=Button_Text    
         htmltext = HtmCache.getInstance().getHtm("data/scripts/custom/" + qn + "/PlayField.htm")
         htmltext = htmltext.replace("LINK1",link1).replace("LINK2",link2).replace("LINK3",link3).replace("LINK4",link4).replace("LINK5",link5).replace("PRIZE",prizestr)  
         htmltext = htmltext.replace("LINK6",link6).replace("LINK7",link7).replace("LINK8",link8).replace("LINK9",link9).replace("LINK.0",link10).replace("BUTTON",button).replace("AGAIN",again)
     elif event.startswith("test.htm") :                  # test number
         if self.games[name][1]==10 or won==1 :
             return self.onEvent("PlayField.htm",st)
         if len(event) == 10: stnum=event[9]              #1-9
         elif len(event)==11: stnum =event[9]+ event[10]  #01-99
         else: stnum=event[9]+ event[10]+event[11]        #001-999
         try: 
           tnum=int(stnum)      #convert to int
         except ValueError, e:  #secured by "type=number" but just in case
           htmltext = self.onEvent("PlayField.htm",st)
           return htmltext   
         try:
           self.tips[name][self.games[name][1]]= tnum  #add tip
         except onEventUnboundLocalError, e:
           htmltext = self.onEvent("PlayField.htm",st)
           return htmltext 
         self.games[name][1] += 1    #tip added, inc TipCount
         htmltext = self.onEvent("PlayField.htm",st)    
     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(State.STARTED)
    return InitialHtml

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

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

not sure if it's correct.could someone check? and what do i do after i make this script work?

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock