Jump to content
  • 0

[help] python script to v.i.p access for npc html


Veandil
 Share

Question

hi all, i have a little problem with make a __init__.py to npc which will be show html when acclvl=<1

my code looks like this

import sys

from net.sf.l2j.gameserver.model.quest import State

from net.sf.l2j.gameserver.model.quest import QuestState

from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

from net.sf.l2j import L2DatabaseFactory



QUEST_ID = 5999

QUEST_NAME   = "vip"

QUEST_DESCRIPTION   = "custom"

QUEST_LOADING_INFO = str(QUEST_ID)+"_"+QUEST_NAME

NPC_ID = 5999







def enable (vip) : # check if vip is enabled

                val = "0"

                conn=L2DatabaseFactory.getInstance().getConnection()

                act = conn.prepareStatement("SELECT accesslevel FROM characters WHERE accesslevel<=1 ")

                act.setInt(1, int(vip))

                rs=act.executeQuery()

                if rs :

                        rs.next()

                        try :

                                val = rs.getString("canUse")

                                conn.close()					

                        except :

                                val = "0"

                                try :

                                        conn.close()

                                except:

                                        pass

                        else :

                                val = "0"



                        if val == "1" :

                                val = "True"

                        if val == "0" :

                                val = "False"



                return val



class Quest (JQuest) :     

        def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

        def onEvent(self,event,st,player,vip):

              st = player.getQuestState(QUEST_LOADING_INFO)  

              htmltext = event

              VIP_ENABLED = getVar("vip")

              if event == "1": 

                if enable(vip) == "true" :

                        html.showhtml("5999-2.htm")

                elseif   

                html.showhtml("5999-1.htm")

def ontalk(self,event,st,player,vip):

		  st = player.getQuestState(QUEST_LOADING_INFO)  

              htmltext = event

              VIP_ENABLED = getVar("vip")

			if enable(vip) =="true" :

				html.showhtml("5999-2.htm")

			elseif

				htmltext = "<html><body>you are not vip! get lost!</body></html>"

QUEST = Quest(QUEST_ID,QUEST_LOADING_INFO,QUEST_DESCRIPTION)



QUEST.addStartNpc(NPC_ID)

QUEST.addFirstTalkId(NPC_ID)

QUEST.addTalkId(NPC_ID)

but it still dont show me html in game.

l2j rev 3599

DB rev 6691

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

hi all, i have a little problem with make a __init__.py to npc which will be show html when acclvl=<1

my code looks like this

import sys

from net.sf.l2j.gameserver.model.quest import State

from net.sf.l2j.gameserver.model.quest import QuestState

from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

from net.sf.l2j import L2DatabaseFactory



QUEST_ID = 5999

QUEST_NAME   = "vip"

QUEST_DESCRIPTION   = "custom"

QUEST_LOADING_INFO = str(QUEST_ID)+"_"+QUEST_NAME

NPC_ID = 5999







def enable (vip) : # check if vip is enabled

                val = "0"

                conn=L2DatabaseFactory.getInstance().getConnection()

                act = conn.prepareStatement("SELECT accesslevel FROM characters WHERE accesslevel<=1 ")

                act.setInt(1, int(vip))

                rs=act.executeQuery()

                if rs :

                        rs.next()

                        try :

                                val = rs.getString("canUse")

                                conn.close()					

                        except :

                                val = "0"

                                try :

                                        conn.close()

                                except:

                                        pass

                        else :

                                val = "0"



                        if val == "1" :

                                val = "True"

                        if val == "0" :

                                val = "False"



                return val



class Quest (JQuest) :     

        def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

        def onEvent(self,event,st,player,vip):

              st = player.getQuestState(QUEST_LOADING_INFO)  

              htmltext = event

              VIP_ENABLED = getVar("vip")

              if event == "1": 

                if enable(vip) == "true" :

                        html.showhtml("5999-2.htm")

                elseif   

                html.showhtml("5999-1.htm")

def ontalk(self,event,st,player,vip):

		  st = player.getQuestState(QUEST_LOADING_INFO)  

              htmltext = event

              VIP_ENABLED = getVar("vip")

			if enable(vip) =="true" :

				html.showhtml("5999-2.htm")

			elseif

				htmltext = "<html><body>you are not vip! get lost!</body></html>"

QUEST = Quest(QUEST_ID,QUEST_LOADING_INFO,QUEST_DESCRIPTION)



QUEST.addStartNpc(NPC_ID)

QUEST.addFirstTalkId(NPC_ID)

QUEST.addTalkId(NPC_ID)

but it still dont show me html in game.

l2j rev 3599

DB rev 6691

 

Why not to try to make it in Java??

 

Better Like:

Create a VIP in PC instance and in DB, check how nombless is registered,

Then you can make it Like a command, or make it in java....

Example:

if (activeChar.isVIP() && activeChar.isGM())

showHtmlMessage etc .....

Myh opinion as java is better from jython...

Link to comment
Share on other sites

  • 0

1st reason :i don't make this in java 'couse i want to share this with peoples who don't change core :P and this can e added to almoste all pack's(with little chnage)

2nd reason : i try to learn jython  

3rd reason i dont know how to add class to java(never do this :P)

4th reason : if i will learn how to do this ill be able to make npc only for hero, top pvp'ers,pk'ers and other... very usefull for pvp servers

 

 

//edit

 

few minutes ago i found npc for showing pvp/pk count.. now i must just change few part of script(its for l2free)so... if i make it ill share it here :P

Link to comment
Share on other sites

  • 0

                conn=L2DatabaseFactory.getInstance().getConnection()

 

                act = conn.prepareStatement("SELECT accesslevel FROM characters WHERE accesslevel<=1 ")

 

                act.setInt(1, int(vip))

 

                rs=act.executeQuery()

ofc it wont work... you are setting an int instead of getting one

Link to comment
Share on other sites

  • 0

so what in your opinion i should put here? every ideas are good and can give something. on l2j forum jiv told i should use something like that

public class GmNPc extends Npc

{



public onAction(player)

{

if !player.isGm() return;

super.onAction(player);

}

}

but i dont know how and where... can someone try explain that i dont want correct code but only way.

 

import sys

from net.sf.l2j.gameserver.model.quest import State

from net.sf.l2j.gameserver.model.quest import QuestState

from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest

from net.sf.l2j import L2DatabaseFactory

print "importing custom: 50300_PKlist"



NPC_ID = 5999
QUEST_ID = 5999
QUEST_NAME   = "vip"
QUEST_DESCRIPTION   = "custom"
InitialHtml = "1.htm"



# ************************
# Creando la Clase Quest *
# ************************

class Quest (JQuest) :

def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)

def onTalk (self,npc,player):
	return InitialHtml

def onEvent(self,event,st):
	htmltext = event

	# *********
	# vip
	# *********

	if event == "1" and cantidad_pago >= 3000 :
		con = L2DatabaseFactory.getInstance().getConnection(None)
		pks = con.prepareStatement("SELECT accesslevel FROM characters WHERE acceslevel>0")
		rs = pks.executeQuery()
		while (rs.next()) :
			acclvl= rs.getString("accesslevel")
                               htmltext = "<html><body>blah!</body></html>"
##				pos = pos + 1
##				posstr = str(pos)
##				if color == 1:
##					color_text = "<font color =\"00FFFF\">"
##					color = 2
##					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FF00FF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
##				elif color == 2:
##					color_text = "<font color =\"FF0000\">"
##					color = 1
##					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FF00FF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
##			htmltext_end = "</table><center><font color=\"FFFFFF\">" + "A Total of " + str(total_asesinados) + " Pk's.</center></body></html>"
##			htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
##			con.close()
		return htmltext_pklist
	elif event == "1" and cantidad_pago < 3000 :
		htmltext = "<html><head><title>PK info Online</title></head><body><font color =\"FF0000\">Primero pagame...!! son 3000 adenas.</body></html>"
		return htmltext






QUEST.addStartNpc(NPC_ID)

QUEST.addFirstTalkId(NPC_ID)

QUEST.addTalkId(NPC_ID)

this is 2nd code from remaked pvp/pk npc, error log :

Traceback (innermost last):
 File "__init__.py", line 71, in ?
NameError: QUEST

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   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.

 Share



  • Posts

    • Dear players! Our Talking Island x3 server is up and running for 7 years. It was opened before official EU/NA Classic servers and kept growing all these years, outliving those official servers.  7 years - a long period of time, and no one but us managed to create such a long living project and connect players from all over the world. During this time we withstood a lot of difficulties, such as forced domain change, social network accounts and content bans, and many others. And here we are, still standing strong. But for a very long time, we kept being asked for a new server, a fresh start, a new journey And we feel, that now it's a time for a New Chapter of L2Classic.club story   New server Dion x3 Classic 1.5 is going Live on 14.01.2023! How hard will it be: XP: x3 SP: x3 ADENA: x2 (amount) DROP: x1 (chance) SPOIL: x1 (chance) x1 (amount) QUEST: x2 (xp/adena) Raid Bosses: x1 (chance) Except: Queen Ant, Core, Orfen x2 (chance), Epic Jewels x1 (chance)   As our veteran players already know, we are not blindly following NCsoft updates, so there is a list of differences for Dion x3 from official servers. Full server description can be found HERE   Website: https://l2classic.club/ Forum: https://l2classic.club/forum/ Discord: https://discord.gg/yzhP2hz   Sincerely, Classic Team
    • Hello everyone!   Account registrations are now available for everyone! We will not be deleting accounts after the Open Beta ends.  You will be able to use them on Live Server. Join our open beta which will launch today!   You can also download our Ertheia client from download section. Do not forget to join our discord, so you do not miss any news.   Best regards, L2Ertheia Team
    • Hello again! I found something that is bothering me a lot on this system. When i spawn the npc and no active winner to show his monument the heading on npc  is fine. When a winner exist and his monument spawn, heading is always to the east. i tryed to change is in the serverpacket and made it even static number to check and nothing happened. Any clue?
    • This article original appeared on MmoGah In Torchlight Infinite, there are so many options that you could feel overwhelmed to choose. To help you avoid mistakes, we shared some tips for beginners in our previous two articles. So, this is the third one. If you find it helpful, be sure to share it with your friends.     It Would Be Better If You Read Tooltips Carefully Sometimes you want to use a stick to beat enemies on the head, but you don't realize that it's a magic stick that is used to befuddle your enemies into tripping over their feet and falling off a cliff. It does not show the effects that you want enemies to be down at once because you don't read the weapon's purpose carefully and use the wrong weapon.   Although reading is boring, it's very important for providing multiplicative damage and outputting combat effectiveness. If you have checked your skills and talents, you can use what you have more efficiently.   So don't ignore information like tooltips.   It Would Be Better If You Cap All Your Resistances As Soon As Possible You often die when shooting at bosses or can't survive as you progress. This is always because you're either not building enough life or your resistances aren't capped. If you add the points of your resistance, your survival will greatly increase.   Torchlight Infinite has many resistances, such as fire, cold, lighting, and erosion. These can inspire greater gear availability in the game, especially when you beat enemies or defend territory. And they can be consumed fast when you use them.   You'll need to cap all resistances at 75 percent as soon as possible because getting high resistance for your process would be better. So, you must check your gear and fix your resistance after a big event.   It Would Be Better If You Accumulated Enough Energy Sometimes, your skills don't do as much damage as your gear support. Even if you have talents, you find them not doing anything as you expect. That's because you are lacking in energy and don't have enough support to improve your skills.   In Torchlight Infinite, there are five sections of support for each skill's improvement. You get the first section of support for free. Then on most skills, it costs 10, 15, 50, and 100 energy for other sections, respectively.   Your energy can be replenished by leveling up, progressing, and putting on your Torchlight Infinite items. If you want more energy from your gear, you'll need higher-level items, and you can roll energy via gear empowerment to make sure to get as much energy as possible for your skills to be as strong as they can be.   It Would Be Better If You Save Crafting Materials When you see dropping materials that include things like Flame Sand, you should save your Flame Sand until level 60, when you unlock the player market. Then you can use Flame Sand to buy some cheap legendaries or other items. That will boost your character beyond just crafting or enchanting your stuff at a low level.   You can do something similar with flame Elementium when you get to a higher level. Flame Elementium doesn't start dropping until you're progressing in the end game. You can often use it to go to the market and buy some legendaries that are boss drops, which might be a little bit more expensive but can be much more powerful. Some enabling build items only cost a single Flame Elementium. So Torchlight Infinite Flame Elementium is especially important.    
    • Interlude PVP server with good balance.     
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock