Teraz mam problem ze sklepem wyskakuje mi to samo. Oto kod pythona:
Ja nie moge dojsc co jest nie tak.
import sys
from java.util import Iterator
from net.sf.l2j.util import Rnd
from net.sf.l2j.gameserver.serverpackets import CreatureSay
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 import L2DatabaseFactory
from net.sf.l2j.gameserver.serverpackets import SystemMessage
from net.sf.l2j.gameserver.model import L2ItemInstance
from net.sf.l2j.gameserver.model import L2World
from net.sf.l2j.gameserver.serverpackets import ConfirmDlg
from net.sf.l2j.gameserver.serverpackets import UserInfo
from net.sf.l2j.gameserver.serverpackets import CharInfo
from net.sf.l2j.gameserver.serverpackets import InventoryUpdate
from net.sf.l2j.gameserver.datatables import ItemTable
from net.sf.l2j.gameserver.idfactory import IdFactory
from net.sf.l2j.gameserver.serverpackets import ShowCalculator
qn = "q8032_MarketBuy"
MARKET = 80007
#limit na stranicu
LIMIT = 14
#äë˙ îňîáđŕćĺíč˙ öĺí
FIRMONEY = "Adena" #1ŕ˙ âŕëţňŕ, íŕçâŕíčĺ
SECMONEY = "Coin of Luck" #2ŕ˙ âŕëţňŕ, íŕçâŕíčĺ
#type
weapons = "<button value=\"Îđóćčĺ\" action=\"bypass -h Quest q8032_MarketBuy show_1\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
armors = "<button value=\"Áđîí˙\" action=\"bypass -h Quest q8032_MarketBuy show_2\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
resources = "<button value=\"Đĺńű\" action=\"bypass -h Quest q8032_MarketBuy show_3\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
recipes = "<button value=\"Đĺöĺďňű\" action=\"bypass -h Quest q8032_MarketBuy show_4\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
books = "<button value=\"Ęíčăč\" action=\"bypass -h Quest q8032_MarketBuy show_5\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
soulshots = "<button value=\"Ďŕňđîíű\" action=\"bypass -h Quest q8032_MarketBuy show_6\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
aadena = "<button value=\"Ďĺ÷ŕňč\" action=\"bypass -h Quest q8032_MarketBuy show_7\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
scrolls = "<button value=\"Ńęđîëëű\" action=\"bypass -h Quest q8032_MarketBuy show_8\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
crystals = "<button value=\"Ęđč\" action=\"bypass -h Quest q8032_MarketBuy show_9\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
potions = "<button value=\"Çĺëü˙\" action=\"bypass -h Quest q8032_MarketBuy show_10\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
tatoos = "<button value=\"Ňŕňó\" action=\"bypass -h Quest q8032_MarketBuy show_11\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
arrows = "<button value=\"Ńňđĺëű\" action=\"bypass -h Quest q8032_MarketBuy show_12\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
sacry = "<button value=\"ŃŔ ęđč\" action=\"bypass -h Quest q8032_MarketBuy show_13\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
fishing = "<button value=\"Óäî÷ęč\" action=\"bypass -h Quest q8032_MarketBuy show_14\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
questsit = "<button value=\"Ęâĺńň\" action=\"bypass -h Quest q8032_MarketBuy show_15\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
poisk = ""
#
sorts = {1: "Weapon", 2: "Armor", 3: "Resource", 4: "Recipe", 5: "Spellbook", 6: "Soulshot", 7: "AncientAdena", 8: "Scroll", 9: "Crystal", 10: "Potion", 11: "Tatoo", 12: "Arrow", 13: "SoulCrystal", 14: "Rod", 15: "QuestItems"}
trans = {1: "Îđóćčĺ", 2: "Áđîí˙", 3: "Đĺńóđńű", 4: "Đĺöĺďňű", 5: "Ęíčćęč", 6: "Ďŕňđîíű", 7: "7 ďĺ÷ŕňĺé", 8: "Ńęđîëëű", 9: "Ęđčńňŕëëű", 10: "Çĺëü˙", 11: "Ňŕňó", 12: "Ńňđĺëű", 13: "ŃŔ ęđč", 14: "Óäî÷ęč", 15: "Ęâĺńňîâűĺ"}
#
class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
def onAdvEvent (self,event,npc,player):
st = player.getQuestState(qn)
if event == "list" :
st.unset("stranic")
st.unset("moreitem")
st.unset("morecount")
st.unset("moreprice")
htmltext = "<html><body>Cďčńîę ňîâŕđîâ:<br>"
htmltext += "<table width=300><tr><td>"+weapons+"</td><td>"+armors+"</td><td>"+resources+"</td><td>"+recipes+"</td><td>"+books+"</td></tr>"
htmltext += "<tr><td>"+potions+"</td><td>"+crystals+"</td><td>"+scrolls+"</td><td>"+aadena+"</td><td>"+soulshots+"</td></tr>"
htmltext += "<tr><td>"+questsit+"</td><td>"+fishing+"</td><td>"+sacry+"</td><td>"+arrows+"</td><td>"+tatoos+"</td></tr></table>"
htmltext += "<table width=300><tr><td></td><td>Ďîńëĺäíčĺ "+str(LIMIT)+":</td></tr>"
con=L2DatabaseFactory.getInstance().getConnection()
listitems=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE mag.itemId>1 AND magicon.itemId=mag.itemId LIMIT 0,?")
listitems.setInt(1, int(LIMIT))
rs=listitems.executeQuery()
while (rs.next()) :
obj=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
icon=rs.getString("itemIcon")
try :
chk = count
if money == 57:
prmoney = str("Adena")
dmoney = str(FIRMONEY)
else:
prmoney = str("COL")
dmoney = str(SECMONEY)
s = str(price)
for i in xrange(len(s)-3,s[0] in ('+','-'),-3):
s=s[:i]+','+s[i:]
pprice = "<font color=00CCFF>"+str(s)+"</font>"
count = (count > 1 and str(count)) or str("")
if chk == 1:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a msg=\"Ęóďčňü "+str(itemname)+" ó "+str(nick)+" çŕ "+str(s)+" "+dmoney+"?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
else:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy showm_"+str(itemobj)+"_"+str(item)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
except :
try : insertion.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table><br>"
cona=L2DatabaseFactory.getInstance().getConnection()
getcount=cona.prepareStatement("SELECT COUNT(itemId) FROM z_market_sell WHERE itemId>1")
rsc=getcount.executeQuery()
if (rsc.next()):
rows = rsc.getInt(1)
vsego = int((rows/LIMIT)+2)
if vsego > 3:
htmltext += "Ńňđŕíčöű: "
st.set("stranic",str(vsego))
prvsego = range(1,vsego)
for i in prvsego:
htmltext += ""
htmltext += " <a action=\"bypass -h Quest q8032_MarketBuy str_0_"+str(i)+"_99\">"+str(i)+"</a><font color=> </font>"
else:
htmltext += ""
rsc.close()
getcount.close()
cona.close()
htmltext += "</body></html>"
elif event.startswith("str_"):
search = str(event.replace("str_", ""))
iotype,zagluwka,grade=search.split("_")
iotype,zagluwka,grade=int(iotype),int(zagluwka),int(grade)
strlist = int(zagluwka - 1)
strCount = st.getInt("stranic")
sortType = sorts.get(iotype, str(""))
razdel = trans.get(iotype, str(""))
htmltext = "<html><body><a action=\"bypass -h Quest q8032_MarketBuy list\">Cďčńîę ňîâŕđîâ</a>: "+razdel+"<br>"
#>
if iotype > 0:
htmltext += ""
else:
htmltext += "<table width=300><tr><td>"+weapons+"</td><td>"+armors+"</td><td>"+resources+"</td><td>"+recipes+"</td><td>"+books+"</td></tr>"
htmltext += "<tr><td>"+potions+"</td><td>"+crystals+"</td><td>"+scrolls+"</td><td>"+aadena+"</td><td>"+soulshots+"</td></tr>"
htmltext += "<tr><td>"+questsit+"</td><td>"+fishing+"</td><td>"+sacry+"</td><td>"+arrows+"</td><td>"+tatoos+"</td></tr></table>"
ones = {1: 0, 2: LIMIT}
one = ones.get(zagluwka, int(LIMIT*strlist))
two = LIMIT
con=L2DatabaseFactory.getInstance().getConnection()
#>
if iotype == 0:
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE mag.itemId>1 AND magicon.itemId=mag.itemId LIMIT ?,?")
sql.setInt(1, one)
sql.setInt(2, two)
elif iotype == 1 or iotype == 2 or iotype == 6 or iotype == 9 or iotype == 12:
htmltext += "<table width=300><tr><td><button value=\"NG\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_0\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"D\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_1\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"C\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_2\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"B\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_3\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"A\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_4\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"S\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_5\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>"
if grade == 0 or grade == 99:
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND magicon.itemId=mag.itemId LIMIT ?,?")
sql.setString(1, sortType)
sql.setInt(2, one)
sql.setInt(3, two)
else:
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND itemGrade=? AND magicon.itemId=mag.itemId LIMIT ?,?")
sql.setString(1, sortType)
sql.setInt(2, grade)
sql.setInt(3, one)
sql.setInt(4, two)
elif iotype > 2 and iotype <16:
if grade == 0 or grade == 99:
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND magicon.itemId=mag.itemId LIMIT ?,?")
sql.setString(1, sortType)
sql.setInt(2, one)
sql.setInt(3, two)
else:
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND itemGrade=? AND magicon.itemId=mag.itemId LIMIT ?,?")
sql.setString(1, sortType)
sql.setInt(2, grade)
sql.setInt(3, one)
sql.setInt(4, two)
rs=sql.executeQuery()
htmltext += "<table width=300><tr><td></td><td>Ńňđŕíčöŕ: "+str(zagluwka)+"</td></tr>"
#>
while (rs.next()) :
obj=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
icon=rs.getString("itemIcon")
try :
chk = count
if money == 57:
prmoney = str("Adena")
dmoney = str(FIRMONEY)
else:
prmoney = str("COL")
dmoney = str(SECMONEY)
s = str(price)
for i in xrange(len(s)-3,s[0] in ('+','-'),-3):
s=s[:i]+','+s[i:]
pprice = "<font color=00CCFF>"+str(s)+" "+prmoney+"</font>"
count = (count > 1 and str(count)) or str("")
if chk == 1:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a msg=\"Ęóďčňü "+str(itemname)+" ó "+str(nick)+" çŕ "+str(s)+" "+dmoney+"?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
else:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy showm_"+str(itemobj)+"_"+str(item)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
except :
try : sql.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table><br>Ńňđŕíčöű: "
prvsego = range(1,strCount)
for i in prvsego:
htmltext += "<a action=\"bypass -h Quest q8032_MarketBuy str_"+str(iotype)+"_"+str(i)+"_"+str(grade)+"\">"+str(i)+"</a><font color=> </font>"
htmltext += "</body></html>"
elif event.startswith("show_"):
iotype = int(event.replace("show_", ""))
sortType = sorts.get(iotype, str(""))
razdel = trans.get(iotype, str(""))
iotype = str(iotype)
htmltext = "<html><body><a action=\"bypass -h Quest q8032_MarketBuy list\">Cďčńîę ňîâŕđîâ</a>: "+razdel+"<br>"
con=L2DatabaseFactory.getInstance().getConnection()
if iotype == "1" or iotype == "2" or iotype == "6" or iotype =="9" or iotype =="12":
htmltext += "<table width=300><tr><td><button value=\"NG\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_0\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"D\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_1\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"C\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_2\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"B\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_3\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"A\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_4\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"S\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_5\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>"
htmltext += "<table width=300><tr><td></td><td>Ďîńëĺäíčĺ "+str(LIMIT)+":</td></tr>"
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND magicon.itemId=mag.itemId LIMIT 0,?")
sql.setString(1, sortType)
sql.setInt(2, int(LIMIT))
else:
htmltext += "<table width=300><tr><td></td><td></td><td></td><td></td></tr>"
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND magicon.itemId=mag.itemId LIMIT 0,?")
sql.setString(1, sortType)
sql.setInt(2, int(LIMIT))
htmltext += "<tr><td></td><td>Ďđĺäěĺň</td></tr>"
rs=sql.executeQuery()
while (rs.next()) :
obj=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("l2Type")
ltype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
icon=rs.getString("itemIcon")
try :
chk = count
if money == 57:
prmoney = str("Adena")
dmoney = str(FIRMONEY)
else:
prmoney = str("COL")
dmoney = str(SECMONEY)
s = str(price)
for i in xrange(len(s)-3,s[0] in ('+','-'),-3):
s=s[:i]+','+s[i:]
pprice = "<font color=00CCFF>"+str(s)+" "+prmoney+"</font>"
count = (count > 1 and str(count)) or str("")
if chk == 1:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a msg=\"Ęóďčňü "+str(itemname)+" ó "+str(nick)+" çŕ "+str(s)+" "+dmoney+"?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
else:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy showm_"+str(itemobj)+"_"+str(item)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
except :
try : sql.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table><br>"
cona=L2DatabaseFactory.getInstance().getConnection()
getcount=cona.prepareStatement("SELECT COUNT(l2Type) FROM z_market_sell WHERE l2Type=?")
getcount.setString(1, sortType)
rsc=getcount.executeQuery()
if (rsc.next()):
rows = rsc.getInt(1)
vsego = int((rows/LIMIT)+2)
if vsego > 3:
htmltext += "Ńňđŕíčöű: "
st.set("stranic",str(vsego))
prvsego = range(1,vsego)
for i in prvsego:
htmltext += ""
htmltext += " <a action=\"bypass -h Quest q8032_MarketBuy str_"+str(iotype)+"_"+str(i)+"_99\">"+str(i)+"</a><font color=> </font>"
else:
htmltext += ""
rsc.close()
getcount.close()
cona.close()
htmltext += "</body></html>"
elif event.startswith("iotype_"):
search = str(event.replace("iotype_", ""))
iotype,grade=search.split("_")
iotype,grade=int(iotype),int(grade)
sortType = sorts.get(iotype, str(""))
razdel = trans.get(iotype, str(""))
link = str(iotype)
grades = {0: str("NG"),1: str("[D]"), 2: str("[C]"), 3: str("[B]"), 4: str("[A]"), 5: str("[S]")}
pgrade = grades.get(grade, str(""))
htmltext = "<html><body><a action=\"bypass -h Quest q8032_MarketBuy list\">Cďčńîę ňîâŕđîâ</a>: <a action=\"bypass -h Quest q8032_MarketBuy show_"+link+"\">"+razdel+"</a>: "+pgrade+" <br>"
htmltext += "<table width=300><tr><td><button value=\"NG\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_0\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"D\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_1\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"C\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_2\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"B\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_3\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"A\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_4\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td><button value=\"S\" action=\"bypass -h Quest q8032_MarketBuy iotype_"+str(iotype)+"_5\" width=25 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr></table>"
htmltext += "<table width=300><tr><td></td><td>Ďđĺäěĺň</td></tr>"
con=L2DatabaseFactory.getInstance().getConnection()
listitems=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND itemGrade=? AND magicon.itemId=mag.itemId LIMIT 0,?")
listitems.setString(1, sortType)
listitems.setInt(2, grade)
listitems.setInt(3, int(LIMIT))
rs=listitems.executeQuery()
while (rs.next()) :
obj=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
icon=rs.getString("itemIcon")
try :
chk = count
if money == 57:
prmoney = str("Adena")
dmoney = str(FIRMONEY)
else:
prmoney = str("COL")
dmoney = str(SECMONEY)
s = str(price)
for i in xrange(len(s)-3,s[0] in ('+','-'),-3):
s=s[:i]+','+s[i:]
pprice = "<font color=00CCFF>"+str(s)+" "+prmoney+"</font>"
count = (count > 1 and str(count)) or str("")
if chk == 1:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a msg=\"Ęóďčňü "+str(itemname)+" ó "+str(nick)+" çŕ "+str(s)+" "+dmoney+"?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
else:
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy showm_"+str(itemobj)+"_"+str(item)+"\">"+count+" "+str(itemname)+"</a> <br1> "+str(pprice)+" "+prmoney+"; PM: "+str(nick)+"</td></tr>"
except :
try : insertion.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table><br>"
cona=L2DatabaseFactory.getInstance().getConnection()
getcount=cona.prepareStatement("SELECT COUNT(itemGrade) FROM z_market_sell WHERE l2Type=? AND itemGrade=?")
getcount.setString(1, str(sortType))
getcount.setInt(2, grade)
rsc=getcount.executeQuery()
if (rsc.next()):
rows = rsc.getInt(1)
vsego = int((rows/LIMIT)+2)
if vsego > 3:
htmltext += "Ńňđŕíčöű: "
st.set("stranic",str(vsego))
prvsego = range(1,vsego)
for i in prvsego:
htmltext += ""
htmltext += " <a action=\"bypass -h Quest q8032_MarketBuy str_"+str(iotype)+"_"+str(i)+"_"+str(grade)+"\">"+str(i)+"</a><font color=> </font>"
else:
htmltext += ""
rsc.close()
getcount.close()
cona.close()
htmltext += "</body></html>"
elif event.startswith("bye_"):
itemObjId = int(event.replace("bye_", ""))
#=====#
cona=L2DatabaseFactory.getInstance().getConnection()
getcount=cona.prepareStatement("SELECT COUNT(itemObjId) FROM z_market_sell WHERE itemObjId=?")
getcount.setInt(1, itemObjId)
rsc=getcount.executeQuery()
if (rsc.next()):
if rsc.getInt(1)>0:
conn=L2DatabaseFactory.getInstance().getConnection()
byeitem=conn.prepareStatement("SELECT * FROM z_market_sell WHERE itemObjId=?")
byeitem.setInt(1, itemObjId)
rs=byeitem.executeQuery()
while (rs.next()) :
owner=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
try :
chkprice = int(count*price)
if money == 57:
pmoney = str(FIRMONEY)
else:
pmoney = str(SECMONEY)
if st.getQuestItemsCount(money) >= chkprice:
price = int(count*price)
st.takeItems(money,price)
if ench == 0:
st.giveItems(item,count)
enchant = str("")
else:
st.giveItems(item,count,ench)
enchant = " +"+str(ench)+""
st.getPlayer().sendPacket(SystemMessage.sendString("Ęóďëĺíî "+str(count)+" "+(itemname)+" ó "+str(nick)+" çŕ "+str(price)+" "+pmoney+"!"));
htmltext = "<html><body>Ęóďëĺíî <font color=LEVEL>"+str(count)+" "+(itemname)+"</font> ó "+str(nick)+" çŕ "+str(price)+" "+pmoney+"!<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
#
seller = L2World.getInstance().getPlayer(nick)
if seller:
seller.sendPacket(SystemMessage.sendString("Ďđĺäěĺň "+str(count)+" "+(itemname)+" áűë ďđîäŕí íŕ ŕóęöčîíĺ!"));
seller.sendPacket(ConfirmDlg(614,"Ďđĺäěĺň "+str(count)+" "+(itemname)+" áűë ďđîäŕí íŕ ŕóęöčîíĺ!"))
#
pvin = ""+str(count)+" "+str(itemname)+""
private=L2DatabaseFactory.getInstance().getConnection()
newItemObj = IdFactory.getInstance().getNextId()
off=private.prepareStatement("INSERT INTO z_market_private (ownerId,ItemName,itemObjId,prise,money) VALUES (?,?,?,?,?)")
off.setInt(1, owner)
off.setString(2, pvin)
off.setInt(3, newItemObj)
off.setInt(4, price)
off.setInt(5, money)
try :
off.executeUpdate()
off.close()
private.close()
except :
try : private.close()
except : pass
#
con=L2DatabaseFactory.getInstance().getConnection()
kupleno=con.prepareStatement("DELETE FROM z_market_sell WHERE itemObjId = ?")
kupleno.setInt(1, itemObjId)
try :
kupleno.executeUpdate()
kupleno.close()
con.close()
except :
try : con.close()
except : pass
else:
htmltext = "<html><body>Ó âŕń íĺ őâŕňŕĺň "+pmoney+"<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
except :
try :
byeitem.close()
except : pass
try :
conn.close()
except :
pass
#
else:
htmltext = "<html><body>Ďđĺäěĺň óćĺ ęňî-ňî ęóďčë ): <br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
else:
htmltext = "<html><body>Oops!<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
rsc.close()
getcount.close()
cona.close()
elif event.startswith("showm_"):
search = str(event.replace("showm_", ""))
obj,itemid=search.split("_")
obj,itemid=int(obj),int(itemid)
con=L2DatabaseFactory.getInstance().getConnection()
listitems=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE mag.itemObjId=? AND magicon.itemId=?")
listitems.setInt(1, obj)
listitems.setInt(2, itemid)
rs=listitems.executeQuery()
while (rs.next()) :
icon=rs.getString("itemIcon")
itemname=rs.getString("ItemName")
nickname=rs.getString("char_name")
grade=rs.getInt("itemGrade")
enchan=rs.getInt("enchLvl")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
try :
st.set("moreitem",str(obj))
st.set("morecount",str(count))
st.set("moreprice",str(price))
if money == 57:
dmoney = str(FIRMONEY)
else:
dmoney = str(SECMONEY)
mprice = int(count*price)
s = str(price)
for i in xrange(len(s)-3,s[0] in ('+','-'),-3):
s=s[:i]+','+s[i:]
pprice = "<font color=00CCFF>"+str(s)+" "+dmoney+"</font>"
grades = {1: "d", 2: "c", 3: "b", 4: "a", 5: "s"}
pgrade = grades.get(grade, str(""))
enchant = (enchan > 0 and " +"+str(enchan)+"") or str("")
htmltext = "<html><body>Âű âűáđŕëč:<br>"
htmltext += "<table width=300><tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><font color=LEVEL>"+str(itemname)+" "+str(enchant)+"</font><br1>Öĺíŕ: "+str(pprice)+"; Ďđîäŕâĺö: "+str(nickname)+"</td></tr></table>"
htmltext += "<br>Â ďđîäŕćĺ: "+str(count)+""
htmltext += "<br>Ńęîëüęî őîňčňĺ ęóďčňü?:"
htmltext += "<edit var=\"cols\" width=200 length=\"10\"><br>"
htmltext += "<button value=\"Ok\" action=\"bypass -h Quest q8032_MarketBuy byem_ $cols _ xz\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>"
htmltext += "<br><a msg=\"Ńęóďčňü âńĺ "+str(count)+" "+str(itemname)+" ó "+str(nickname)+" çŕ "+str(mprice)+" adena?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(obj)+"\">Ńęóďčňü âń¸</a><br>"
htmltext += "<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
except :
try : listitems.close()
except : pass
try :
con.close()
except :
pass
elif event.startswith("byem_ "):
search = str(event.replace("byem_ ", ""))
search,ptype=search.split("_")
search,ptype=str(search),str(ptype)
search = str(search.replace(" ", ""))
ptype = str(ptype.replace(" ", ""))
if search == "":
htmltext = "<html><body>Âű íĺ óęŕçŕëč ęîëč÷ĺńňâî.<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
return htmltext
wantcount = int(search)
itemObjId = st.getInt("moreitem")
itemCount = st.getInt("morecount")
onePrice = st.getInt("moreprice")
#=====#
cona=L2DatabaseFactory.getInstance().getConnection()
getcount=cona.prepareStatement("SELECT COUNT(itemObjId) FROM z_market_sell WHERE itemObjId=?")
getcount.setInt(1, itemObjId)
rsc=getcount.executeQuery()
if (rsc.next()):
if rsc.getInt(1)>0:
conn=L2DatabaseFactory.getInstance().getConnection()
byeitem=conn.prepareStatement("SELECT * FROM z_market_sell WHERE itemObjId=?")
byeitem.setInt(1, itemObjId)
rs=byeitem.executeQuery()
while (rs.next()) :
owner=rs.getInt("ownerId")
nick=rs.getString("char_name")
itemname=rs.getString("ItemName")
ench=rs.getInt("enchLvl")
item=rs.getInt("itemId")
grade=rs.getInt("itemGrade")
itype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
money=rs.getInt("money")
try :
writepr = price
price = int(onePrice*wantcount)
ost = int(count-wantcount)
if money == 57:
pmoney = str(FIRMONEY)
else:
pmoney = str(SECMONEY)
if wantcount > count:
htmltext = "<html><body>Íĺďđŕâčëüíîĺ ęîëč÷ĺńňâî ďđĺäěĺňîâ!<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
elif st.getQuestItemsCount(money) >= price:
st.takeItems(money,price)
if ench == 0:
st.giveItems(item,wantcount)
enchant = str("")
else:
st.giveItems(item,wantcount,ench)
enchant = " +"+str(ench)+""
st.getPlayer().sendPacket(SystemMessage.sendString("Ęóďëĺíî "+str(wantcount)+" "+(itemname)+" ó "+str(nick)+" çŕ "+str(price)+" "+pmoney+"!"));
htmltext = "<html><body>Ęóďëĺíî <font color=LEVEL>"+str(wantcount)+" "+(itemname)+"</font> ó "+str(nick)+" çŕ "+str(price)+" "+pmoney+"!<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
#
seller = L2World.getInstance().getPlayer(nick)
if seller:
seller.sendPacket(SystemMessage.sendString("Ďđĺäěĺň "+str(wantcount)+" "+(itemname)+" áűë ďđîäŕí íŕ ŕóęöčîíĺ!"));
seller.sendPacket(ConfirmDlg(614,"Ďđĺäěĺň "+str(wantcount)+" "+(itemname)+" áűë ďđîäŕí íŕ ŕóęöčîíĺ!"))
#
pvin = ""+str(wantcount)+" "+str(itemname)+""
newItemObj = IdFactory.getInstance().getNextId()
private=L2DatabaseFactory.getInstance().getConnection()
off=private.prepareStatement("INSERT INTO z_market_private (ownerId,ItemName,itemObjId,prise,money) VALUES (?,?,?,?,?)")
off.setInt(1, owner)
off.setString(2, pvin)
off.setInt(3, newItemObj)
off.setInt(4, price)
off.setInt(5, money)
try :
off.executeUpdate()
off.close()
private.close()
except :
try : private.close()
except : pass
#
if ost>0:
con=L2DatabaseFactory.getInstance().getConnection()
kupleno=con.prepareStatement("UPDATE z_market_sell SET count=?, prise=? WHERE itemObjId =?")
kupleno.setInt(1, ost)
kupleno.setInt(2, writepr)
kupleno.setInt(3, itemObjId)
try :
kupleno.executeUpdate()
kupleno.close()
con.close()
except :
try : con.close()
except : pass
else:
con=L2DatabaseFactory.getInstance().getConnection()
kupleno=con.prepareStatement("DELETE FROM z_market_sell WHERE itemObjId = ?")
kupleno.setInt(1, itemObjId)
try :
kupleno.executeUpdate()
kupleno.close()
con.close()
except :
try : con.close()
except : pass
else:
htmltext = "<html><body>Ó âŕń íĺ őâŕňŕĺň "+pmoney+"</body></html>"
except :
try :
byeitem.close()
except : pass
try :
conn.close()
except :
pass
#
else:
htmltext = "<html><body>Ďđĺäěĺň óćĺ ęňî-ňî ęóďčë ):<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a> </body></html>"
else:
htmltext = "<html><body>Oops!<br><br><a action=\"bypass -h Quest q8032_MarketBuy list\">Âĺđíóňüń˙.</a></body></html>"
rsc.close()
getcount.close()
cona.close()
return htmltext
def onTalk (self,npc,player):
st = player.getQuestState(qn)
npcId = npc.getNpcId()
if npcId == MARKET:
htmltext = "privetstvie.htm"
return htmltext
QUEST = Quest(8032,qn,"custom")
CREATED = State('Start', QUEST)
QUEST.setInitialState(CREATED)
QUEST.addStartNpc(MARKET)
QUEST.addTalkId(MARKET)