Jump to content
  • 0

Question

Posted

hello i have top online npc n my server and it takes the online time from navicat
but it navicat it count per seconds i want it counts per hours or days how can i do it?

Recommended Posts

  • 0
Posted

days = num_seconds / (60 * 60 * 24);
num_seconds -= days * (60 * 60 * 24);
hours = num_seconds / (60 * 60);
num_seconds -= hours * (60 * 60);
minutes = num_seconds / 60;

  • 0
Posted

You can create a new variable into the source to calculate the table value (seconds) with * / 60 * so the variable will get the minutes,then send the variable value to the npc dialog

  • 0
Posted

days = num_seconds / (60 * 60 * 24);

num_seconds -= days * (60 * 60 * 24);

hours = num_seconds / (60 * 60);

num_seconds -= hours * (60 * 60);

minutes = num_seconds / 60;

yes but how can i do it

  • 0
Posted

You can create a new variable into the source to calculate the table value (seconds) with * / 60 * so the variable will get the minutes,then send the variable value to the npc dialog

i really dont know how :S

  • 0
Posted

Then give us the code and will do it for you...Simple as that

it's not java code it's a rank npc but if you mean the init here it is

 

 

     # - - - - - - - -

         # + Online Time +

         # - - - - - - - -                    

        if event == "6" and price >= PriceCount :

            st.takeItems(PriceID,PriceCount)

            htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=280><tr><td width=40><center><font color =\"FF0000\">Rank</color></center></td><td width=160><center><font color =\"FF0000\">Name</color></center></td><td width=80><center><font color =\"FF0000\">Online</color></center></td></tr><tr></tr>"

            htmltext_info =""            

            color = 1

            pos = 0

            con = L2DatabaseFactory.getInstance().getConnection()

            pks = con.prepareStatement("SELECT char_name,onlinetime FROM characters WHERE onlinetime>0 and accesslevel=0 order by onlinetime desc limit 20")

            rs = pks.executeQuery()

            while (rs.next()) :

                char_name = rs.getString("char_name")

                char_onlinetime = rs.getString("onlinetime")

                pos = pos + 1

                posstr = str(pos)

                if color == 1:

                    color_text = "<font color =\"FFFFFF\">"

                    color = 2

                    htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"

                elif color == 2:

                    color_text = "<font color =\"00FF00\">"

                    color = 1

                    htmltext_info = htmltext_info + "<tr><td><center><font color =\"00FF00\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"

            htmltext_end = "</table></center></body></html>"

            htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end

            con.close()

            return htmltext_pklist

        elif event == "6" and price < PriceCount :

            htmltext = "<html><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"

            return htmltext

 

QUEST       = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)

 

for npcId in NPC:

 QUEST.addStartNpc(npcId)

 QUEST.addTalkId(npcId)

 QUEST.addTalkId(npcId)

  • 0
Posted

 

# - - - - - - - -
         # + Online Time +
         # - - - - - - - -                   
        if event == "6" and price >= PriceCount :
            st.takeItems(PriceID,PriceCount)
            htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=280><tr><td width=40><center><font color =\"FF0000\">Rank</color></center></td><td width=160><center><font color =\"FF0000\">Name</color></center></td><td width=80><center><font color =\"FF0000\">Online</color></center></td></tr><tr></tr>"
            htmltext_info =""           
            color = 1
            pos = 0
            con = L2DatabaseFactory.getInstance().getConnection()
            pks = con.prepareStatement("SELECT char_name,onlinetime FROM characters WHERE onlinetime>0 and accesslevel=0 order by onlinetime desc limit 20")
            rs = pks.executeQuery()
            while (rs.next()) :
                char_name = rs.getString("char_name")
                char_onlinetime = rs.getString("onlinetime")

                char_onlinetime = char_onlinetime/(60*60)
                pos = pos + 1
                posstr = str(pos)
                if color == 1:
                    color_text = "<font color =\"FFFFFF\">"
                    color = 2
                    htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"
                elif color == 2:
                    color_text = "<font color =\"00FF00\">"
                    color = 1
                    htmltext_info = htmltext_info + "<tr><td><center><font color =\"00FF00\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"
            htmltext_end = "</table></center></body></html>"
            htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
            con.close()
            return htmltext_pklist
        elif event == "6" and price < PriceCount :
            htmltext = "<html><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"
            return htmltext

QUEST       = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)

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

 

 

 

try this and make sure the line you add starts with TAB character, not spaces like i did

  • 0
Posted
import sys
from com.l2jfrozen.gameserver.model.actor.instance import L2PcInstance
from java.util import Iterator
from com.l2jfrozen.gameserver.datatables import SkillTable
from com.l2jfrozen.util.database import L2DatabaseFactory
from com.l2jfrozen.gameserver.model.quest import State
from com.l2jfrozen.gameserver.model.quest import QuestState
from com.l2jfrozen.gameserver.model.quest.jython import QuestJython as JQuest
#===================================================
qn = "2003_Ranking"
#===================================================
NPC=[9]
PriceID = 57
PriceCount = 0
QuestId     = 2003
QuestName   = "Ranking"
QuestDesc   = "custom"
InitialHtml = "1.htm"
#===================================================
print "(Added NPC Ranking SMZ & RTZ successfully)"
#===================================================
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
		price = st.getQuestItemsCount(PriceID)
		
		# - - - - - - - - -
		# +  PvP Ranking  +
		# - - - - - - - - -
		if event == "1" and price >= PriceCount :
			st.takeItems(PriceID,PriceCount)
			total_asesinados = 0
			htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=280><tr><td width=40><center><font color =\"FF0000\">Rank</center></td><td width=180><center>Name</center></td><td width=60><center>PVP's</color></center></td></tr><tr></tr>"
			htmltext_info =""			
			color = 1
			pos = 0
			con = L2DatabaseFactory.getInstance().getConnection()
			pks = con.prepareStatement("SELECT char_name,pvpkills FROM characters WHERE pvpkills>0 and accesslevel=0 order by pvpkills desc limit 20")
			rs = pks.executeQuery()
			while (rs.next()) :
				char_name = rs.getString("char_name")
				char_pkkills = rs.getString("pvpkills")
				total_asesinados = total_asesinados + int(char_pkkills)
				pos = pos + 1
				posstr = str(pos)
				if color == 1:
					color_text = "<font color =\"FFFFFF\">"
					color = 2
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
				elif color == 2:
					color_text = "<font color =\"00FF00\">"
					color = 1
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"00FF00\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
			htmltext_end = "</table></center></body></html>"
			htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
			con.close()
			return htmltext_pklist
		elif event == "1" and price < PriceCount :
			htmltext = "<html><title>Rankings</title><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"
			return htmltext
		
		# - - - - - - - - -
		# +  PK Ranking   +
		# - - - - - - - - -
		if event == "2" and price >= PriceCount :
			st.takeItems(PriceID,PriceCount)
			total_asesinados = 0
			htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=280><tr><td width=40><center><font color =\"FF0000\">Rank</center></td><td width=180><center>Name</center></td><td width=60><center>PK's</color></center></td></tr><tr></tr>"
			htmltext_info =""			
			color = 1
			pos = 0
			con = L2DatabaseFactory.getInstance().getConnection()
			pks = con.prepareStatement("SELECT char_name,pkkills FROM characters WHERE pkkills>0 and accesslevel=0 order by pkkills desc limit 20")
			rs = pks.executeQuery()
			while (rs.next()) :
				char_name = rs.getString("char_name")
				char_pkkills = rs.getString("pkkills")
				total_asesinados = total_asesinados + int(char_pkkills)
				pos = pos + 1
				posstr = str(pos)
				if color == 1:
					color_text = "<font color =\"FFFFFF\">"
					color = 2
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
				elif color == 2:
					color_text = "<font color =\"00FF00\">"
					color = 1
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"00FF00\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_pkkills + "</center></td></tr>"
			htmltext_end = "</table></center></body></html>"
			htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
			con.close()
			return htmltext_pklist
		elif event == "2" and price < PriceCount :
			htmltext = "<html><title>Rankings</title><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"
			return htmltext
			
		# - - - - - - - - - - - - - -
		# + Clan Reputation ranking +
		# - - - - - - - - - - - - - -
		if event == "5" and price >= PriceCount :
			st.takeItems(PriceID,PriceCount)
			htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=230><tr><td><font color =\"FF0000\">Rank</color></td><td><center><font color =\"FF0000\">Level</color></center></td><td><center><font color =\"FF0000\">Name</color></center></td><td><center><font color =\"FF0000\">Reputation</color></center></td></tr><tr></tr>"
			htmltext_info =""
			color = 1
			pos = 0
			con = L2DatabaseFactory.getInstance().getConnection()
			clan = con.prepareStatement("SELECT clan_name,clan_level,reputation_score FROM clan_data WHERE clan_level>0 order by reputation_score desc limit 5")
			rs = clan.executeQuery()
			while (rs.next()) :
				clan_name = rs.getString("clan_name")
				clan_level = rs.getString("clan_level")
				clan_score = rs.getString("reputation_score")
				pos = pos + 1
				posstr = str(pos)
				if color == 1:
					color_text = "<font color =\"FFFFFF\">"
					color = 2
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFF00\">" + posstr + "</center></td><td><center>" + color_text + clan_level +"</center></td><td><center>" + clan_name + "</center></td><td><center>" + clan_score + "</center></td></tr>"
				elif color == 2:
					color_text = "<font color =\"FFFFFF\">"
					color = 1
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFF00\">" + posstr + "</center></td><td><center>" + color_text + clan_level +"</center></td><td><center>" + clan_name + "</center></td><td><center>" + clan_score + "</center></td></tr>"
			htmltext_end = "</table></center></body></html>"
			htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
			con.close()
			return htmltext_pklist
		elif event == "5" and price < PriceCount :
			htmltext = "<html><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"
			return htmltext
            
		 # - - - - - - - -
		 # + Online Time +
	     # - - - - - - - -					
		if event == "6" and price >= PriceCount :
			st.takeItems(PriceID,PriceCount)
			htmltext_ini = "<html><head><center></head><body><br><img src=\"l2ui.bbs_lineage2\" width=78 height=13><br1><br><br><table width=280><tr><td width=40><center><font color =\"FF0000\">Rank</color></center></td><td width=160><center><font color =\"FF0000\">Name</color></center></td><td width=80><center><font color =\"FF0000\">Online</color></center></td></tr><tr></tr>"
			htmltext_info =""			
			color = 1
			pos = 0
			con = L2DatabaseFactory.getInstance().getConnection()
			pks = con.prepareStatement("SELECT char_name,onlinetime FROM characters WHERE onlinetime>0 and accesslevel=0 order by onlinetime desc limit 20")
			rs = pks.executeQuery()
			while (rs.next()) :
				char_name = rs.getString("char_name")
				char_onlinetime = rs.getString("onlinetime")
				pos = pos + 1
				posstr = str(pos)
				if color == 1:
					color_text = "<font color =\"FFFFFF\">"
					color = 2
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"
				elif color == 2:
					color_text = "<font color =\"00FF00\">"
					color = 1
					htmltext_info = htmltext_info + "<tr><td><center><font color =\"00FF00\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"
			htmltext_end = "</table></center></body></html>"
			htmltext_pklist = htmltext_ini + htmltext_info + htmltext_end
			con.close()
			return htmltext_pklist
		elif event == "6" and price < PriceCount :
			htmltext = "<html><body><center>Sorry!<br><br>You do not have the necessary items.</center></body></html>"
			return htmltext

QUEST       = Quest(QuestId,str(QuestId) + "_" + QuestName,QuestDesc)

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

it's not java it's python and i tried the way you suggest me but when i press show me top online it opens a windows and writes script error any other suggest ?

  • 0
Posted (edited)

Change:

 

htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"

 

to

 

htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + (((int)char_onlinetime)/(60*60))+ "</center></td></tr>"

 

Try this...(Ignore my previous suggestion, i did not see that the script takes the onlinetime as a string).

 

According to google, cast should be ok :P

 

In case of script error, can u post the error?

Edited by Solomun
  • 0
Posted

Did python accept type casting?

Google said yes....And fuck, 5 years since i write something in python :(

  • 0
Posted

Change:

 

htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + char_onlinetime + "</center></td></tr>"

 

to

 

htmltext_info = htmltext_info + "<tr><td><center><font color =\"FFFFFF\">" + posstr + "</td><td><center>" + color_text + char_name +"</center></td><td><center>" + (((int)char_onlinetime)/(60*60))+ "</center></td></tr>"

 

Try this...(Ignore my previous suggestion, i did not see that the script takes the onlinetime as a string).

 

According to google, cast should be ok :P

 

In case of script error, can u post the error?

i did but it still remains the same nothing change and no error

  • 0
Posted

i did but it still remains the same nothing change and no error

 

 

In case of script error, can u post the error?

  • 0
Posted (edited)

Typecast in python:

 

To convert from a numeric type to a string:

number = 2

word = str(number )

 

To convert from a string type to an int:

test = "test"

number = int(test )

Edited by melron
  • 0
Posted

Typecast in python:

 

 

To convert from a string type to an int:

test = "test"

number = int(test )

 

thats what i did...right?

 

((int)char_onlinetime)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I’ve worked with a web designer Tacoma before, and it really reminded me how much smoother projects run when design and development stay in sync. Your setup looks solid, and pairing clean UI work with steady backend support can save a ton of back‑and‑forth later. If you ever decide to push harder on conversions or need outside perspective on structure, that mix helped me spot gaps early on.
    • If you’re juggling mixed payment methods and tricky setups, I’ve found that easing the pressure on the subscription side can make the whole flow smoother. I started using Subscription Revenue Growth for handling my own recurring payments, upgrades, and all that messy churn stuff, and it took a big weight off. Pairing something stable for subs with your gateway setup can keep cashflow from going off the rails.
    • L2Avalon launches February 20 High Five project (Salvation client) focused on classic world progression — not instance spam and not “twink” metas. What is L2Avalon? L2Avalon is built around real Lineage 2 gameplay: farming spots, open world conflict, raids, epics, economy and competition. No Kamael Reduced instanced content **Discord:** https://discord.gg/NbM2cXmAem 🌐 **Website:** https://l2avalon.net Balance & Economy Every class is tuned to be viable in PvE and PvP Off-meta classes get buffed instead of adding power-creep garbage Adena-based economy Farming matters: boosted Drop/Spoil for each stage of progression Rates & Settings Dynamic XP: 50x (Lv 1–40) → 1x (Lv 78+) Staged progression with new content unlocking weekly Adena / Drop / Spoil: 3x / 5x / 5x NPC Buffer: 2 hours (Premium: 3 hours) Box limit: 2+1 windows per PC MP potion: 1000 MP, 10s cooldown Free2Play System (earn Donate Coins by playing) You don’t have to donate to progress. Donate Coins drop in-game, so everything is achievable through playtime and activity. Where Donate Coins drop: Mobs Lv 76+, Raid Bosses Lv 70+, Epic Bosses Auto-farm (controlled) Limit: only 1 window can use auto-farm at the same time Daily time: 1 hour/day without Premium Extra tickets: purchasable with PC Bang points (earned by being online) Disabled zones: CC / IT / FOG / VARKA / KETRA Equipment Changes Reworked set bonuses Reworked SA system Enchanted set bonuses Enchanted shirt bonuses Fake Epic jewelry (weakened alternative) Skills (High Five mechanics) New skills added Old skills updated New enchant branches + updated existing ones Subclass skills Clan skills Daily Activities (solo-friendly) Events / Missions / Instances Stages Soon — stage schedule and weekly unlocks will be published February 20 — we start. **Discord:** https://discord.gg/NbM2cXmAem 🌐 **Website:** https://l2avalon.net
    • Hello MxC community, i want to buy client dev / patch maker services for the client of salvation. Im using L2jeternity multiprotocol (h5-salvation 140). I want a Patch full optimized for the h5 content. Everything that is not needed must be removed, as well as some textures like maps for example should be also adjusted to h5 content. If you know anyone that can take the job feel free to contact me here or in Discord. Only professional work.   Discord: ch4osroxas   Thank you very much!
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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