Jump to content

Recommended Posts

Posted

Have a script, but he dont save skills after restart. Who can help?

 

p.s. Sorry my English, i from Ukraine=)

 

 

import sys

from com.l2jfrozen.gameserver.datatables import SkillTable

from com.l2jfrozen.gameserver.model.quest import State

from com.l2jfrozen.gameserver.model.quest import QuestState

from com.l2jfrozen.gameserver.model import L2Augmentation

from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest

from com.l2jfrozen.util.random import Rnd

from com.l2jfrozen.util.database import L2DatabaseFactory

from com.l2jfrozen.gameserver.templates import L2EtcItemType

from com.l2jfrozen.gameserver.templates import L2WeaponType

from com.l2jfrozen.gameserver.templates import L2Item

from com.l2jfrozen.gameserver.network.serverpackets import InventoryUpdate

from java.lang import System





#

#@author KFan

#ICQ: 604883692

#Skype: Kotyara20141

#



NPC_ID = 60007

ITEM_ID = 57

#ITEM_COUNT = 0

#Do not need a subject

ITEM_COUNT = 1



#A player can learn just one skill? 1 = true 0 = false

ONLY_ONE = 0





qn = "9994_skill_trader"

print "9994_skill_trader Loading Started"



class Quest (JQuest) :



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



def onTalk (self,npc,player):

st = player.getQuestState(qn)

ownerid = st.getPlayer().getObjectId()

htmltext = "I have nothing to say you"

npcId = npc.getNpcId()

if not st : return

cond = st.getInt("cond")

onlyone = st.getInt("onlyone")

if ONLY_ONE :

if onlyone > 0 :

return "fail.htm"

if cond >= 0 :

st.set("cond", "1")

st.setState(STARTED)

htmltext = "start.htm"

return htmltext







def onEvent (self,event,st) :

htmltext = event

cond = st.getInt("cond")

ownerid = st.getPlayer().getObjectId()

if event == "buy" :

htmltext = "buy.htm"

elif event.startswith('buy_') :

if st.getQuestItemsCount(ITEM_ID) <= ITEM_COUNT :

return "n-money.htm"

buy_skill = str(event.replace("buy_", ""))

buy_skill_splite = buy_skill.split('_')

st.takeItems(ITEM_ID, ITEM_COUNT)

st.getPlayer().addSkill(SkillTable.getInstance().getInfo(int(buy_skill_splite[0]), int(buy_skill_splite[1])))

skill_name = st.getPlayer().addSkill(SkillTable.getInstance().getInfo(int(buy_skill_splite[0]), int(buy_skill_splite[1])).getName())

con=L2DatabaseFactory.getInstance().getConnection()

sql=con.prepareStatement("INSERT INTO character_skills (char_obj_id, skill_id, skill_level, skill_name) VALUES (?,?,?,?)")

sql.setInt(1, ownerid)

sql.setInt(2, int(buy_skill_splite[0]))

sql.setInt(3, int(buy_skill_splite[1]))

sql.setString(4, str(skill_name))

rs=sql.executeQuery()

con.close()

if ONLY_ONE :

st.set("onlyone", "1")

st.set("cond", "0")

st.setState(COMPLETED)

htmltext = "buy.htm"

return htmltext





QUEST = Quest( -1, qn, "custom")



CREATED = State('Start', QUEST)

STARTED = State('Started', QUEST)

COMPLETED = State('Completed', QUEST)



QUEST.setInitialState(CREATED)

QUEST.addStartNpc(NPC_ID)

QUEST.addTalkId(NPC_ID)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..