Jump to content

Question

Posted

Παιδια θελω να μου πειτε αν βλεπετε καποιο λαθος σε αυτο εδω το code σχετικα με την database. Επισης με java δεν μπορω να το φτιαξω το npc γιατι τωρα αρχισα και δεν εχω ακομα τις καταληλες γνωσεις.

import sys
from com.l2jfrozen.gameserver.model.actor.instance import L2PcInstance
from java.util import Iterator
from com.l2jfrozen.gameserver.datatables import SkillTable
from com.l2jfrozen.util.database import L2DatabaseFactory
from com.l2jfrozen.gameserver.model.quest import State
from com.l2jfrozen.gameserver.model.quest import QuestState
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest

qn = "555555_DonateM"

NPC=[555555]
Cash=10000
QuestId     = 555555
QuestName   = "DonateM"
QuestDesc   = "custom"
InitialHtml = "1.htm"

print "O donateManager energopii8ike"

class Quest (JQuest) :

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


    def onEvent(seld,event,st):

        #Majesty
        if event == "1":
            skill = SkillTable.getInstance().getInfo(82,1)
            st.getPlayer().addSkill(skill)
            st.takeItems(Cash,5)
            conection = L2DatabaseFactory.getInstance().getConnection()
            charid = conection.prepareStatement("SELECT obj_Id FROM characters WHERE char_name=?")
            charid.setString(1, st.getPlayer().getName())
            charobjid = charid.executeQuery()
            charobjidd = charobjid.getInt("obj_Id")
            ins = conection.prepareStatement("INSERT INTO character_skills (char_obj_id,skill_id,skill_level,skill_name,class_index) VALUES (?,?,?,?,?)")
            ins.setInt(1, charobjidd)
            ins.setInt(2, 82)
            ins.setInt(3, 1)
            ins.setString(4, "Majesty")
            ins.setInt(5, 1)
            ins.close()
            conection.close()
            return "<html><head><body>YOU ADD THE MAJESTY</body></html>"
            st.setState(COMPLETED)


    def onTalk (self,npc,player):
        st = player.getQuestState(qn)
        st.setState(STARTED)
        return InitialHtml


QUEST = Quest(555555,qn,"custom")
CREATED     = State('Start', QUEST)
STARTING    = State('Starting', QUEST)
STARTED     = State('Started', QUEST)
COMPLETED   = State('Completed', QUEST)
QUEST.setInitialState(CREATED)

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

2 answers to this question

Recommended Posts

Guest
This topic is now closed to further replies.


×
×
  • Create New...