Свернуть ↑
import sys
from java.lang import System
from java.util import Iterator
from com.l2jcore.util.database import L2DatabaseFactory
from com.l2jcore.Game.network.serverpackets import CreatureSay
from com.l2jcore.Game.model.quest import State
from com.l2jcore.Game.model.quest import QuestState
from com.l2jcore.Game.model.quest.jython import QuestJython as JQuest
from com.l2jcore.Game.network.serverpackets import SystemMessage
from com.l2jcore.Game.model.actor.instance import L2ItemInstance
from com.l2jcore.Game.model import L2World
from com.l2jcore.Game.network.serverpackets import ConfirmDlg
from com.l2jcore.Game.network.serverpackets import UserInfo
from com.l2jcore.Game.network.serverpackets import CharInfo
from com.l2jcore.Game.network.serverpackets import InventoryUpdate
from com.l2jcore.Game.datatables.sql import ItemTable
from com.l2jcore.util.random import Rnd
qn = "q8032_MarketBuy"
MARKET = 80007
#type
weapons = "<button value=\"weapons\" action=\"bypass -h Quest q8032_MarketBuy show_wpns\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
armors = "<button value=\"armors\" action=\"bypass -h Quest q8032_MarketBuy show_arms\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
resources = "<button value=\"Ресы\" action=\"bypass -h Quest q8032_MarketBuy show_res\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
recipes = "<button value=\"Рецепты\" action=\"bypass -h Quest q8032_MarketBuy show_recp\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
books = "<button value=\"Книги\" action=\"bypass -h Quest q8032_MarketBuy show_buks\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
soulshots = "<button value=\"Соски\" action=\"bypass -h Quest q8032_MarketBuy show_shot\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
#grade
dgrade = "<button value=\D\ action=\"bypass -h Quest q8032_MarketBuy grade_1\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
cgrade = "<button value=\C\ action=\"bypass -h Quest q8032_MarketBuy grade_2\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
bgrade = "<button value=\B\ action=\"bypass -h Quest q8032_MarketBuy grade_3\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
agrade = "<button value=\A\ action=\"bypass -h Quest q8032_MarketBuy grade_4\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
sgrade = "<button value=\S\ action=\"bypass -h Quest q8032_MarketBuy grade_5\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">"
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" :
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></td><td></td><td></td><td></td><td>"+soulshots+"</td></tr></table>"
htmltext += "<table width=300><tr><td></td><td>Последние 50:</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,50")
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")
icon=rs.getString("itemIcon")
try :
pprice = price
if pprice >= 10000:
pprice = "<font color=00CCFF>"+str(pprice)+"</font>"
elif price >= 100000:
pprice = "<font color=FF0099>"+str(pprice)+"</font>"
elif price >= 1000000:
pprice = "<font color=FFCC00>"+str(pprice)+"</font>"
elif price >= 10000000:
pprice = "<font color=00FF66>"+str(pprice)+"</font>"
elif price >= 100000000:
pprice = "<font color=33CCCC>"+str(pprice)+"</font>"
elif price >= 1000000000:
pprice = "<font color=FF0066>"+str(pprice)+"</font>"
else:
pprice = "<font color=FFFFFF>"+str(pprice)+"</font>"
if count > 1:
count = str(count)
else:
count = str("")
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a msg=\"Купить "+count+""+str(itemname)+" у "+str(nick)+" за "+str(price)+" adena?\" action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> Цена: "+str(pprice)+"; Продавец: "+str(nick)+"</td></tr>"
except :
try : insertion.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table></body></html>"
elif event.startswith("show_"):
wamrs = str(event.replace("show_", ""))
if wamrs == "wpns":
sortType = str("Weapon")
razdel = str("Оружие")
view = str("1")
elif wamrs == "arms":
sortType = str("Armor")
razdel = str("Броня")
view = str("2")
elif wamrs == "res":
sortType = str("Resource")
razdel = str("Ресурсы")
view = str("3")
elif wamrs == "recp":
sortType = str("Recipe")
razdel = str("Рецепты")
view = str("4")
elif wamrs == "buks":
sortType = str("Spellbook")
razdel = str("Книги")
view = str("5")
elif wamrs == "shot":
sortType = str("Soulshot")
razdel = str("Патроны")
view = str("6")
st.set("view",view)
htmltext = "<html><body><a action=\"bypass -h Quest q8032_MarketBuy list\">Cписок товаров</a>: "+razdel+"<br>"
con=L2DatabaseFactory.getInstance().getConnection( )
if view == "1" or view == "2":
htmltext += "<table width=300><tr><td>"+dgrade+"</td><td>"+cgrade+"</td><td>"+bgrade+"</td><td>"+agrade+"</td><td>"+sgrade+"</td></tr></table>"
htmltext += "<table width=300><tr><td></td><td>Последние 50:</td></tr>"
sql=con.prepareStatement("SELECT * FROM `z_market_sell` mag, `z_market_icons` magicon WHERE l2Type=? AND magicon.itemId=mag.itemId LIMIT 0,50")
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")
htmltext += "<tr><td></td><td>Предмет</td></tr>"
listitems=sql
listitems.setString(1, sortType)
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("l2Type")
ltype=rs.getString("itemType")
itemobj=rs.getInt("itemObjId")
count=rs.getInt("count")
price=rs.getInt("prise")
icon=rs.getString("itemIcon")
try :
if price >= 10000:
price = "<font color=00CCFF>"+str(price)+"</font>"
elif price >= 100000:
price = "<font color=FF0099>"+str(price)+"</font>"
elif price >= 1000000:
price = "<font color=FFCC00>"+str(price)+"</font>"
elif price >= 10000000:
price = "<font color=00FF66>"+str(price)+"</font>"
elif price >= 100000000:
price = "<font color=33CCCC>"+str(price)+"</font>"
elif price >= 1000000000:
price = "<font color=FF0066>"+str(price)+"</font>"
else:
price = "<font color=FFFFFF>"+str(price)+"</font>"
if count > 1:
count = str(count)
else:
count = str("")
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> Цена: "+str(price)+"; Продавец: "+str(nick)+"</td></tr>"
except :
try : insertion.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table></body></html>"
elif event.startswith("grade_"):
grade = int(event.replace("grade_", ""))
wamrs= st.getInt("view")
if wamrs == 1:
sortType = str("Weapon")
razdel = str("Оружие")
link = str("show_wpns")
elif wamrs == 2:
sortType = str("Armor")
razdel = str("Броня")
link = str("show_arms")
elif wamrs == 3:
sortType = str("Resource")
razdel = str("Ресурсы")
link = str("show_res")
elif wamrs == 4:
sortType = str("Recipe")
razdel = str("Рецепты")
link = str("show_recp")
elif wamrs == 5:
sortType = str("Spellbook")
razdel = str("Книги")
link = str("show_buks")
elif wamrs == 6:
sortType = str("Soulshot")
razdel = str("Патроны")
link = str("show_shot")
if grade == 1:
pgrade = str("[D]")
elif grade == 2:
pgrade = str("[C]")
elif grade == 3:
pgrade = str("[B]")
elif grade == 4:
pgrade = str("[A]")
elif grade == 5:
pgrade = str("[S]")
htmltext = "<html><body><a action=\"bypass -h Quest q8032_MarketBuy list\">Cписок товаров</a>: <a action=\"bypass -h Quest q8032_MarketBuy "+link+"\">"+razdel+"</a>: "+pgrade+" <br>"
htmltext += "<table width=300><tr><td>"+dgrade+"</td><td>"+cgrade+"</td><td>"+bgrade+"</td><td>"+agrade+"</td><td>"+sgrade+"</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")
listitems.setString(1, sortType)
listitems.setInt(2, grade)
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")
icon=rs.getString("itemIcon")
try :
if price >= 10000:
price = "<font color=00CCFF>"+str(price)+"</font>"
elif price >= 100000:
price = "<font color=FF0099>"+str(price)+"</font>"
elif price >= 1000000:
price = "<font color=FFCC00>"+str(price)+"</font>"
elif price >= 10000000:
price = "<font color=00FF66>"+str(price)+"</font>"
elif price >= 100000000:
price = "<font color=33CCCC>"+str(price)+"</font>"
elif price >= 1000000000:
price = "<font color=FF0066>"+str(price)+"</font>"
else:
price = "<font color=FFFFFF>"+str(price)+"</font>"
if count > 1:
count = str(count)
else:
count = str("")
htmltext += "<tr><td><img src=\"Icon."+str(icon)+"\" width=32 height=32></td><td><a action=\"bypass -h Quest q8032_MarketBuy bye_"+str(itemobj)+"\">"+count+" "+str(itemname)+"</a> <br1> Цена: "+str(price)+"; Продавец: "+str(nick)+"</td></tr>"
except :
try : insertion.close()
except : pass
try :
con.close()
except :
pass
htmltext += "</table></body></html>"
elif event.startswith("bye_"):
itemObjId = int(event.replace("bye_", ""))
#=====#
conn=L2DatabaseFactory.getInstance().getConnection ()
byeitem=conn.prepareStatement("SELECT ownerId,char_name,ItemName,enchLvl,itemGrade,l2Typ e,itemType,itemId,itemObjId,count,prise 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")
try :
if st.getQuestItemsCount(4037) >= price:
st.takeItems(4037,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)+" adena!"));
htmltext = "<html><body>Куплено <font color=LEVEL>"+str(count)+" "+(itemname)+"</font> у "+str(nick)+" за "+str(price)+" adena!<br></body></html>"
#
pvin = ""+str(count)+" "+str(itemname)+""
player.sendPacket(ConfirmDlg(614,"Предмет "+str(count)+" "+(itemname)+" был продан на аукционе!"))
seller = L2World.getInstance().getPlayer(nick)
if seller:
seller.sendPacket(SystemMessage.sendString("Предме т "+str(count)+" "+(itemname)+" был продан на аукционе!"));
private=L2DatabaseFactory.getInstance().getConnect ion()
off=private.prepareStatement("INSERT INTO z_market_private (ownerId,ItemName,itemObjId,prise) VALUES (?,?,?,?)")
off.setInt(1, owner)
off.setString(2, pvin)
off.setInt(3, itemObjId)
off.setInt(4, price)
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>У вас не хватает денег</body></html>"
except :
try : insertion.close()
except : pass
try :
conn.close()
except :
pass
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)