Jump to content

Recommended Posts

Posted

 esta es la coneccion que da error

def CLASS_NAME(case):
    val = "Unknow Class"
    try: val = CharTemplateTable.getInstance().getClassNameById(int(case))
    except: val = "Unknow Class"
    return val

aca el npc

import sys

from java.sql import Connection
from java.sql import ResultSet
from java.sql import SQLException
from java.sql import Statement
from java.util import HashMap
from java.util import Map
from java.util.logging import Level
from java.util.logging import Logger

from java.lang import StringBuilder
from java.lang import Object
from java.lang import Class
from java.lang import Throwable

from java.lang                                      import Math
from java.lang                                      import System
from cStringIO                                      import StringIO
from com.l2jserver                                  import Config
from com.l2jserver                                  import L2DatabaseFactory
from com.l2jserver.gameserver.model                 import StatsSet
from com.l2jserver.gameserver.model.base            import ClassId
from com.l2jserver.gameserver.model.base 	        import Race
from com.l2jserver.gameserver.model.quest           import State
from com.l2jserver.gameserver.model.quest           import QuestState
from com.l2jserver.gameserver.model.quest.jython    import QuestJython as JQuest
from com.l2jserver.gameserver.datatables            import ItemTable
from com.l2jserver.gameserver.datatables            import SkillTable
from com.l2jserver.gameserver.datatables            import SkillTreesData
from com.l2jserver.gameserver.datatables            import ExperienceTable
from com.l2jserver.gameserver.datatables            import CharTemplateTable
from com.l2jserver.gameserver.datatables            import ClassListData
from com.l2jserver.gameserver.instancemanager       import QuestManager
from com.l2jserver.gameserver.taskmanager           import AttackStanceTaskManager
from com.l2jserver.gameserver.network.L2GameClient  import GameClientState
from com.l2jserver.gameserver.network.serverpackets import SetupGauge
from com.l2jserver.gameserver.network.serverpackets import ActionFailed
from com.l2jserver.gameserver.network.serverpackets import RestartResponse
from com.l2jserver.gameserver.network.serverpackets import CharSelectionInfo
from com.l2jserver.gameserver.model.actor.templates import L2PcTemplate



NPC       = [1234]
QuestId   = 1234
QuestName = "SubclassNpc"
QuestDesc = "custom"
QI        = "%s_%s" % (QuestId,QuestName)


print "============================="
print "INFO LOADED SUBCLASS MANAGER"
print "============================="

#-------------------------------------------------------------------------------------------------------------------------------------
# SETTINGS
#-------------------------------------------------------------------------------------------------------------------------------------
#For more than 3 subclasses, you must increase the variable number into the SQL and add to the database. 
#inside the sql you will find some variables named SubclassidX. Just change the "X" increasing the number. 
#This value shouldn't be changed if you don't want to increase the subclasses number beyond 3. 
#Increase or decrease the "CONFIG_MAX_SUBS_IN_DB" value without make these changes, will cause errors. Be carefull!.
CONFIG_MAX_SUBS_IN_DB = 3

# Subclasses number that can be added. Must be less than or equal to "CONFIG_MAX_SUBS_IN_DB".
CONFIG_MAX_SUBS_AMOUNT = 3

#True, allows reloading the configuration script from the game, without restarting the server (for GMs only). False, disables it.
CONFIG_SHOW_RELOAD_PANEL = True

# True enable restart protection. Recommended Default: True
CONFIG_ENABLE_RESTART_PROTECTION = True

# Delay time in seconds before being restarted automatically. Not recommended a number bellow to 5 seconds. Default: 5 seconds
CONFIG_RESTART_TIME_PROTECTION = 10

# True: The user must wait a while before take any action. Default: True
# False: The user can do any action without time constraints. Not recommended
CONFIG_ENABLE_FLOOD_PROTECTION = True

#Blocking time in seconds before take any action.
CONFIG_FLOOD_PROTECTION_TIME = 20

#Subclass list that won't be able to choose. Default: [57,51] Overlord and Warsmith
CONFIG_FORBBIDEN_SUBCLASSES = []

# True, allows add stackable subclasses in every original game subclass (Mainclass and every retails).
# False, allows add stackable subclasses in only one original game subclass or main class
CONFIG_ALLOW_MULT_SUBS = False

# True, allows any stackable subclass. False, allows add your own race's subclasses only.
CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = True

#This option work if "CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = False", Also you need to be using a original game subclass (Retail) to get available this.
#True, allow add a subclass with the same main class's race. False, allow add a subclass with the same Retail's race.
CONFIG_ALLOW_MUTANT_RETAIL = True

#The next three options work if "CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = True" only.
#True, allows everybody add Kamael subclass. False otherwise.
CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE = True

#True, allows Dark Elf class do elf subclass, and Elf class do Dark Elf Subclass. False otherwise.
CONFIG_ALLOW_DELF_AND_ELF_EXCHANGE_SUBS = True

#True, allows Kamaels add any subclass. False, allows Kamaels to add their own race only.
CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL = True

#True, allows delete the main class or any subclass added. False, allow to delete added subclasses only. Default: False
CONFIG_ALLOW_DELETE_MAIN_CLASS = False

#Allow to add subclasses already used in the original game subclasses (Retail). Default: False
CONFIG_ALLOW_SUBCLASS_DUPLICATION = False

#True, allows add subsclasses if the character is a Noblesse only. False, otherwise. Default: False
CONFIG_ALLOW_SUBS_FOR_NOBLESSE_ONLY = False

#True, allow to add subclass or any other actions if you have the required items only. False, otherwise
CONFIG_ENABLE_FEE_FOR_SUBCLASS = False

#Required Item to switch between the subclasses. Default: 57 (Adena)
#Required items number.
CONFIG_SWITCH_ITEM_REQUIRED = 57
CONFIG_SWITCH_ITEM_AMOUNT = 1000000

#Required Item to add a subclass.
#Required items number.
CONFIG_ADD_ITEM_REQUIRED = 3481
CONFIG_ADD_ITEM_AMOUNT = 100

#Required Item to delete subclasses.
#Required items number.
CONFIG_DELETE_ITEM_REQUIRED = 3481
CONFIG_DELETE_ITEM_AMOUNT = 10

# Minimum Level to add a subclass. Default: 76
CONFIG_MIN_LEVEL_FOR_SUBS = 76

# True:  Show 3rd Class trasfer to choose. False: Show 2nd Class trasfer to choose.
CONFIG_HTML_SHOW_3RD_TRANSFER_CLASS = False

#Disallow add subclasses if the user's class transfer level is lower than bellow option.
CONFIG_CLASS_TRANSFER_LEVEL = 2

# True: The user level will chang after add a subclass. False: User level won't change after add a subclass. Default: True
CONFIG_ENABLE_DECREASE_LEVEL = True

#Level at which the character will be changed after add a subclass. Default: 40
CONFIG_LEVEL_AFTER_ADD_A_SUBCLASS = 40

#-------------------------------------------------------------------------------------------------------------------------------------

def HTMLA(st): 
    xsubsamount=SUB_COUNT(DATA(st))
    if xsubsamount >= 0 :
        HTML = StringIO()
        HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
        HTML.write("<font color=\"303030\">%s</font>" % AIO())
        HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
        HTML.write("<table width=250 border=0 bgcolor=444444>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Before taking any action, make sure you</font></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   are using the Main Class or the proper</font></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Subclass, which requested the changes.</font></td></tr>")
        if CONFIG_ENABLE_FEE_FOR_SUBCLASS:
            HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Besides you need the required items.</font></td></tr>")
            HTML.write("<tr><td><br></td></tr>")
            if xsubsamount < CONFIG_MAX_SUBS_AMOUNT and CONFIG_ADD_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Choose Sub: <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
            if CONFIG_DELETE_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Delete Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_DELETE_ITEM_AMOUNT,ITEM_NAME(CONFIG_DELETE_ITEM_REQUIRED)))
            if CONFIG_SWITCH_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Switch Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_SWITCH_ITEM_AMOUNT,ITEM_NAME(CONFIG_SWITCH_ITEM_REQUIRED)))
        HTML.write("<tr><td></td></tr></table><br>")
        HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
        HTML.write("<tr><td width=90 align=\"center\"><table width=90 border=0 bgcolor=444444><tr><td width=90 align=\"center\"><table width=85 border=0 bgcolor=444444>")
        if xsubsamount < CONFIG_MAX_SUBS_AMOUNT :
            HTML.write("<tr><td><button value=\"Choose Sub\" action=\"bypass -h Quest %s gethtml 1 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("<tr><td><button value=\"Delete Sub\" action=\"bypass -h Quest %s gethtml 3 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("<tr><td><button value=\"Switch Sub\" action=\"bypass -h Quest %s gethtml 2 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("</table></td></tr></table></td></tr>")
        HTML.write("</center></body></html>")
        return HTML.getvalue()
    else:
        if st.getQuestItemsCount(CONFIG_ADD_ITEM_REQUIRED) < CONFIG_ADD_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"0","0")
        if st.player.getRace().ordinal() == 5 and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL: return HTMLE(st,"5")
        if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE: 
            if not CONFIG_ALLOW_MUTANT_RETAIL and st.player.isSubClassActive(): return HTMLE(st,`st.player.getTemplate().race.ordinal()`)
            else: return HTMLE(st,`st.player.getRace().ordinal()`)
        else: return HTMLB(st)

def HTMLB(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a Race</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    HTML.write("<tr><td><button value=\"Human\" action=\"bypass -h Quest %s escraza 0 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Elf\" action=\"bypass -h Quest %s escraza 1 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Dark Elf\" action=\"bypass -h Quest %s escraza 2 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Orc\" action=\"bypass -h Quest %s escraza 3 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Dwarf\" action=\"bypass -h Quest %s escraza 4 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    if CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE or st.player.getRace().ordinal() == 5:
        HTML.write("<tr><td><button value=\"Kamael\" action=\"bypass -h Quest %s escraza 5 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLC(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a subclass to Switch</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    info = DATA(st); j=-1
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and info[0] != i: 
            j+=1
            if CONFIG_MAX_SUBS_AMOUNT > j:
                HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s switch %s %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(CLASS_NAME(`info[i+2]`),QI,info[i+2],i))
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLD(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose the class you want to delete</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=100 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    info = DATA(st)
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and (i != 0 or CONFIG_ALLOW_DELETE_MAIN_CLASS):
            HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s confirmdelete %s %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(CLASS_NAME(`info[i+2]`),QI,info[i+2],i))
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLE(st,case):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write(RACE_HTML(st,case))
    HTML.write("</center></body></html>")
    return HTML.getvalue()
    
def HTMLF(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br></td></tr>")                                                                                                                                                                                            
    HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">This option can be seen by GMs only and it<br1>allow to update any changes made in the<br1>script. You can disable this option in<br1>the settings section within the Script.<br><font color=\"LEVEL\">Do you want to update the SCRIPT?</font></font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s reloadscript 1 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)
    HTML.write("<button value=\"No\" action=\"bypass -h Quest %s reloadscript 0 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)            
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def RACE_HTML(st,race): 
    HTML = StringIO()
    HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">Which subclass do you wish to add?</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    list = FORBBIDEN_LIST(st,None)
    num = 0
    for cId in ClassId.values():
        if cId.level() == 3 and `cId.getRace().ordinal()` == race and cId.getId() not in list and cId.getParent().getId() not in list:
            num = 1
            HTML.write("<button value=\"%s\" action=\"bypass -h Quest %s confirmadd %s 0\" width=150 height=30 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (CLASS_NAME(PARENT_CLASS(cId.getId())),QI,cId.getId()))
    if num == 0:
        HTML = StringIO()
        HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">There are no available subclasses<br1>for this race</font></td></tr>")
        HTML.write("<tr><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    TEXT = HTML.getvalue()
    HTML.close()
    return TEXT

def CONFIRM_HTML(st,case,case1,case2,case3):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Do you really want to %s the<br1><font color=\"LEVEL\">%s</font>  subclass?</td></tr>" % (case,CLASS_NAME(case2)))
    HTML.write("<tr><td><br><br></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s %s %s %s\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case,case2,case3))
    HTML.write("<button value=\"No\" action=\"bypass -h Quest %s gethtml %s 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case1))
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def COMPLETE_HTML(st,case,case2) :
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    if case == None: HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Congratulations</font><br></td></tr>")
    else: 
        HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">The class bellow has been deleted:</font></td></tr>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">%s</font></td></tr>" % "+CLASS_NAME(case)+")
        HTML.write("<tr><td><br><br></td></tr>")
    if case == None or `st.player.getClassId().getId()` != case2:
        HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Your class has been changed to:</font></td></tr>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">%s</font></td></tr>" % st.player.getTemplate().className)
        HTML.write("<tr><td><br><br></td></tr>")
    HTML.write("</table><br>")
    if CONFIG_ENABLE_RESTART_PROTECTION:
        HTML.write("<table width=250 border=0 bgcolor=444444>")
        HTML.write("<tr><td align=\"center\"><font color=\"00FF00\">You will be automatically restarted<br1>in %s seconds.</font></td></tr></table><br>" % CONFIG_RESTART_TIME_PROTECTION)
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def ERRORS_HTML(st,case,id) :
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"FF5500\">Error</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1><br>")
    HTML.write("<table width=220 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    if case == "0": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't meet this NPC's minimum<br>required items. Come back with:<br><font color=\"LEVEL\">%s %s.</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
    elif case == "1": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_SWITCH_ITEM_AMOUNT,ITEM_NAME(CONFIG_SWITCH_ITEM_REQUIRED)))
    elif case == "2": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
    elif case == "3": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_DELETE_ITEM_AMOUNT,ITEM_NAME(CONFIG_DELETE_ITEM_REQUIRED)))
    elif case == "4": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br>subclass at this time.<br>Your level must be <font color=\"LEVEL\">%s or above.</font></td></tr>" % CONFIG_MIN_LEVEL_FOR_SUBS)
    elif case == "5": 
        if CONFIG_CLASS_TRANSFER_LEVEL >= 3: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">Level 3</font></td></tr>")
        elif CONFIG_CLASS_TRANSFER_LEVEL == 2: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">2nd or higher</font></td></tr>")
        else: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">1st or higher</font></td></tr>")
    elif case == "6": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br>subclass at this time.<br>You must be a <font color=\"LEVEL\">Noblesse</font></td></tr>")
    elif case == "7": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to this class:<br><font color=\"LEVEL\">%s</font><br>Forbbiden Class.</td></tr>" % "+CLASS_NAME(id)+")
    elif case == "8": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not add the class bellow:<br><font color=\"LEVEL\">%s</font><br>Forbbiden Class.</td></tr>" % "+CLASS_NAME(id)+")
    elif case == "9": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not delete your <font color=\"LEVEL\">Main Class</font><br></td></tr>")
    elif case == "10": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to the <font color=\"LEVEL\">Same Class</font><br></td></tr>")
    elif case == "11": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">The action has been stopped.<br><font color=\"LEVEL\">Wrong Slot</font><br></td></tr>")
    elif case == "12": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and<br>switch to the proper class first.<br></td></tr>" % "+CLASS_NAME(id)+")
    elif case == "13": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not delete the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and<br>switch to the proper class first.<br></td></tr>" % "+CLASS_NAME(id)+")
    elif case == "14": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not add the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and switch<br>to the proper class first.</td></tr>" % "+CLASS_NAME(id)+")
    else: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">The action has been stopped.<br><font color=\"LEVEL\">Unknow Bypass</font><br></td></tr>")
    HTML.write("<tr><td><br><br></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1>")
    HTML.write("</center></body></html>")
    if CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
    st.playSound("ItemSound3.sys_shortage")
    return HTML.getvalue()

def RELOAD_CONFIG(st) :
    try:
        if QuestManager.getInstance().reload(QuestId): st.player.sendMessage("The script and settings have been reloaded successfully.")
        else: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
    except: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
    return HTMLA(st)

def BLOCK_TIME(st,time):
    endtime = int(System.currentTimeMillis()/1000) + time
    st.set("time",`endtime`)
    st.getPlayer().sendPacket(SetupGauge(3, time * 1000 + 300))
    return True

def ALLOW_ACTION(st):
	if st.player.getActiveEnchantItem() != None or st.player.getActiveEnchantAttrItem() != None:
		st.player.sendMessage("Cannot add subclass while Enchanting")
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	st.player.getInventory().updateDatabase()
	if st.player.getPrivateStoreType() != 0:
		st.player.sendMessage("Cannot add subclass while trading")
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	if st.player.isLocked():
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	return True

def DATA(st):
    con=L2DatabaseFactory.getInstance().getConnection()
    act = con.prepareStatement("SELECT * FROM subclass_list WHERE player_id=%s" % STRING_PART(st))
    rs=act.executeQuery()
    val=[]
    if rs.next(): 
        try:
            val.append(rs.getInt("currentsub"))
            val.append(rs.getInt("sub_index"))
            for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                try : id = int(rs.getString("subclassid%s" % i))
                except : id = -1
                val.append(id)
        except:
            val=[]
            for i in range(CONFIG_MAX_SUBS_IN_DB + 3):
                val.append(-1)
    else:
        val=[]
        for i in range(CONFIG_MAX_SUBS_IN_DB + 3):
            val.append(-1)
    try : 
        rs.close()
        act.close()
        con.close()
    except: pass
    return val

def FORBBIDEN_LIST(st,data):
    val = CONFIG_FORBBIDEN_SUBCLASSES
    val.append(st.player.getClassId().getId())
    if data == None: data = DATA(st)
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if data[i+2] != -1:
            val.append(data[i+2])
    if not CONFIG_ALLOW_SUBCLASS_DUPLICATION:
        if st.player.getBaseClass() not in val:
            val.append(st.player.getBaseClass())
        for subClass in st.player.getSubClasses().values():
            val.append(subClass.getClassId())
    return val

def CLASS_LIST(st,data):
    if data == None or len(data) < CONFIG_MAX_SUBS_IN_DB + 3:
        data = DATA(st)
    val=[]
    j=-1
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(data[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL):
            j+=1
            if CONFIG_MAX_SUBS_AMOUNT >= j:
                val.append(ClassId.values()[data[i+2]])
    return val

def RACE_ALLOWED(st,list,data):
    if st.player.getRace().ordinal() in list:
        return False
    if st.player.getClassId().getRace().ordinal() in list:
        return False
    for cId in CLASS_LIST(st,data):
        if cId.getRace().ordinal() in list:
            return False
    return True

def CLASS_ALLOWED(st,id,id2,data):
    c2 = CLASS_ID(id2); pci = st.player.getClassId()
    if c2 == None or c2.equalsOrChildOf(pci) or pci.equalsOrChildOf(c2): 
        return False
    if id != "switch":
        c1 = CLASS_ID(id)
        if c1 == None or not c2.equalsOrChildOf(c1): 
            return False
        list = FORBBIDEN_LIST(st,data)
        if c1.getId() in list or c2.getId() in list:
            return False
        if not CONFIG_ALLOW_SUBCLASS_DUPLICATION:
            if pci.getId() != st.player.getBaseClass():
                baseId = ClassId.values()[st.player.getBaseClass()]
                if c2.equalsOrChildOf(baseId): 
                    return False
            for subClass in st.player.getSubClasses().values():
                subId = ClassId.values()[subClass.getClassId()]
                if c2.equalsOrChildOf(subId): 
                    return False
    if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_ALLOW_MUTANT_RETAIL:
        if st.player.isSubClassActive() and c2.getRace() != pci.getRace(): return False
        if not st.player.isSubClassActive() and c2.getRace() != st.player.getRace(): return False     
    if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and CONFIG_ALLOW_MUTANT_RETAIL and c2.getRace() != st.player.getRace(): return False
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE  and st.player.getRace().ordinal() != 5 and c2.getRace().ordinal() == 5: return False
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL  and st.player.getRace().ordinal() == 5 and c2.getRace().ordinal() != 5: return False 
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_ALLOW_DELF_AND_ELF_EXCHANGE_SUBS:
        if c2.getRace().ordinal() == 1 and not RACE_ALLOWED(st,[2],data): return False
        if c2.getRace().ordinal() == 2 and not RACE_ALLOWED(st,[1],data): return False
    return True

def SUB_COUNT(data):
    j=-1;k=0
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if data[i] == -1: k+=1
        if CID_LEVEL(data[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL): j+=1
    if j==-1 and k <= CONFIG_MAX_SUBS_IN_DB: return -2
    return j

def SLOT_ALLOWED(data,slot):
    if not slot.isdigit() or int(slot) < 0 or int(slot) > CONFIG_MAX_SUBS_IN_DB: return False
    return CID_LEVEL(data[int(slot)+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL)

def CLASS_NAME(case):
    val = "Unknow Class"
    try: val = CharTemplateTable.getInstance().getClassNameById(int(case))
    except: val = "Unknow Class"
    return val



def ITEM_NAME(case):
    try: val =ItemTable.getInstance().createDummyItem(case).getItemName()
    except: val = "No Name"
    return val

def PARENT_CLASS(case):
    val=`case`
    if not CONFIG_HTML_SHOW_3RD_TRANSFER_CLASS: 
        if CID_LEVEL(val) > 0:
            val = `ClassId.values()[case].getParent().getId()`
        else :  val = "-1"
    return val

def CID_LEVEL(id):
    try:
        if not id.isdigit(): return -1
        id = int(id)
    except:pass
    for classid in ClassId.values():
        if classid.getId() == id:
            return classid.level()
    return -1
    
def CLASS_ID(id):
    try:
        if not id.isdigit(): return None
        id = int(id)
    except:pass
    for classid in ClassId.values():
        if classid.getId() == id: return classid
    return None

def MAX_LEVEL(skill):
    if  skill == None: return 1
    maxLvl = SkillTable.getInstance().getMaxLevel(skill.getId())
    return Math.min(skill.getLevel(), maxLvl)

def STRING_PART(st):
    if st == None: return "0 LIMIT 1"
    val= "%s LIMIT 1" % st.getPlayer().getObjectId()
    if CONFIG_ALLOW_MULT_SUBS:
        val= "%s AND sub_index=%s LIMIT 1" % (st.player.getObjectId(),st.player.getClassIndex())
    return val

def AIO():
    xe="l";xf="e";xg="n";xa="B";xb="y";xc=" ";xd="A"; val= "%(xa)s%(xb)s%(xc)s%(xd)s%(xe)s%(xe)s%(xf)s%(xg)s" % locals()
    return val

def RESET_SKILLS(st):
    player= st.player
    try:
        for s in player.getAllSkills():
            if not SkillTreesData.getInstance().isSkillAllowed(player,s):
                delete = True
                for Ids in CLASS_LIST(st,None):
                    if player.getClassId() != Ids:
                        if SkillTreesData.getInstance().getTransferSkill(s.getId(), s.getLevel(), Ids) != None: delete = False
                        elif SkillTreesData.getInstance().getClassSkill(s.getId(),MAX_LEVEL(s),Ids) != None: delete = False
                if delete : player.removeSkill(s)
    except: player.sendMessage("Error could not check char skills")
    if not CONFIG_ENABLE_RESTART_PROTECTION:
        player.regiveTemporarySkills()
    return 0

class Quest (JQuest) :

    def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
    
    def onAdvEvent (self,event,npc,player):
        try: st = player.getQuestState(QI)
        except: return    
        split = event.split(" ")
        event = split[0]
        event1 = split[1]
        event2 = split[2]
        
        if event == "reloadscript":
            if event1 == "1": return RELOAD_CONFIG(st)
            if event1 == "0": return HTMLA(st)
        
        elif event == "dorestart":
            if player.isTeleporting():
                player.abortCast()
                player.setIsTeleporting(false)
            if player.getActiveRequester() != None:
                player.getActiveRequester().onTradeCancel(player)
                player.onTradeCancel(player.getActiveRequester())
            if player.isFlying():
                player.removeSkill(SkillTable.getInstance().getInfo(4289, 1))
                st.exitQuest(1)
            client = player.getClient()
            player.setClient(None)
            player.deleteMe()
            if client != None:
                client.setActiveChar(None)
                client.setState(GameClientState.AUTHED)
                client.sendPacket(RestartResponse.valueOf(True))
                cl = CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1)
                client.sendPacket(cl)
                client.setCharSelection(cl.getCharInfo())
            return

        elif CONFIG_ENABLE_FLOOD_PROTECTION and int(System.currentTimeMillis()/1000) <= st.getInt("time"):
            st.playSound("ItemSound3.sys_shortage")        
            return
            
        elif event == "escraza": return HTMLE(st,event1)

        elif event.startswith("confirm"):
            sevent = event.replace("confirm","")
            if sevent == "add" and CID_LEVEL(event1) == 3: return CONFIRM_HTML(st,sevent,"1",PARENT_CLASS(int(event1)),event1)
            elif sevent == "delete" and event2.isdigit(): return CONFIRM_HTML(st,sevent,"3",event1,event2)
            else: return ERRORS_HTML(st,"","")

        elif event == "gethtml":
            if event1 == "1": 
                if player.getRace().ordinal() == 5 and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL: return HTMLE(st,"5")
                if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE: 
                    if not CONFIG_ALLOW_MUTANT_RETAIL and player.isSubClassActive(): return HTMLE(st,`player.getTemplate().race.ordinal()`)
                    else: return HTMLE(st,`player.getRace().ordinal()`)
                else: return HTMLB(st)
            elif event1 == "2": return HTMLC(st)
            elif event1 == "3": return HTMLD(st)
            return

        elif event == "switch":
            info = DATA(st)
            if not SLOT_ALLOWED(info,event2): return ERRORS_HTML(st,"11","0")
            elif info[1] != player.getClassIndex(): return ERRORS_HTML(st,"12",event1)
            elif not ALLOW_ACTION(st): return
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif st.getQuestItemsCount(CONFIG_SWITCH_ITEM_REQUIRED) < CONFIG_SWITCH_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"1","0")
            elif event2 == `info[0]`: return ERRORS_HTML(st,"10","0")
            elif not CLASS_ALLOWED(st,"switch",event1,info): return ERRORS_HTML(st,"7",event1)
            else:
                conn=L2DatabaseFactory.getInstance().getConnection()
                pcid = player.getClassId()
                upd=conn.prepareStatement("UPDATE subclass_list SET currentsub=%s, subclassid%s=%s WHERE player_id=%s" % (event2,info[0],pcid.getId(),STRING_PART(st)))
                try :
                    upd.executeUpdate()
                    upd.close()
                    conn.close()
                except :
                    try : conn.close()
                    except : pass
                if RESET_SKILLS(st) == 1: pass
                temp = info[int(event2)+2]
                player.setTarget(player)
                player.setClassId(temp)
                if not player.isSubClassActive(): player.setBaseClass(temp)
                if not CONFIG_ENABLE_RESTART_PROTECTION:
                    player.store()
                    player.broadcastUserInfo()
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_SWITCH_ITEM_REQUIRED,CONFIG_SWITCH_ITEM_AMOUNT)
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,None,`pcid.getId()`)

        elif event == "delete":
            info = DATA(st)
            if not ALLOW_ACTION(st): return
            elif not SLOT_ALLOWED(info,event2): return ERRORS_HTML(st,"11","0")
            elif info[1]!= player.getClassIndex(): return ERRORS_HTML(st,"13",event1)
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif st.getQuestItemsCount(CONFIG_DELETE_ITEM_REQUIRED) < CONFIG_DELETE_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"3","0")
            elif event2 == "0" and not CONFIG_ALLOW_DELETE_MAIN_CLASS: return ERRORS_HTML(st,"9","0")    
            else:
                conn=L2DatabaseFactory.getInstance().getConnection()
                pcid = player.getClassId()
                upd=conn.prepareStatement("UPDATE subclass_list SET subclassid%s=%s WHERE player_id=%s" % (info[0],pcid.getId(),STRING_PART(st)))
                try :
                    upd.executeUpdate()
                    upd.close()
                    conn.close()
                except :
                    try : conn.close()
                    except : pass
                if event2 == `info[0]` and SUB_COUNT(info) > 0:
                    j=0
                    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and j == 0 and i != info[0]: 
                            j+=1; temp = info[i+2]; info[0] = i
                    player.setTarget(player)
                    player.setClassId(temp)
                    if not player.isSubClassActive(): player.setBaseClass(temp)
                    player.sendMessage("Your class has changed to " + player.getTemplate().className)
                    if not CONFIG_ENABLE_RESTART_PROTECTION:
                        player.store()
                        player.broadcastUserInfo()
                con=L2DatabaseFactory.getInstance().getConnection()
                if SUB_COUNT(info) <= 1: rem=con.prepareStatement("DELETE FROM subclass_list WHERE player_id=%s" % STRING_PART(st))
                else: rem = con.prepareStatement("UPDATE subclass_list SET subclassid%s=-1 ,currentsub=%s WHERE player_id=%s" % (event2,info[0],STRING_PART(st)))
                try : rem.executeUpdate()
                except : pass
                try : 
                    rem.close()
                    con.close()
                except : pass
                if RESET_SKILLS(st) == 1: pass
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_DELETE_ITEM_REQUIRED,CONFIG_DELETE_ITEM_AMOUNT)
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,event1,`pcid.getId()`)

        elif event == "add":
            info = DATA(st)
            if info[1] != player.getClassIndex() and SUB_COUNT(info) >= 0: return ERRORS_HTML(st,"14",event1)
            elif not ALLOW_ACTION(st): return
            elif CONFIG_ALLOW_SUBS_FOR_NOBLESSE_ONLY and not player.isNoble(): return ERRORS_HTML(st,"6","0")
            elif st.getQuestItemsCount(CONFIG_ADD_ITEM_REQUIRED) < CONFIG_ADD_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"2","0")
            elif st.getPlayer().getLevel() < CONFIG_MIN_LEVEL_FOR_SUBS: return ERRORS_HTML(st,"4","0")
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif not CLASS_ALLOWED(st,event1,event2,info): return ERRORS_HTML(st,"8",event1)
            else:
                oldid = `player.getClassId().getId()`
                con=L2DatabaseFactory.getInstance().getConnection()
                if SUB_COUNT(info) == -1 :
                    ins = con.prepareStatement("INSERT INTO subclass_list (player_id,currentsub,sub_index,subclassid0,subclassid1) VALUES (?,?,?,?,?)")
                    ins.setString(1, `player.getObjectId()`)
                    ins.setString(2, "1")
                    ins.setString(3, `player.getClassIndex()`)
                    ins.setString(4, oldid)
                    ins.setString(5, event1)
                else:
                    temp6 = "-1"; j=0
                    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                        if CID_LEVEL(info[i+2]) < Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and temp6 == "-1" and j==0:
                            j+=1; temp6 = `i`
                        if info[0] < 0 or info[0] > CONFIG_MAX_SUBS_IN_DB: info[0] = 0
                    ins = con.prepareStatement("UPDATE subclass_list SET currentsub=%s, subclassid%s=%s, subclassid%s=%s WHERE player_id=%s" % (temp6,temp6,event1,info[0],oldid,STRING_PART(st)))
                try :
                    ins.executeUpdate()
                    ins.close()
                    con.close()
                except : pass
                if RESET_SKILLS(st) == 1: pass
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_ADD_ITEM_REQUIRED,CONFIG_ADD_ITEM_AMOUNT)
                if CONFIG_ENABLE_DECREASE_LEVEL:
                    pXp = player.getExp()
                    tXp = ExperienceTable.getInstance().getExpForLevel(CONFIG_LEVEL_AFTER_ADD_A_SUBCLASS)
                    if pXp > tXp: player.removeExpAndSp(pXp - tXp, 0)
                player.setTarget(player)
                player.setClassId(int(event1))
                if not player.isSubClassActive(): player.setBaseClass(int(event1))
                if not CONFIG_ENABLE_RESTART_PROTECTION:
                    player.store()
                    player.broadcastUserInfo()
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,None,oldid)
        else: return ERRORS_HTML(st,"","")
    def onFirstTalk (self,npc,player):
		st = player.getQuestState(QI)
		if not st : st = self.newQuestState(player)
		if player.isGM(): 
			if CONFIG_SHOW_RELOAD_PANEL == True: return HTMLF(st)
		if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):return HTMLA(st)
		else:
			st.playSound("ItemSound3.sys_shortage")		
			return

QUEST = Quest(QuestId,QI,QuestDesc)

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

si borramos unas líneas nos muestra las id de las classes

def CLASS_NAME(case):

    return case
  • 5 years later...
Posted
On 2/10/2015 at 5:16 AM, miluno_yo22582 said:

 esta es la coneccion que da error


def CLASS_NAME(case):
    val = "Unknow Class"
    try: val = CharTemplateTable.getInstance().getClassNameById(int(case))
    except: val = "Unknow Class"
    return val

aca el npc


import sys

from java.sql import Connection
from java.sql import ResultSet
from java.sql import SQLException
from java.sql import Statement
from java.util import HashMap
from java.util import Map
from java.util.logging import Level
from java.util.logging import Logger

from java.lang import StringBuilder
from java.lang import Object
from java.lang import Class
from java.lang import Throwable

from java.lang                                      import Math
from java.lang                                      import System
from cStringIO                                      import StringIO
from com.l2jserver                                  import Config
from com.l2jserver                                  import L2DatabaseFactory
from com.l2jserver.gameserver.model                 import StatsSet
from com.l2jserver.gameserver.model.base            import ClassId
from com.l2jserver.gameserver.model.base 	        import Race
from com.l2jserver.gameserver.model.quest           import State
from com.l2jserver.gameserver.model.quest           import QuestState
from com.l2jserver.gameserver.model.quest.jython    import QuestJython as JQuest
from com.l2jserver.gameserver.datatables            import ItemTable
from com.l2jserver.gameserver.datatables            import SkillTable
from com.l2jserver.gameserver.datatables            import SkillTreesData
from com.l2jserver.gameserver.datatables            import ExperienceTable
from com.l2jserver.gameserver.datatables            import CharTemplateTable
from com.l2jserver.gameserver.datatables            import ClassListData
from com.l2jserver.gameserver.instancemanager       import QuestManager
from com.l2jserver.gameserver.taskmanager           import AttackStanceTaskManager
from com.l2jserver.gameserver.network.L2GameClient  import GameClientState
from com.l2jserver.gameserver.network.serverpackets import SetupGauge
from com.l2jserver.gameserver.network.serverpackets import ActionFailed
from com.l2jserver.gameserver.network.serverpackets import RestartResponse
from com.l2jserver.gameserver.network.serverpackets import CharSelectionInfo
from com.l2jserver.gameserver.model.actor.templates import L2PcTemplate



NPC       = [1234]
QuestId   = 1234
QuestName = "SubclassNpc"
QuestDesc = "custom"
QI        = "%s_%s" % (QuestId,QuestName)


print "============================="
print "INFO LOADED SUBCLASS MANAGER"
print "============================="

#-------------------------------------------------------------------------------------------------------------------------------------
# SETTINGS
#-------------------------------------------------------------------------------------------------------------------------------------
#For more than 3 subclasses, you must increase the variable number into the SQL and add to the database. 
#inside the sql you will find some variables named SubclassidX. Just change the "X" increasing the number. 
#This value shouldn't be changed if you don't want to increase the subclasses number beyond 3. 
#Increase or decrease the "CONFIG_MAX_SUBS_IN_DB" value without make these changes, will cause errors. Be carefull!.
CONFIG_MAX_SUBS_IN_DB = 3

# Subclasses number that can be added. Must be less than or equal to "CONFIG_MAX_SUBS_IN_DB".
CONFIG_MAX_SUBS_AMOUNT = 3

#True, allows reloading the configuration script from the game, without restarting the server (for GMs only). False, disables it.
CONFIG_SHOW_RELOAD_PANEL = True

# True enable restart protection. Recommended Default: True
CONFIG_ENABLE_RESTART_PROTECTION = True

# Delay time in seconds before being restarted automatically. Not recommended a number bellow to 5 seconds. Default: 5 seconds
CONFIG_RESTART_TIME_PROTECTION = 10

# True: The user must wait a while before take any action. Default: True
# False: The user can do any action without time constraints. Not recommended
CONFIG_ENABLE_FLOOD_PROTECTION = True

#Blocking time in seconds before take any action.
CONFIG_FLOOD_PROTECTION_TIME = 20

#Subclass list that won't be able to choose. Default: [57,51] Overlord and Warsmith
CONFIG_FORBBIDEN_SUBCLASSES = []

# True, allows add stackable subclasses in every original game subclass (Mainclass and every retails).
# False, allows add stackable subclasses in only one original game subclass or main class
CONFIG_ALLOW_MULT_SUBS = False

# True, allows any stackable subclass. False, allows add your own race's subclasses only.
CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = True

#This option work if "CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = False", Also you need to be using a original game subclass (Retail) to get available this.
#True, allow add a subclass with the same main class's race. False, allow add a subclass with the same Retail's race.
CONFIG_ALLOW_MUTANT_RETAIL = True

#The next three options work if "CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE = True" only.
#True, allows everybody add Kamael subclass. False otherwise.
CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE = True

#True, allows Dark Elf class do elf subclass, and Elf class do Dark Elf Subclass. False otherwise.
CONFIG_ALLOW_DELF_AND_ELF_EXCHANGE_SUBS = True

#True, allows Kamaels add any subclass. False, allows Kamaels to add their own race only.
CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL = True

#True, allows delete the main class or any subclass added. False, allow to delete added subclasses only. Default: False
CONFIG_ALLOW_DELETE_MAIN_CLASS = False

#Allow to add subclasses already used in the original game subclasses (Retail). Default: False
CONFIG_ALLOW_SUBCLASS_DUPLICATION = False

#True, allows add subsclasses if the character is a Noblesse only. False, otherwise. Default: False
CONFIG_ALLOW_SUBS_FOR_NOBLESSE_ONLY = False

#True, allow to add subclass or any other actions if you have the required items only. False, otherwise
CONFIG_ENABLE_FEE_FOR_SUBCLASS = False

#Required Item to switch between the subclasses. Default: 57 (Adena)
#Required items number.
CONFIG_SWITCH_ITEM_REQUIRED = 57
CONFIG_SWITCH_ITEM_AMOUNT = 1000000

#Required Item to add a subclass.
#Required items number.
CONFIG_ADD_ITEM_REQUIRED = 3481
CONFIG_ADD_ITEM_AMOUNT = 100

#Required Item to delete subclasses.
#Required items number.
CONFIG_DELETE_ITEM_REQUIRED = 3481
CONFIG_DELETE_ITEM_AMOUNT = 10

# Minimum Level to add a subclass. Default: 76
CONFIG_MIN_LEVEL_FOR_SUBS = 76

# True:  Show 3rd Class trasfer to choose. False: Show 2nd Class trasfer to choose.
CONFIG_HTML_SHOW_3RD_TRANSFER_CLASS = False

#Disallow add subclasses if the user's class transfer level is lower than bellow option.
CONFIG_CLASS_TRANSFER_LEVEL = 2

# True: The user level will chang after add a subclass. False: User level won't change after add a subclass. Default: True
CONFIG_ENABLE_DECREASE_LEVEL = True

#Level at which the character will be changed after add a subclass. Default: 40
CONFIG_LEVEL_AFTER_ADD_A_SUBCLASS = 40

#-------------------------------------------------------------------------------------------------------------------------------------

def HTMLA(st): 
    xsubsamount=SUB_COUNT(DATA(st))
    if xsubsamount >= 0 :
        HTML = StringIO()
        HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
        HTML.write("<font color=\"303030\">%s</font>" % AIO())
        HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
        HTML.write("<table width=250 border=0 bgcolor=444444>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Before taking any action, make sure you</font></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   are using the Main Class or the proper</font></td></tr>")
        HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Subclass, which requested the changes.</font></td></tr>")
        if CONFIG_ENABLE_FEE_FOR_SUBCLASS:
            HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Besides you need the required items.</font></td></tr>")
            HTML.write("<tr><td><br></td></tr>")
            if xsubsamount < CONFIG_MAX_SUBS_AMOUNT and CONFIG_ADD_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Choose Sub: <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
            if CONFIG_DELETE_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Delete Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_DELETE_ITEM_AMOUNT,ITEM_NAME(CONFIG_DELETE_ITEM_REQUIRED)))
            if CONFIG_SWITCH_ITEM_AMOUNT >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Switch Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_SWITCH_ITEM_AMOUNT,ITEM_NAME(CONFIG_SWITCH_ITEM_REQUIRED)))
        HTML.write("<tr><td></td></tr></table><br>")
        HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
        HTML.write("<tr><td width=90 align=\"center\"><table width=90 border=0 bgcolor=444444><tr><td width=90 align=\"center\"><table width=85 border=0 bgcolor=444444>")
        if xsubsamount < CONFIG_MAX_SUBS_AMOUNT :
            HTML.write("<tr><td><button value=\"Choose Sub\" action=\"bypass -h Quest %s gethtml 1 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("<tr><td><button value=\"Delete Sub\" action=\"bypass -h Quest %s gethtml 3 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("<tr><td><button value=\"Switch Sub\" action=\"bypass -h Quest %s gethtml 2 0\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
        HTML.write("</table></td></tr></table></td></tr>")
        HTML.write("</center></body></html>")
        return HTML.getvalue()
    else:
        if st.getQuestItemsCount(CONFIG_ADD_ITEM_REQUIRED) < CONFIG_ADD_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"0","0")
        if st.player.getRace().ordinal() == 5 and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL: return HTMLE(st,"5")
        if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE: 
            if not CONFIG_ALLOW_MUTANT_RETAIL and st.player.isSubClassActive(): return HTMLE(st,`st.player.getTemplate().race.ordinal()`)
            else: return HTMLE(st,`st.player.getRace().ordinal()`)
        else: return HTMLB(st)

def HTMLB(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a Race</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    HTML.write("<tr><td><button value=\"Human\" action=\"bypass -h Quest %s escraza 0 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Elf\" action=\"bypass -h Quest %s escraza 1 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Dark Elf\" action=\"bypass -h Quest %s escraza 2 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Orc\" action=\"bypass -h Quest %s escraza 3 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("<tr><td><button value=\"Dwarf\" action=\"bypass -h Quest %s escraza 4 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    if CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE or st.player.getRace().ordinal() == 5:
        HTML.write("<tr><td><button value=\"Kamael\" action=\"bypass -h Quest %s escraza 5 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLC(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a subclass to Switch</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    info = DATA(st); j=-1
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and info[0] != i: 
            j+=1
            if CONFIG_MAX_SUBS_AMOUNT > j:
                HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s switch %s %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(CLASS_NAME(`info[i+2]`),QI,info[i+2],i))
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLD(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose the class you want to delete</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=100 align=\"center\"><table width=105 border=0 bgcolor=444444>")
    info = DATA(st)
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and (i != 0 or CONFIG_ALLOW_DELETE_MAIN_CLASS):
            HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s confirmdelete %s %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(CLASS_NAME(`info[i+2]`),QI,info[i+2],i))
    HTML.write("</table></td></tr></table></td></tr>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def HTMLE(st,case):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td></td></tr>")
    HTML.write(RACE_HTML(st,case))
    HTML.write("</center></body></html>")
    return HTML.getvalue()
    
def HTMLF(st):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br></td></tr>")                                                                                                                                                                                            
    HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">This option can be seen by GMs only and it<br1>allow to update any changes made in the<br1>script. You can disable this option in<br1>the settings section within the Script.<br><font color=\"LEVEL\">Do you want to update the SCRIPT?</font></font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s reloadscript 1 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)
    HTML.write("<button value=\"No\" action=\"bypass -h Quest %s reloadscript 0 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)            
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def RACE_HTML(st,race): 
    HTML = StringIO()
    HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">Which subclass do you wish to add?</font></td></tr>")
    HTML.write("<tr><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    list = FORBBIDEN_LIST(st,None)
    num = 0
    for cId in ClassId.values():
        if cId.level() == 3 and `cId.getRace().ordinal()` == race and cId.getId() not in list and cId.getParent().getId() not in list:
            num = 1
            HTML.write("<button value=\"%s\" action=\"bypass -h Quest %s confirmadd %s 0\" width=150 height=30 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (CLASS_NAME(PARENT_CLASS(cId.getId())),QI,cId.getId()))
    if num == 0:
        HTML = StringIO()
        HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">There are no available subclasses<br1>for this race</font></td></tr>")
        HTML.write("<tr><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    TEXT = HTML.getvalue()
    HTML.close()
    return TEXT

def CONFIRM_HTML(st,case,case1,case2,case3):
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Do you really want to %s the<br1><font color=\"LEVEL\">%s</font>  subclass?</td></tr>" % (case,CLASS_NAME(case2)))
    HTML.write("<tr><td><br><br></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
    HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s %s %s %s\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case,case2,case3))
    HTML.write("<button value=\"No\" action=\"bypass -h Quest %s gethtml %s 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case1))
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def COMPLETE_HTML(st,case,case2) :
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font>" % AIO())
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
    HTML.write("<table width=250 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    if case == None: HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Congratulations</font><br></td></tr>")
    else: 
        HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">The class bellow has been deleted:</font></td></tr>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">%s</font></td></tr>" % "+CLASS_NAME(case)+")
        HTML.write("<tr><td><br><br></td></tr>")
    if case == None or `st.player.getClassId().getId()` != case2:
        HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Your class has been changed to:</font></td></tr>")
        HTML.write("<tr><td></td></tr>")
        HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">%s</font></td></tr>" % st.player.getTemplate().className)
        HTML.write("<tr><td><br><br></td></tr>")
    HTML.write("</table><br>")
    if CONFIG_ENABLE_RESTART_PROTECTION:
        HTML.write("<table width=250 border=0 bgcolor=444444>")
        HTML.write("<tr><td align=\"center\"><font color=\"00FF00\">You will be automatically restarted<br1>in %s seconds.</font></td></tr></table><br>" % CONFIG_RESTART_TIME_PROTECTION)
    HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
    HTML.write("</center></body></html>")
    return HTML.getvalue()

def ERRORS_HTML(st,case,id) :
    HTML = StringIO()
    HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
    HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
    HTML.write("<table width=260 border=0 bgcolor=444444>")
    HTML.write("<tr><td align=\"center\"><font color=\"FF5500\">Error</font></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1><br>")
    HTML.write("<table width=220 border=0 bgcolor=444444>")
    HTML.write("<tr><td><br><br></td></tr>")
    if case == "0": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't meet this NPC's minimum<br>required items. Come back with:<br><font color=\"LEVEL\">%s %s.</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
    elif case == "1": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_SWITCH_ITEM_AMOUNT,ITEM_NAME(CONFIG_SWITCH_ITEM_REQUIRED)))
    elif case == "2": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_ADD_ITEM_AMOUNT,ITEM_NAME(CONFIG_ADD_ITEM_REQUIRED)))
    elif case == "3": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (CONFIG_DELETE_ITEM_AMOUNT,ITEM_NAME(CONFIG_DELETE_ITEM_REQUIRED)))
    elif case == "4": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br>subclass at this time.<br>Your level must be <font color=\"LEVEL\">%s or above.</font></td></tr>" % CONFIG_MIN_LEVEL_FOR_SUBS)
    elif case == "5": 
        if CONFIG_CLASS_TRANSFER_LEVEL >= 3: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">Level 3</font></td></tr>")
        elif CONFIG_CLASS_TRANSFER_LEVEL == 2: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">2nd or higher</font></td></tr>")
        else: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br>at this time. Your current ocupation<br>must be <font color=\"LEVEL\">1st or higher</font></td></tr>")
    elif case == "6": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br>subclass at this time.<br>You must be a <font color=\"LEVEL\">Noblesse</font></td></tr>")
    elif case == "7": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to this class:<br><font color=\"LEVEL\">%s</font><br>Forbbiden Class.</td></tr>" % "+CLASS_NAME(id)+")
    elif case == "8": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not add the class bellow:<br><font color=\"LEVEL\">%s</font><br>Forbbiden Class.</td></tr>" % "+CLASS_NAME(id)+")
    elif case == "9": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not delete your <font color=\"LEVEL\">Main Class</font><br></td></tr>")
    elif case == "10": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to the <font color=\"LEVEL\">Same Class</font><br></td></tr>")
    elif case == "11": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">The action has been stopped.<br><font color=\"LEVEL\">Wrong Slot</font><br></td></tr>")
    elif case == "12": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not switch to the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and<br>switch to the proper class first.<br></td></tr>" % "+CLASS_NAME(id)+")
    elif case == "13": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not delete the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and<br>switch to the proper class first.<br></td></tr>" % "+CLASS_NAME(id)+")
    elif case == "14": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can not add the class bellow:<br><font color=\"LEVEL\">%s</font><br>Talk to a Grand Master and switch<br>to the proper class first.</td></tr>" % "+CLASS_NAME(id)+")
    else: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">The action has been stopped.<br><font color=\"LEVEL\">Unknow Bypass</font><br></td></tr>")
    HTML.write("<tr><td><br><br></td></tr></table><br>")
    HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1>")
    HTML.write("</center></body></html>")
    if CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
    st.playSound("ItemSound3.sys_shortage")
    return HTML.getvalue()

def RELOAD_CONFIG(st) :
    try:
        if QuestManager.getInstance().reload(QuestId): st.player.sendMessage("The script and settings have been reloaded successfully.")
        else: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
    except: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
    return HTMLA(st)

def BLOCK_TIME(st,time):
    endtime = int(System.currentTimeMillis()/1000) + time
    st.set("time",`endtime`)
    st.getPlayer().sendPacket(SetupGauge(3, time * 1000 + 300))
    return True

def ALLOW_ACTION(st):
	if st.player.getActiveEnchantItem() != None or st.player.getActiveEnchantAttrItem() != None:
		st.player.sendMessage("Cannot add subclass while Enchanting")
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	st.player.getInventory().updateDatabase()
	if st.player.getPrivateStoreType() != 0:
		st.player.sendMessage("Cannot add subclass while trading")
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	if st.player.isLocked():
		st.playSound("ItemSound3.sys_shortage")
		st.player.sendPacket(ActionFailed.STATIC_PACKET)
		return False
	return True

def DATA(st):
    con=L2DatabaseFactory.getInstance().getConnection()
    act = con.prepareStatement("SELECT * FROM subclass_list WHERE player_id=%s" % STRING_PART(st))
    rs=act.executeQuery()
    val=[]
    if rs.next(): 
        try:
            val.append(rs.getInt("currentsub"))
            val.append(rs.getInt("sub_index"))
            for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                try : id = int(rs.getString("subclassid%s" % i))
                except : id = -1
                val.append(id)
        except:
            val=[]
            for i in range(CONFIG_MAX_SUBS_IN_DB + 3):
                val.append(-1)
    else:
        val=[]
        for i in range(CONFIG_MAX_SUBS_IN_DB + 3):
            val.append(-1)
    try : 
        rs.close()
        act.close()
        con.close()
    except: pass
    return val

def FORBBIDEN_LIST(st,data):
    val = CONFIG_FORBBIDEN_SUBCLASSES
    val.append(st.player.getClassId().getId())
    if data == None: data = DATA(st)
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if data[i+2] != -1:
            val.append(data[i+2])
    if not CONFIG_ALLOW_SUBCLASS_DUPLICATION:
        if st.player.getBaseClass() not in val:
            val.append(st.player.getBaseClass())
        for subClass in st.player.getSubClasses().values():
            val.append(subClass.getClassId())
    return val

def CLASS_LIST(st,data):
    if data == None or len(data) < CONFIG_MAX_SUBS_IN_DB + 3:
        data = DATA(st)
    val=[]
    j=-1
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if CID_LEVEL(data[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL):
            j+=1
            if CONFIG_MAX_SUBS_AMOUNT >= j:
                val.append(ClassId.values()[data[i+2]])
    return val

def RACE_ALLOWED(st,list,data):
    if st.player.getRace().ordinal() in list:
        return False
    if st.player.getClassId().getRace().ordinal() in list:
        return False
    for cId in CLASS_LIST(st,data):
        if cId.getRace().ordinal() in list:
            return False
    return True

def CLASS_ALLOWED(st,id,id2,data):
    c2 = CLASS_ID(id2); pci = st.player.getClassId()
    if c2 == None or c2.equalsOrChildOf(pci) or pci.equalsOrChildOf(c2): 
        return False
    if id != "switch":
        c1 = CLASS_ID(id)
        if c1 == None or not c2.equalsOrChildOf(c1): 
            return False
        list = FORBBIDEN_LIST(st,data)
        if c1.getId() in list or c2.getId() in list:
            return False
        if not CONFIG_ALLOW_SUBCLASS_DUPLICATION:
            if pci.getId() != st.player.getBaseClass():
                baseId = ClassId.values()[st.player.getBaseClass()]
                if c2.equalsOrChildOf(baseId): 
                    return False
            for subClass in st.player.getSubClasses().values():
                subId = ClassId.values()[subClass.getClassId()]
                if c2.equalsOrChildOf(subId): 
                    return False
    if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_ALLOW_MUTANT_RETAIL:
        if st.player.isSubClassActive() and c2.getRace() != pci.getRace(): return False
        if not st.player.isSubClassActive() and c2.getRace() != st.player.getRace(): return False     
    if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and CONFIG_ALLOW_MUTANT_RETAIL and c2.getRace() != st.player.getRace(): return False
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_UNLOCK_KAMAEL_FOR_EVERY_RACE  and st.player.getRace().ordinal() != 5 and c2.getRace().ordinal() == 5: return False
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL  and st.player.getRace().ordinal() == 5 and c2.getRace().ordinal() != 5: return False 
    if CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE and not CONFIG_ALLOW_DELF_AND_ELF_EXCHANGE_SUBS:
        if c2.getRace().ordinal() == 1 and not RACE_ALLOWED(st,[2],data): return False
        if c2.getRace().ordinal() == 2 and not RACE_ALLOWED(st,[1],data): return False
    return True

def SUB_COUNT(data):
    j=-1;k=0
    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
        if data[i] == -1: k+=1
        if CID_LEVEL(data[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL): j+=1
    if j==-1 and k <= CONFIG_MAX_SUBS_IN_DB: return -2
    return j

def SLOT_ALLOWED(data,slot):
    if not slot.isdigit() or int(slot) < 0 or int(slot) > CONFIG_MAX_SUBS_IN_DB: return False
    return CID_LEVEL(data[int(slot)+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL)

def CLASS_NAME(case):
    val = "Unknow Class"
    try: val = CharTemplateTable.getInstance().getClassNameById(int(case))
    except: val = "Unknow Class"
    return val



def ITEM_NAME(case):
    try: val =ItemTable.getInstance().createDummyItem(case).getItemName()
    except: val = "No Name"
    return val

def PARENT_CLASS(case):
    val=`case`
    if not CONFIG_HTML_SHOW_3RD_TRANSFER_CLASS: 
        if CID_LEVEL(val) > 0:
            val = `ClassId.values()[case].getParent().getId()`
        else :  val = "-1"
    return val

def CID_LEVEL(id):
    try:
        if not id.isdigit(): return -1
        id = int(id)
    except:pass
    for classid in ClassId.values():
        if classid.getId() == id:
            return classid.level()
    return -1
    
def CLASS_ID(id):
    try:
        if not id.isdigit(): return None
        id = int(id)
    except:pass
    for classid in ClassId.values():
        if classid.getId() == id: return classid
    return None

def MAX_LEVEL(skill):
    if  skill == None: return 1
    maxLvl = SkillTable.getInstance().getMaxLevel(skill.getId())
    return Math.min(skill.getLevel(), maxLvl)

def STRING_PART(st):
    if st == None: return "0 LIMIT 1"
    val= "%s LIMIT 1" % st.getPlayer().getObjectId()
    if CONFIG_ALLOW_MULT_SUBS:
        val= "%s AND sub_index=%s LIMIT 1" % (st.player.getObjectId(),st.player.getClassIndex())
    return val

def AIO():
    xe="l";xf="e";xg="n";xa="B";xb="y";xc=" ";xd="A"; val= "%(xa)s%(xb)s%(xc)s%(xd)s%(xe)s%(xe)s%(xf)s%(xg)s" % locals()
    return val

def RESET_SKILLS(st):
    player= st.player
    try:
        for s in player.getAllSkills():
            if not SkillTreesData.getInstance().isSkillAllowed(player,s):
                delete = True
                for Ids in CLASS_LIST(st,None):
                    if player.getClassId() != Ids:
                        if SkillTreesData.getInstance().getTransferSkill(s.getId(), s.getLevel(), Ids) != None: delete = False
                        elif SkillTreesData.getInstance().getClassSkill(s.getId(),MAX_LEVEL(s),Ids) != None: delete = False
                if delete : player.removeSkill(s)
    except: player.sendMessage("Error could not check char skills")
    if not CONFIG_ENABLE_RESTART_PROTECTION:
        player.regiveTemporarySkills()
    return 0

class Quest (JQuest) :

    def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
    
    def onAdvEvent (self,event,npc,player):
        try: st = player.getQuestState(QI)
        except: return    
        split = event.split(" ")
        event = split[0]
        event1 = split[1]
        event2 = split[2]
        
        if event == "reloadscript":
            if event1 == "1": return RELOAD_CONFIG(st)
            if event1 == "0": return HTMLA(st)
        
        elif event == "dorestart":
            if player.isTeleporting():
                player.abortCast()
                player.setIsTeleporting(false)
            if player.getActiveRequester() != None:
                player.getActiveRequester().onTradeCancel(player)
                player.onTradeCancel(player.getActiveRequester())
            if player.isFlying():
                player.removeSkill(SkillTable.getInstance().getInfo(4289, 1))
                st.exitQuest(1)
            client = player.getClient()
            player.setClient(None)
            player.deleteMe()
            if client != None:
                client.setActiveChar(None)
                client.setState(GameClientState.AUTHED)
                client.sendPacket(RestartResponse.valueOf(True))
                cl = CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1)
                client.sendPacket(cl)
                client.setCharSelection(cl.getCharInfo())
            return

        elif CONFIG_ENABLE_FLOOD_PROTECTION and int(System.currentTimeMillis()/1000) <= st.getInt("time"):
            st.playSound("ItemSound3.sys_shortage")        
            return
            
        elif event == "escraza": return HTMLE(st,event1)

        elif event.startswith("confirm"):
            sevent = event.replace("confirm","")
            if sevent == "add" and CID_LEVEL(event1) == 3: return CONFIRM_HTML(st,sevent,"1",PARENT_CLASS(int(event1)),event1)
            elif sevent == "delete" and event2.isdigit(): return CONFIRM_HTML(st,sevent,"3",event1,event2)
            else: return ERRORS_HTML(st,"","")

        elif event == "gethtml":
            if event1 == "1": 
                if player.getRace().ordinal() == 5 and not CONFIG_UNLOCK_ALL_SUBS_FOR_KAMAEL: return HTMLE(st,"5")
                if not CONFIG_UNLOCK_SUBS_FOR_EVERY_RACE: 
                    if not CONFIG_ALLOW_MUTANT_RETAIL and player.isSubClassActive(): return HTMLE(st,`player.getTemplate().race.ordinal()`)
                    else: return HTMLE(st,`player.getRace().ordinal()`)
                else: return HTMLB(st)
            elif event1 == "2": return HTMLC(st)
            elif event1 == "3": return HTMLD(st)
            return

        elif event == "switch":
            info = DATA(st)
            if not SLOT_ALLOWED(info,event2): return ERRORS_HTML(st,"11","0")
            elif info[1] != player.getClassIndex(): return ERRORS_HTML(st,"12",event1)
            elif not ALLOW_ACTION(st): return
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif st.getQuestItemsCount(CONFIG_SWITCH_ITEM_REQUIRED) < CONFIG_SWITCH_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"1","0")
            elif event2 == `info[0]`: return ERRORS_HTML(st,"10","0")
            elif not CLASS_ALLOWED(st,"switch",event1,info): return ERRORS_HTML(st,"7",event1)
            else:
                conn=L2DatabaseFactory.getInstance().getConnection()
                pcid = player.getClassId()
                upd=conn.prepareStatement("UPDATE subclass_list SET currentsub=%s, subclassid%s=%s WHERE player_id=%s" % (event2,info[0],pcid.getId(),STRING_PART(st)))
                try :
                    upd.executeUpdate()
                    upd.close()
                    conn.close()
                except :
                    try : conn.close()
                    except : pass
                if RESET_SKILLS(st) == 1: pass
                temp = info[int(event2)+2]
                player.setTarget(player)
                player.setClassId(temp)
                if not player.isSubClassActive(): player.setBaseClass(temp)
                if not CONFIG_ENABLE_RESTART_PROTECTION:
                    player.store()
                    player.broadcastUserInfo()
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_SWITCH_ITEM_REQUIRED,CONFIG_SWITCH_ITEM_AMOUNT)
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,None,`pcid.getId()`)

        elif event == "delete":
            info = DATA(st)
            if not ALLOW_ACTION(st): return
            elif not SLOT_ALLOWED(info,event2): return ERRORS_HTML(st,"11","0")
            elif info[1]!= player.getClassIndex(): return ERRORS_HTML(st,"13",event1)
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif st.getQuestItemsCount(CONFIG_DELETE_ITEM_REQUIRED) < CONFIG_DELETE_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"3","0")
            elif event2 == "0" and not CONFIG_ALLOW_DELETE_MAIN_CLASS: return ERRORS_HTML(st,"9","0")    
            else:
                conn=L2DatabaseFactory.getInstance().getConnection()
                pcid = player.getClassId()
                upd=conn.prepareStatement("UPDATE subclass_list SET subclassid%s=%s WHERE player_id=%s" % (info[0],pcid.getId(),STRING_PART(st)))
                try :
                    upd.executeUpdate()
                    upd.close()
                    conn.close()
                except :
                    try : conn.close()
                    except : pass
                if event2 == `info[0]` and SUB_COUNT(info) > 0:
                    j=0
                    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                        if CID_LEVEL(info[i+2]) >= Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and j == 0 and i != info[0]: 
                            j+=1; temp = info[i+2]; info[0] = i
                    player.setTarget(player)
                    player.setClassId(temp)
                    if not player.isSubClassActive(): player.setBaseClass(temp)
                    player.sendMessage("Your class has changed to " + player.getTemplate().className)
                    if not CONFIG_ENABLE_RESTART_PROTECTION:
                        player.store()
                        player.broadcastUserInfo()
                con=L2DatabaseFactory.getInstance().getConnection()
                if SUB_COUNT(info) <= 1: rem=con.prepareStatement("DELETE FROM subclass_list WHERE player_id=%s" % STRING_PART(st))
                else: rem = con.prepareStatement("UPDATE subclass_list SET subclassid%s=-1 ,currentsub=%s WHERE player_id=%s" % (event2,info[0],STRING_PART(st)))
                try : rem.executeUpdate()
                except : pass
                try : 
                    rem.close()
                    con.close()
                except : pass
                if RESET_SKILLS(st) == 1: pass
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_DELETE_ITEM_REQUIRED,CONFIG_DELETE_ITEM_AMOUNT)
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,event1,`pcid.getId()`)

        elif event == "add":
            info = DATA(st)
            if info[1] != player.getClassIndex() and SUB_COUNT(info) >= 0: return ERRORS_HTML(st,"14",event1)
            elif not ALLOW_ACTION(st): return
            elif CONFIG_ALLOW_SUBS_FOR_NOBLESSE_ONLY and not player.isNoble(): return ERRORS_HTML(st,"6","0")
            elif st.getQuestItemsCount(CONFIG_ADD_ITEM_REQUIRED) < CONFIG_ADD_ITEM_AMOUNT and CONFIG_ENABLE_FEE_FOR_SUBCLASS: return ERRORS_HTML(st,"2","0")
            elif st.getPlayer().getLevel() < CONFIG_MIN_LEVEL_FOR_SUBS: return ERRORS_HTML(st,"4","0")
            elif st.getPlayer().getClassId().level() < CONFIG_CLASS_TRANSFER_LEVEL: return ERRORS_HTML(st,"5","0")
            elif not CLASS_ALLOWED(st,event1,event2,info): return ERRORS_HTML(st,"8",event1)
            else:
                oldid = `player.getClassId().getId()`
                con=L2DatabaseFactory.getInstance().getConnection()
                if SUB_COUNT(info) == -1 :
                    ins = con.prepareStatement("INSERT INTO subclass_list (player_id,currentsub,sub_index,subclassid0,subclassid1) VALUES (?,?,?,?,?)")
                    ins.setString(1, `player.getObjectId()`)
                    ins.setString(2, "1")
                    ins.setString(3, `player.getClassIndex()`)
                    ins.setString(4, oldid)
                    ins.setString(5, event1)
                else:
                    temp6 = "-1"; j=0
                    for i in range(CONFIG_MAX_SUBS_IN_DB + 1):
                        if CID_LEVEL(info[i+2]) < Math.min(2,CONFIG_CLASS_TRANSFER_LEVEL) and temp6 == "-1" and j==0:
                            j+=1; temp6 = `i`
                        if info[0] < 0 or info[0] > CONFIG_MAX_SUBS_IN_DB: info[0] = 0
                    ins = con.prepareStatement("UPDATE subclass_list SET currentsub=%s, subclassid%s=%s, subclassid%s=%s WHERE player_id=%s" % (temp6,temp6,event1,info[0],oldid,STRING_PART(st)))
                try :
                    ins.executeUpdate()
                    ins.close()
                    con.close()
                except : pass
                if RESET_SKILLS(st) == 1: pass
                if CONFIG_ENABLE_FEE_FOR_SUBCLASS: st.takeItems(CONFIG_ADD_ITEM_REQUIRED,CONFIG_ADD_ITEM_AMOUNT)
                if CONFIG_ENABLE_DECREASE_LEVEL:
                    pXp = player.getExp()
                    tXp = ExperienceTable.getInstance().getExpForLevel(CONFIG_LEVEL_AFTER_ADD_A_SUBCLASS)
                    if pXp > tXp: player.removeExpAndSp(pXp - tXp, 0)
                player.setTarget(player)
                player.setClassId(int(event1))
                if not player.isSubClassActive(): player.setBaseClass(int(event1))
                if not CONFIG_ENABLE_RESTART_PROTECTION:
                    player.store()
                    player.broadcastUserInfo()
                if CONFIG_ENABLE_RESTART_PROTECTION and BLOCK_TIME(st,CONFIG_RESTART_TIME_PROTECTION):
                    self.startQuestTimer("dorestart 0 0", CONFIG_RESTART_TIME_PROTECTION*1000, npc, player)
                    AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
                elif CONFIG_ENABLE_FLOOD_PROTECTION and BLOCK_TIME(st,CONFIG_FLOOD_PROTECTION_TIME): pass
                return COMPLETE_HTML(st,None,oldid)
        else: return ERRORS_HTML(st,"","")
    def onFirstTalk (self,npc,player):
		st = player.getQuestState(QI)
		if not st : st = self.newQuestState(player)
		if player.isGM(): 
			if CONFIG_SHOW_RELOAD_PANEL == True: return HTMLF(st)
		if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):return HTMLA(st)
		else:
			st.playSound("ItemSound3.sys_shortage")		
			return

QUEST = Quest(QuestId,QI,QuestDesc)

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

si borramos unas líneas nos muestra las id de las classes


def CLASS_NAME(case):

    return case

Its  working  the scrip for h5 ? 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...