Desquire 451 Опубликовано 18 июня, 2013 (изменено) Хз в чем проблемы, не могу вообще понять не не так..... Вот собстенно файл - http://yadi.sk/d/UxeFXlFU5wdYD Чтобы не скачивать вот он... import sys from time import gmtime, strftime from l2dream import Config from l2dream import L2DatabaseFactory from l2dream.gameserver.model.base import Experience from l2dream.gameserver.model.quest import State from l2dream.gameserver.model.quest import QuestState from l2dream.gameserver.model.quest.jython import QuestJython as JQuest from l2dream.gameserver.util import PcAction qn = "1234_DreamServices" QuestId = 1234 QuestName = "DreamServices" QuestDesc = "custom" SERVICE_NPC = 50030 serviceName = "" saveBD = 0 ###################################################### #Сервис заточки ENCHANT_CHECK_WEAPON = 18 ENCHANT_CHECK_ARMOR = 14 ENCHANT_CHECK_JEWEL = 14 AMOUNT_OF_ENCHANT = 1 ENCHANT_PAYMENT_ITEM_ID = 9999 PRICE_PAYMENT_AMOUNT = 3 weapons = ['Sword','Blunt','Dagger','Bow','Pole','Etc','Fist','Dual Sword','Dual Fist','Big Sword','Big Blunt','Ancient','Crossbow','Rapier','Dual Dagger'] armors = ['Light','Heavy','Magic','Shield','Sigil'] jewels = ['None'] acceptableItemTypes = weapons+armors+jewels ###################################################### #Сервис дворянства GOLDBAR = 4037 PRICE_NUBLE = 20 NOBLESS_TIARA = 7694 ###################################################### #Сервис понижения уровня DELEVEL_MEDAL = 57 DELEVEL_PRICE = 50000 ###################################################### #Сервис покраски COLOR_PRICES = { 1: [9999, 10, "Donate Coin"], 2: [9999, 10, "Donate Coin"], } COLOR_COLOURS = { 1: ["00FF00","00FF00"], 2: ["16721c","1c7216"], 3: ["00FFFF","FFFF00"], 4: ["FF0000","0000FF"], 5: ["FFFB00","00FBFF"], 6: ["337fe6","e67f33"], 7: ["DDA0DD","DDA0DD"], 8: ["808080","808080"], 9: ["000000","000000"], 10: ["81c739","81c739"], 11: ["9120b1","b12091"], 12: ["7c2196","96217c"], 13: ["811664","641681"], 14: ["6b4558","58456b"], } ###################################################### #Сервис покупки геройства HERO_ITEM = 9999 # Итем необходимый для покупки. HERO_COST = 2 # Стоимость за один день. ###################################################### #Сервис покупки Премиума PA_ITEM = 9999 # Итем необходимый для покупки. PA_COST = 1 # Стоимость за один день. ###################################################### #Сервис смены имени SET_NAME_ITEM = 9999 # итем необходимый для обмена SET_NAME_COST = 15 # стоимость SET_NAME_INAME = "Donate Coin" # название итема ######################################### # Управление лвл-ом клана # ######################################### Item1 = 9999 # ID Итема # Name1 = "Don" # Имя Итема # Count1 = 5 # Цена за 6 лвл клана # Count2 = 10 # Цена за 7 лвл клана # Count3 = 15 # Цена за 8 лвл клана # ######################################### ######################################### # Управление репутацией клана # ######################################### Item2 = 9999 # ID Итема # Name2 = "Don" # Имя Итема # Count4 = 10 # Цена 50к репутации # Count5 = 15 # Цена 100к репутации # ######################################### ######################################### # Управление скиллами клана # ######################################### Item3 = 9999 # ID Итема # Name3 = "Don" # Имя Итема # Count6 = 30 # Цена за клан скиллы # ######################################### class Quest (JQuest) : def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr) def onEvent (Self,event,st) : saveBD = 0; if event == "startench" : return "StartEnchant.htm" elif event == "startnoble" : return "StartNoble.htm" elif event == "delevel" : return "DelevelGo.htm" elif event == "StartNoble2" : if st.getPlayer().isNoble() == 1 : htmltext = "NobleError1.htm" elif st.getQuestItemsCount(GOLDBAR) < 20 : htmltext = "NobleError2.htm" elif st.getPlayer().getLevel() < 40 : htmltext = "NobleError2.htm" else : st.takeItems(GOLDBAR,PRICE_NUBLE) st.getPlayer().setNoble(True) st.giveItems(NOBLESS_TIARA,1) st.playSound("ItemSound.quest_finish") return "NobleEnd.htm" elif event == "choose_item" : htmltext = "" for Item in st.getPlayer().getInventory().getItems(): itemType = Item.getItem().getItemType().toString() itemGrade = Item.getItem().getCrystalType() if itemType in acceptableItemTypes and itemGrade > 0 and not Item.getItem().isHeroItem() and not Item.isShadowItem(): htmltext += "<a action=\"bypass -h Quest 1234_DreamServices enchantItem_" + str(Item.getObjectId()) +"\">" + Item.getItem().getName() + "+" + str(Item.getEnchantLevel()) + "</a><br>" if htmltext == "": htmltext = "noEnchatnItems.htm" else : htmltext = st.showHtmlFile("selectEnchatnItems.htm").replace("ITEM",htmltext) elif event.startswith("enchantItem_"): objId = int(event.replace("enchantItem_", "")) Item = st.getPlayer().getInventory().getItemByObjectId(objId) if Item : itemType = Item.getItem().getItemType().toString() itemEnchant = Item.getEnchantLevel() if st.getQuestItemsCount(ENCHANT_PAYMENT_ITEM_ID) >= PRICE_PAYMENT_AMOUNT : if (itemType in weapons and itemEnchant >= ENCHANT_CHECK_WEAPON) or (itemType in armors and itemEnchant >= ENCHANT_CHECK_ARMOR) or (itemType in jewels and itemEnchant >= ENCHANT_CHECK_JEWEL) : htmltext = "notPlusZero.htm" else : Item.setEnchantLevel(itemEnchant+AMOUNT_OF_ENCHANT) st.takeItems(ENCHANT_PAYMENT_ITEM_ID, PRICE_PAYMENT_AMOUNT) htmltext = "Congratulations.htm" else : htmltext = "notEnoughItems.htm" else : htmltext = "EnchantError.htm" elif event == "DelevelReady" : if st.getPlayer().getLevel() < 41 : return "DelevelLevel.htm" elif st.getQuestItemsCount(DELEVEL_MEDAL) < DELEVEL_PRICE : return "DelevelAdena.htm" elif st.getPlayer().getKarma() > 0 : return "Delevelkarma.htm" elif st.getPlayer().getPvpFlag() != 0 : return "DelevelPvp.htm" elif st.getPlayer().isAttackingNow() == True : return "DelevelAttack.htm" else: st.getPlayer().setTarget(st.getPlayer()) st.takeItems(DELEVEL_MEDAL,DELEVEL_PRICE) st.getPlayer().getStat().removeExpAndSp((st.getPlayer().getExp() - Experience.LEVEL[st.getPlayer().getStat().getLevel() - 1]),0) return "DelevelReady.htm" elif event == "colorservice" : return "ColorService.htm" elif event.startswith("ColorVar_"): vtype = int(event.replace("ColorVar_", "")) if vtype == 1: sample = "### " + st.getPlayer().getName() + " ###" else: sample = "### " + st.getPlayer().getTitle() + " ###" htmltext = st.showHtmlFile("ColorServiceSelect.htm").replace("PRICE_REPLACE", str(COLOR_PRICES[vtype][1])+" "+str(COLOR_PRICES[vtype][2])) htmlt = "" for i in COLOR_COLOURS.keys(): htmlt += "<tr><td width=20></td><td><font color="+str(COLOR_COLOURS[i][1])+">"+str(sample)+"</font></td><td><a msg=\"OK?\" action=\"bypass -h Quest 1234_DreamServices ColorPaint_"+str(vtype)+"_"+str(i)+"\">>>>></a></td></tr>" htmltext = htmltext.replace("BODY_COLOR", htmlt) elif event.startswith("ColorPaint_"): get = str(event.replace("ColorPaint_", "")) vtype,color=get.split("_") vtype,color=int(vtype),int(color) paintcolor = int(COLOR_COLOURS[color][0],16) if vtype == 1: if st.getQuestItemsCount(COLOR_PRICES[1][0]) < int(COLOR_PRICES[1][1]): htmltext = st.showHtmlFile("ColorErr.htm").replace("REPLACE_ERR", str(COLOR_PRICES[2][1])+" "+str(COLOR_PRICES[2][2])) return htmltext st.takeItems(COLOR_PRICES[1][0],COLOR_PRICES[1][1]) st.getPlayer().getAppearance().setNameColor(paintcolor) else: if st.getQuestItemsCount(COLOR_PRICES[2][0]) < int(COLOR_PRICES[2][1]): htmltext = st.showHtmlFile("ColorErr.htm").replace("REPLACE_ERR", str(COLOR_PRICES[2][1])+" "+str(COLOR_PRICES[2][2])) return htmltext st.takeItems(COLOR_PRICES[2][0],COLOR_PRICES[2][1]) st.getPlayer().getAppearance().setTitleColor(paintcolor) st.getPlayer().broadcastUserInfo() st.getPlayer().store() htmltext = "ColorOk.htm" elif event == "ServiceHero" : return "ServiceHero.htm" elif event.startswith("setHero"): days = event.replace("setHero", "") if days == " ": htmltext = "HeroErrDay.htm" return htmltext if st.getPlayer().isHero(): htmltext = "HeroIsHero.htm" return htmltext days = days.replace(" ", "") if not days.isdigit(): htmltext = "HeroErrDay.htm" return htmltext days = int(days) if days < 1: htmltext = "HeroErrDay.htm" return htmltext payment = HERO_COST * days if st.getQuestItemsCount(HERO_ITEM) < payment: htmltext = st.showHtmlFile("HeroErr.htm").replace("HERO_DAYS", str(days)).replace("HERO_ITEM_COUNT", str(payment)) return htmltext serviceName = "Hero Status, "+str(days)+" days." saveBD = 1 st.takeItems(HERO_ITEM,payment) PcAction.addHeroStatus(st.getPlayer(),days) st.getPlayer().broadcastUserInfo() st.getPlayer().store() htmltext = st.showHtmlFile("HeroOk.htm").replace("HERO_DAYS", str(days)) elif event == "ServicePa" : return "ServicePa.htm" elif event.startswith("setPa"): days = event.replace("setPa", "") if days == " ": htmltext = "PaErrDay.htm" return htmltext if st.getPlayer().getPremiumService() > 0: htmltext = "PaIsPa.htm" return htmltext days = days.replace(" ", "") if not days.isdigit(): htmltext = "PaErrDay.htm" return htmltext days = int(days) if days < 1: htmltext = "PaErrDay.htm" return htmltext payment = PA_COST * days if st.getQuestItemsCount(PA_ITEM) < payment: htmltext = st.showHtmlFile("PaErr.htm").replace("PA_DAYS", str(days)).replace("PA_ITEM_COUNT", str(payment)) return htmltext serviceName = "Premium Status, "+str(days)+" days." saveBD = 1 st.takeItems(PA_ITEM,payment) PcAction.addPremiumServices(st.getPlayer(),st.getPlayer().getAccountName(),days) st.getPlayer().broadcastUserInfo() st.getPlayer().store() htmltext = st.showHtmlFile("PaOk.htm").replace("PA_DAYS", str(days)) elif event == "setName" : return "ServiceSetName.htm" elif event.startswith("setNameCheck") : nick = str(event.replace("setNameCheck", "")) nick = str(nick.replace(" ", "")) if nick == "": htmltext = "ServiceSetNameNull.htm" return htmltext elif nick.startswith("GM.") or nick.startswith("ADM") or nick.startswith("Gm") or nick.startswith("gm.") or nick.startswith("GM") or nick.startswith("ADM.") or nick.startswith("EGM.") or nick.startswith("-"): htmltext = "ServiceSetNameErr.htm" return htmltext elif nick.endswith(".GM") or nick.endswith(".ADM") or nick.endswith(".EGM"): htmltext = "ServiceSetNameErr.htm" return htmltext cona=L2DatabaseFactory.getInstance().getConnection() getcount=cona.prepareStatement("SELECT COUNT(char_name) FROM characters WHERE char_name=?") getcount.setString(1,nick) rsc=getcount.executeQuery() if (rsc.next()): if rsc.getInt(1) == 1: htmltext = st.showHtmlFile("ServiceSetNameCheckErr.htm").replace("SET_NICK", nick) return htmltext rsc.close() getcount.close() cona.close() htmltext = st.showHtmlFile("ServiceSetNameCheckOk.htm").replace("SET_NICK", nick) elif event.startswith("setNameSet") : nick = str(event.replace("setNameSet", "")) nick = str(nick.replace(" ", "")) if st.getQuestItemsCount(SET_NAME_ITEM) < SET_NAME_COST: htmltext = st.showHtmlFile("ServiceSetNameNoMoney.htm").replace("NAME_COST", str(SET_NAME_COST)).replace("NAME_INAME", str(SET_NAME_INAME)) return htmltext st.getPlayer().setName(nick) st.takeItems(SET_NAME_ITEM,SET_NAME_COST) serviceName = "Nick Name Chenge" saveBD = 1 payment = 0 htmltext = "ServiceSetNameOk.htm" if saveBD == 1: login = str(st.getPlayer().getAccountName()) name = str(st.getPlayer().getName()) date = str(strftime("%Y-%m-%d", gmtime())) time = str(strftime("%H:%M:%S", gmtime())) writelog=L2DatabaseFactory.getInstance().getConnection() write=writelog.prepareStatement("INSERT INTO l2dream_npc_log (date,time,login,name,action,payment) VALUES (?,?,?,?,?,?)") write.setString(1, date) write.setString(2, time) write.setString(3, login) write.setString(4, name) write.setString(5, serviceName) write.setInt(6, payment) try : write.executeUpdate() write.close() writelog.close() serviceName = "" payment = "" saveBD = 0 except : try : writelog.close() except : pass return htmltext def onFirstTalk (self,npc,player) : st = player.getQuestState(qn) if not st : st = self.newQuestState(player) htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>" if not st : return htmltext return "Start.htm" QUEST = Quest(1234,qn,QuestDesc) QUEST.addStartNpc(SERVICE_NPC) QUEST.addFirstTalkId(SERVICE_NPC) QUEST.addTalkId(SERVICE_NPC) в __init__.py.error.log пишет вот что Error on: E:\dream\game\data\scripts\custom\1234_DreamServices\__init__.py.error.log Line: -1 - Column: -1 Traceback (innermost last): (no code object) at line 0 SyntaxError: ('Lexical error at line 1, column 1. Encountered: "\\ufeff" (65279), after : ""', ('__init__.py', 1, 1, u'\uFEFFimport sys')) Но с оригинальным файлов все нормально - Изменял я как : Открыл блокнотом: заменить 4037 на 9999 ( заменял не все а по очереди) Изменено 18 июня, 2013 пользователем zGrandy Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Demoncool 1110 Опубликовано 18 июня, 2013 (изменено) Попробуй имя вписать serviceName="" Изменено 18 июня, 2013 пользователем Demoncool Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
Nixy 8 Опубликовано 17 июля, 2013 (изменено) uFEFFimport sys Изменено 17 июля, 2013 пользователем Nixy Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты