import sys
from java.util import Iterator
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 java.lang import System
import time
qn = "q9215_statystikaServera"
MARKET = 92145 #Id нпс
id_many = 57 #Id монет
prise_castle = 300 # цена просмотра статистики (Замки)
prise_epicrb = 300 # цена просмотра статистики (Епик РБ)
prise_pl_lvl = 300 # цена просмотра статистики (Игроки - Левел)
prise_pl_pvp = 300 # цена просмотра статистики (Игроки - PvP)
prise_pl_pk = 300 # цена просмотра статистики (Игроки - PK)
prise_pl_time = 300 # цена просмотра статистики (Игроки - Время в игре)
prise_сl_lvl = 300 # цена просмотра статистики (Клан - Левел)
prise_cl_repa = 300 # цена просмотра статистики (Клан - Репутация)
prise_cl_pl = 300 # цена просмотра статистики (Клан - Игроки)
col_pl = "50" #количество отображаемых игроков в статистики "Игроки"
col_сl = "50" #количество отображаемых кланов в статистики "Кланы"
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 == "castle" :
if st.getQuestItemsCount(id_many) >= prise_castle:
st.takeItems(id_many,prise_castle)
htmltext = u"<html><title>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430</title><body><center><br><br><table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera list_players\">\u0418\u0433\u0440\u043e\u043a\u0438</a></a></td><td><a action=\"bypass -h Quest q9215_statystikaServera list_clans\">\u041a\u043b\u0430\u043d\u044b</a></td><td><font color=CCFF33>[\u0417\u0430\u043c\u043a\u0438]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera epicrb\">\u0415\u043f\u0438\u043a \u0420\u0411</a></td></tr></table>------------------------------------------------------------------"
htmltext += u"<table width=300><tr><td><font color=f0197a>\u2116</font></td><td><font color=3cd7f0>\u0417\u0430\u043c\u043e\u043a</font></td><td><font color=f0fab1>\u041d\u0430\u043b\u043e\u0433</font></td><td><font color=3ce773>\u0412\u043b\u0430\u0434\u0435\u0435\u0442</font></td></tr>"
con=L2DatabaseFactory.getInstance().getConnection()
sql=con.prepareStatement("SELECT id,name,siegeDate,taxPercent,(SELECT clan_name FROM `clan_data` WHERE hasCastle=id) AS owner FROM `castle` ORDER BY id")
rs = sql.executeQuery()
while (rs.next()) :
id=rs.getString("id")
id=str(id)
name=rs.getString("name")
name=str(name)
siegeDate=rs.getString("siegeDate")
# siegeDate= (siegeDate/1000)
# siegeDate= time.localtime(siegeDate)
owner1=rs.getString("owner")
owner1=str(owner1)
taxPercent=rs.getString("taxPercent")
taxPercent=str(taxPercent)
htmltext += "<tr><td><font color=f0197a>"+id+"</font></td><td><font color=3cd7f0>"+name+"</font></td><td><font color=f0fab1>"+taxPercent+"%</font></td><td><font color=3ce773>"+owner1+"</font></td></tr>"
htmltext += "</table>------------------------------------------------------------------</center></body></html>"
con.close()
else:
htmltext = "NoMany.htm"
elif event == "list_players" :
htmltext = "list_players.htm"
elif event == "list_clans" :
htmltext = "list_clans.htm"
elif event == "epicrb" :
if st.getQuestItemsCount(id_many) >= prise_epicrb:
st.takeItems(id_many,prise_epicrb)
htmltext = u"<html><title>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430</title><body><center><br><br><table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera list_players\">\u0418\u0433\u0440\u043e\u043a\u0438</a></a></td><td><a action=\"bypass -h Quest q9215_statystikaServera list_clans\">\u041a\u043b\u0430\u043d\u044b</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera castle\">\u0417\u0430\u043c\u043a\u0438</a></td><td><font color=CCFF33>[\u0415\u043f\u0438\u043a \u0420\u0411]</font></td></tr></table>------------------------------------------------------------------"
htmltext += u"<table width=300><tr><td><font color=f07ee5>\u2116</font></td><td><font color=05f3ea>\u0411\u043e\u0441</font></td><td><font color=7e8781>\u041b\u0432\u043b</font></td><td><font color=7ed607>\u0421\u0442\u0430\u0442\u0443\u0441</font></td></tr>"
pos = 0
con=L2DatabaseFactory.getInstance().getConnection()
sql=con.prepareStatement("SELECT `grandboss_data`.`boss_id`, `grandboss_data`.`status`, npc.level, npc.name FROM `grandboss_data` LEFT JOIN `npc` ON `grandboss_data`.`boss_id` = `npc`.`id` ORDER BY `grandboss_data`.`status` ASC , `npc`.`level` DESC")
rs = sql.executeQuery()
while (rs.next()) :
name=rs.getString("name")
name=str(name)
level=rs.getString("level")
level=str(level)
status=rs.getString("status")
pos = pos + 1
posstr = str(pos)
if status == "0":
status = u"<font color=7ee30f>\u0416\u0438\u0432</font>"
else:
status = u"<font color=f00000>\u0421\u0434\u043e\u0445</font>"
htmltext += "<tr><td><font color=f07ee5>"+posstr+"</font></td><td><font color=05f3ea>"+str(name)+"</font></td><td><font color=7e8781>"+str(level)+"</font></td><td>"+status+"</td></tr>"
htmltext += "</table>------------------------------------------------------------------</center></body></html>"
con.close()
else:
htmltext = "NoMany.htm"
elif event.startswith("show_"):
wamrs = str(event.replace("show_", ""))
if wamrs == "lvl":
prise = prise_pl_lvl
sortType = str("ORDER BY `sp` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font color=\"LEVEL\">[\u041e\u043f\u044b\u0442]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pvp\">PVP</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pk\">PK</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_time\">\u0412\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0435</a></td></tr></table>------------------------------------------------------------------"
elif wamrs == "pvp":
prise = prise_pl_pvp
sortType = str("ORDER BY `pvpkills` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera show_lvl\">\u041e\u043f\u044b\u0442</a></td><td><font color=\"LEVEL\">[PVP]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pk\">PK</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_time\">\u0412\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0435</a></td></tr></table>------------------------------------------------------------------"
elif wamrs == "pk":
prise = prise_pl_pk
sortType = str("ORDER BY `pkkills` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera show_lvl\">\u041e\u043f\u044b\u0442</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pvp\">PVP</a></td><td><font color=\"LEVEL\">[PK]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_time\">\u0412\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0435</a></td></tr></table>------------------------------------------------------------------"
elif wamrs == "time":
prise = prise_pl_time
sortType = str("ORDER BY `onlinetime` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera show_lvl\">\u041e\u043f\u044b\u0442</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pvp\">PVP</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show_pk\">PK</a></td><td><font color=\"LEVEL\">[\u0412\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0435]</font></td></tr></table>------------------------------------------------------------------"
pos = 0
if st.getQuestItemsCount(id_many) >= prise:
st.takeItems(id_many,prise)
htmltext = u"<html><title>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430</title><body><center><br><br><center><table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font color=CCFF33>[\u0418\u0433\u0440\u043e\u043a\u0438]</font></a></td><td><a action=\"bypass -h Quest q9215_statystikaServera list_clans\">\u041a\u043b\u0430\u043d\u044b</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera castle\">\u0417\u0430\u043c\u043a\u0438</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera epicrb\">\u0415\u043f\u0438\u043a \u0420\u0411</a></td></tr></table>"
htmltext += "------------------------------------------------------------------"
htmltext += razdel
htmltext += u"<table width=300><tr><td><font color=f1c900>\u2116</font></td><td><font color=00dfe8>\u0418\u043c\u044f</font></td><td><font color=ff8f92>\u041b\u0432\u043b</font></td><td><font color=5ef28b>\u041a\u043b\u0430\u0441\u0441</font></td><td>\u0412\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0435</td><td><font color=cfb464>PvP / PK</font></td></tr>"
con=L2DatabaseFactory.getInstance().getConnection()
sql=con.prepareStatement("SELECT karma,level,onlinetime,char_name,pvpkills,pkkills,(SELECT ClassName FROM char_templates WHERE char_templates.ClassId=characters.classid) AS class FROM `characters` WHERE accesslevel<1 "+sortType+" LIMIT "+col_pl+"")
rs = sql.executeQuery()
while (rs.next()) :
char_name=rs.getString("char_name")
char_name=str(char_name)
onlinetime=rs.getString("onlinetime")
onlinetime=int(onlinetime)
onlinetime = (onlinetime/60/60/24)
char_pkkills=rs.getString("pkkills")
char_pkkills=str(char_pkkills)
char_pvpkills=rs.getString("pvpkills")
char_pvpkills=str(char_pvpkills)
char_level=rs.getString("level")
char_level=str(char_level)
char_class=rs.getString("class")
char_class=str(char_class)
pos = pos + 1
posstr = str(pos)
htmltext += "<tr><td><font color=f1c900>"+posstr+"</font></td><td><font color=00dfe8>"+char_name+"</font></td><td><font color=ff8f92>"+char_level+"</font></td><td><font color=5ef28b>"+char_class+"</font></td><td>"+str(onlinetime)+u" \u0434.</td><td><font color=cfb464>"+char_pvpkills+"/"+char_pkkills+"</font></td></tr>"
htmltext += "</table>------------------------------------------------------------------</center></body></html>"
con.close()
else:
htmltext = "NoMany.htm"
elif event.startswith("show2_"):
wamrs = str(event.replace("show2_", ""))
if wamrs == "lvl":
prise = prise_сl_lvl
sortTypeClan = str("ORDER BY `clan_level` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font color=\"LEVEL\">[\u041b\u0435\u0432\u0435\u043b]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera show2_repa\">\u0420\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044f</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show2_players\">\u0418\u0433\u0440\u043e\u043a\u0438</a></td></tr></table>------------------------------------------------------------------"
elif wamrs == "repa":
prise = prise_cl_repa
sortTypeClan = str("ORDER BY `reputation_score` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera show2_lvl\">\u041b\u0435\u0432\u0435\u043b</a></td><td><font color=\"LEVEL\">[\u0420\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044f]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera show2_players\">\u0418\u0433\u0440\u043e\u043a\u0438</a></td></tr></table>------------------------------------------------------------------"
elif wamrs == "players":
prise = prise_cl_pl
sortTypeClan = str("ORDER BY `players` DESC")
razdel = u"<table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera show2_lvl\">\u041b\u0435\u0432\u0435\u043b</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera show2_repa\">\u0420\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044f</a></td><td><font color=\"LEVEL\">[\u0418\u0433\u0440\u043e\u043a\u0438]</font></td></tr></table>------------------------------------------------------------------"
pos = 0
if st.getQuestItemsCount(id_many) >= prise:
st.takeItems(id_many,prise)
htmltext = u"<html><title>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430</title><body><center><br><br><center><table width=\"230\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a action=\"bypass -h Quest q9215_statystikaServera list_players\">\u0418\u0433\u0440\u043e\u043a\u0438</a></td><td><font color=CCFF33>[\u041a\u043b\u0430\u043d\u044b]</font></td><td><a action=\"bypass -h Quest q9215_statystikaServera castle\">\u0417\u0430\u043c\u043a\u0438</a></td><td><a action=\"bypass -h Quest q9215_statystikaServera epicrb\">\u0415\u043f\u0438\u043a \u0420\u0411</a></td></tr></table>"
htmltext += "------------------------------------------------------------------"
htmltext += razdel
htmltext += u"<table width=300><tr><td>\u2116</td><td><font color=f2b88f>\u041a\u043b\u0430\u043d</font></td><td><font color=539f65>\u041b\u0432\u043b</font></td><td><font color=53bcee>\u0420\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044f</font></td><td><font color=8fd96f>\u041b\u0438\u0434\u0435\u0440</font></td><td><font color=ffe967>\u0418\u0433\u0440\u043e\u043a\u043e\u0432</font></td><td><font color=87ffff>Ally</font></td></tr>"
con=L2DatabaseFactory.getInstance().getConnection()
sql=con.prepareStatement("SELECT clan_name,clan_level,reputation_score,ally_name,(SELECT char_name FROM `characters` WHERE characters.obj_Id=clan_data.leader_id) AS leader,(SELECT COUNT(*) FROM characters WHERE characters.clanid=clan_data.clan_id) as players FROM `clan_data` "+sortTypeClan+" LIMIT "+col_pl+"")
rs = sql.executeQuery()
while (rs.next()) :
clan_name=rs.getString("clan_name")
clan_name=str(clan_name)
clan_level=rs.getString("clan_level")
clan_level=str(clan_level)
reputation_score=rs.getString("reputation_score")
reputation_score=str(reputation_score)
ally_name=rs.getString("ally_name")
ally_name=str(ally_name)
leader=rs.getString("leader")
leader=str(leader)
players=rs.getString("players")
players=str(players)
pos = pos + 1
posstr = str(pos)
htmltext += "<tr><td>"+posstr+"</td><td><font color=f2b88f>"+clan_name+"</font></td><td><font color=539f65>"+clan_level+"</font></td><td><font color=53bcee>"+reputation_score+"</font></td><td><font color=8fd96f>"+leader+"</font></td><td><font color=ffe967>"+players+"</font></td><td><font color=87ffff>"+ally_name+"</font></td></tr>"
htmltext += "</table>------------------------------------------------------------------</center></body></html>"
con.close()
else:
htmltext = "NoMany.htm"
return htmltext
def onTalk (self,npc,player):
st = player.getQuestState(qn)
npcId = npc.getNpcId()
if npcId == MARKET:
htmltext = "privetstvie.htm"
return htmltext
QUEST = Quest(9215,qn,"custom")
QUEST.addStartNpc(MARKET)
QUEST.addTalkId(MARKET)