Separated amount of private/offline stores
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Jesus.M
- Posts: 41
- Joined: Sun Apr 25, 2010 11:33 am
- Location: Lithuania
- Contact:
Separated amount of private/offline stores
Is there any abilities to count amount of private/offline stores and dwarven manufactures using PHP+MySQL for web page, or should I do it via Telnet? Or there isn't any abilities to do it at all? I couldn't find anything in database...
Design meets code. Obey the code!
- denser
- Posts: 1392
- Joined: Wed May 30, 2007 9:13 pm
- Location: Russia
- Contact:
Re: Separated amount of private/offline stores
you have to make cron script for counting and make db for your site.
native method for this absent...
native method for this absent...
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
L2J - the place where glad to see you any time!
- Jesus.M
- Posts: 41
- Joined: Sun Apr 25, 2010 11:33 am
- Location: Lithuania
- Contact:
Re: Separated amount of private/offline stores
Easy to say
but how that script should look exactly?

Design meets code. Obey the code!
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: Separated amount of private/offline stores
does lastactive change when you're in offline store mode? if yes, you can check which are online=0 and lastactive=now
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
- pinkcore
- Posts: 247
- Joined: Fri Jul 24, 2009 3:04 am
- Location: Czech Republic
Re: Separated amount of private/offline stores
I think its not important...jurchiks wrote:does lastactive change when you're in offline store mode? if yes, you can check which are online=0 and lastactive=now
Use character_offline_trade table and count all rows and you will get all offline stores

So you can only work with offline traders / crafters beacuse characters table is not designed to determine if is online player in trade mode or not.
I'm not here only for food!
- nonom
- L2j Veteran
- Posts: 649
- Joined: Wed Mar 11, 2009 10:34 pm
- Location: Magmeld
Re: Separated amount of private/offline stores
@pinkcore: the character_offline_trade table is empty each time that l2j server is deployed, so you cant determinate the current number on this way. Try get it yourselfpinkcore wrote:I think its not important...jurchiks wrote:does lastactive change when you're in offline store mode? if yes, you can check which are online=0 and lastactive=now
Use character_offline_trade table and count all rows and you will get all offline stores
So you can only work with offline traders / crafters beacuse characters table is not designed to determine if is online player in trade mode or not.
Code: Select all
SELECT * FROM `character_offline_trade`
Code: Select all
public static void storeOffliners() { ... for (L2PcInstance pc : L2World.getInstance().getAllPlayers().values()) { ... if ((pc.getPrivateStoreType() != L2PcInstance.STORE_PRIVATE_NONE) && (pc.getClient() == null || pc.getClient().isDetached())) ... con.commit(); // flush, then seems all of them are commited ;) } ... }
I hope it help
- denser
- Posts: 1392
- Joined: Wed May 30, 2007 9:13 pm
- Location: Russia
- Contact:
Re: Separated amount of private/offline stores
try to add
to L2PcInstance.java in method "store". it made each 15 minutes to store table...
on server start that table become empty but in 15 mins - again fills by offliners if any
Code: Select all
try { if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) OfflineTradersTable.storeOffliners(); } catch (Throwable t) { _log.log(Level.WARNING, "Error saving offline shops.",t); }
on server start that table become empty but in 15 mins - again fills by offliners if any
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
L2J - the place where glad to see you any time!
- pinkcore
- Posts: 247
- Joined: Fri Jul 24, 2009 3:04 am
- Location: Czech Republic
Re: Separated amount of private/offline stores
Oops sorry i forgot, but regular saving (Like denser's idea) is better than saving on shutdown. Beacuse if your machine or something get freezed all offliners are removed.@pinkcore: the character_offline_trade table is empty each time that l2j server is deployed, so you cant determinate the current number on this way. Try get it yourself
I'm not here only for food!
- denser
- Posts: 1392
- Joined: Wed May 30, 2007 9:13 pm
- Location: Russia
- Contact:
Re: Separated amount of private/offline stores
my idea is damn bad coz if you have 1000 players - it become many-many-,any sql queries...MANY.
need to make globaltask or threadpool.
but direction is right ))
i done it
thx ThE_PuNiSheR for help and explaination
here you are, make in scripts folder cron/OfflineTradeStore.java:
[java]package cron; import java.util.logging.Level;import java.util.logging.Logger; import com.l2jserver.Config;import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.datatables.OfflineTradersTable; public class OfflineTradeStore{ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName()); private long _init = 1000 * 60 * 15; private long _delay = 1000 * 60 * 15; public OfflineTradeStore() { ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); } private class store implements Runnable { public void run() { try { if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) { OfflineTradersTable.storeOffliners(); _log.info("Offline traders stored via cron!"); } } catch (Throwable t) { _log.log(Level.WARNING, "Error saving offline shops.", t); } } } public static void main(String[] args) { new OfflineTradeStore(); }}[/java]
register at scripts.cfg.
it makes store offliners after script load immediately, and each 15 minutes after...so if your server crushes after load - you get chance to save you poor offliners ^^
need to make globaltask or threadpool.
but direction is right ))
i done it


here you are, make in scripts folder cron/OfflineTradeStore.java:
[java]package cron; import java.util.logging.Level;import java.util.logging.Logger; import com.l2jserver.Config;import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.datatables.OfflineTradersTable; public class OfflineTradeStore{ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName()); private long _init = 1000 * 60 * 15; private long _delay = 1000 * 60 * 15; public OfflineTradeStore() { ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); } private class store implements Runnable { public void run() { try { if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) { OfflineTradersTable.storeOffliners(); _log.info("Offline traders stored via cron!"); } } catch (Throwable t) { _log.log(Level.WARNING, "Error saving offline shops.", t); } } } public static void main(String[] args) { new OfflineTradeStore(); }}[/java]
register at scripts.cfg.
it makes store offliners after script load immediately, and each 15 minutes after...so if your server crushes after load - you get chance to save you poor offliners ^^
Last edited by denser on Sun Sep 05, 2010 5:57 am, edited 1 time in total.
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
L2J - the place where glad to see you any time!
- pinkcore
- Posts: 247
- Joined: Fri Jul 24, 2009 3:04 am
- Location: Czech Republic
Re: Separated amount of private/offline stores
I was thinking about 1 bad condition:denser wrote:my idea is damn bad coz if you have 1000 players - it become many-many-,any sql queries...MANY.
need to make globaltask or threadpool.
but direction is right ))
i done itthx ThE_PuNiSheR for help and explaination
![]()
here you are, make in scripts folder cron/OfflineTradeStore.java:
[java]package cron; import java.util.logging.Level;import java.util.logging.Logger; import com.l2jserver.Config;import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.datatables.OfflineTradersTable; public class OfflineTradeStore{ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName()); private long _init = 0; private long _delay = 1000 * 60 * 15; public OfflineTradeStore() { ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); } private class store implements Runnable { public void run() { try { if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS) { OfflineTradersTable.storeOffliners(); _log.info("Offline traders stored via cron!"); } } catch (Throwable t) { _log.log(Level.WARNING, "Error saving offline shops.", t); } } } public static void main(String[] args) { new OfflineTradeStore(); }}[/java]
register at scripts.cfg.
it makes store offliners after script load immediately, and each 15 minutes after...so if your server crushes after load - you get chance to save you poor offliners ^^
1. You shutdown server with Offliners and data is safely stored.
2. You start it again with this cron script, script will be loaded before restoring offliners so table will be cleaned beacuse there will be no offliners in the world at the moment. I will test it but I'm too lazy for now.
I'm not here only for food!
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
- pinkcore
- Posts: 247
- Joined: Fri Jul 24, 2009 3:04 am
- Location: Czech Republic
Re: Separated amount of private/offline stores
Yea it's easy but I'm thinking about saving after offliners are restored cause if my server crashes to 10 minutes all is lost tooThE_PuNiSheR wrote:just set init start to 10 mins..

But I have did the cron scripts are loaded as last thing on server startup:
(I know this isn't best way how to do it but i wanted to contribute

Core side:
Code: Select all
Index: java/com/l2jserver/gameserver/GameServer.java===================================================================--- java/com/l2jserver/gameserver/GameServer.java (revision 4407)+++ java/com/l2jserver/gameserver/GameServer.java (working copy)@@ -464,6 +453,18 @@ _log.info("Server Loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds"); AutoAnnounceTaskManager.getInstance();+ + try+ {+ _log.info("Running Cron");+ File cron = new File(Config.DATAPACK_ROOT + "/data/cron.cfg");+ if(!Config.ALT_DEV_NO_HANDLERS || !Config.ALT_DEV_NO_QUESTS)+ L2ScriptEngineManager.getInstance().executeScriptList(cron);+ }+ catch (IOException ioe)+ {+ _log.severe("Failed loading cron.cfg, no script going to be loaded");+ } } public static void main(String[] args) throws Exception
Code: Select all
Index: data/cron.cfg===================================================================--- data/cron.cfg (revision 0)+++ data/cron.cfg (revision 0)@@ -0,0 +1 @@+cron/OfflineTradeStore.java\ No newline at end of fileIndex: data/scripts/cron/OfflineTradeStore.java===================================================================--- data/scripts/cron/OfflineTradeStore.java (revision 0)+++ data/scripts/cron/OfflineTradeStore.java (revision 0)@@ -0,0 +1,45 @@+package cron;+ +import java.util.logging.Level;+import java.util.logging.Logger;+ +import com.l2jserver.Config;+import com.l2jserver.gameserver.ThreadPoolManager;+import com.l2jserver.gameserver.datatables.OfflineTradersTable;+ +public class OfflineTradeStore+{+ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName());+ private long _init = 0;+ private long _delay = 1000 * 60 * 15;+ + public OfflineTradeStore()+ {+ ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); + }+ + private class store implements Runnable+ {+ public void run()+ {+ try+ {+ if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)+ {+ OfflineTradersTable.storeOffliners();+ _log.info("Offline traders stored via cron!");+ }+ }+ catch (Throwable t)+ {+ _log.log(Level.WARNING, "Error saving offline shops.", t);+ }+ }+ }+ + + public static void main(String[] args)+ {+ new OfflineTradeStore();+ }+}\ No newline at end of file
I'm not here only for food!
- denser
- Posts: 1392
- Joined: Wed May 30, 2007 9:13 pm
- Location: Russia
- Contact:
Re: Separated amount of private/offline stores
here a little cumulative patch to focus all ideas 
core:
[diff]Index: com/l2jserver/Config.java===================================================================--- com/l2jserver/Config.java (revision 4410)+++ com/l2jserver/Config.java (working copy)@@ -398,6 +398,7 @@ public static boolean ALT_DEV_NO_HANDLERS; public static boolean ALT_DEV_NO_QUESTS; public static boolean ALT_DEV_NO_SPAWNS;+ public static boolean ALT_DEV_NO_CRON; public static boolean SERVER_LIST_TESTSERVER; public static int THREAD_P_EFFECTS; public static int THREAD_P_GENERAL;@@ -1668,6 +1675,7 @@ ALT_DEV_NO_HANDLERS = Boolean.parseBoolean(General.getProperty("AltDevNoHandlers", "False")); ALT_DEV_NO_QUESTS = Boolean.parseBoolean(General.getProperty("AltDevNoQuests", "False")); ALT_DEV_NO_SPAWNS = Boolean.parseBoolean(General.getProperty("AltDevNoSpawns", "False"));+ ALT_DEV_NO_CRON = Boolean.parseBoolean(General.getProperty("AltDevNoCron", "False")); THREAD_P_EFFECTS = Integer.parseInt(General.getProperty("ThreadPoolSizeEffects", "10")); THREAD_P_GENERAL = Integer.parseInt(General.getProperty("ThreadPoolSizeGeneral", "13")); IO_PACKET_THREAD_CORE_SIZE = Integer.parseInt(General.getProperty("UrgentPacketThreadCoreSize", "2"));Index: com/l2jserver/gameserver/GameServer.java===================================================================--- com/l2jserver/gameserver/GameServer.java (revision 4410)+++ com/l2jserver/gameserver/GameServer.java (working copy)@@ -464,6 +467,20 @@ _log.info("Server Loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds"); AutoAnnounceTaskManager.getInstance();+ + try+ {+ _log.info("Loading Cron Scripts...");+ File cron = new File(Config.DATAPACK_ROOT + "/data/cron.cfg");+ if(!Config.ALT_DEV_NO_CRON)+ L2ScriptEngineManager.getInstance().executeScriptList(cron);+ else+ _log.info("Loading Cron Scripts disabled by alternative configuration.");+ }+ catch (IOException ioe)+ {+ _log.severe("Failed loading cron.cfg, no script going to be loaded");+ } } public static void main(String[] args) throws Exception\ No newline at end of fileIndex: config/General.properties===================================================================--- config/General.properties (revision 4410)+++ config/General.properties (working copy)@@ -758,4 +758,8 @@ # Don't load spawntable. # Default: False AltDevNoSpawns = False++# Don't load cron.cfg+# Default: False+AltDevNoCron = False\ No newline at end of file[/diff]
DP:
[diff]### Eclipse Workspace Patch 1.0#P gameserverIndex: data/scripts/cron/OfflineTradeStore.java===================================================================--- data/scripts/cron/OfflineTradeStore.java (revision 0)+++ data/scripts/cron/OfflineTradeStore.java (revision 0)@@ -0,0 +1,49 @@+package cron;+ +import java.util.logging.Level;+import java.util.logging.Logger;++import com.l2jserver.Config;+import com.l2jserver.gameserver.ThreadPoolManager;+import com.l2jserver.gameserver.datatables.OfflineTradersTable;++/**+ * @author denser+ * @author ThE_PuNiSheR+ */+public class OfflineTradeStore+{+ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName());+ private long _init = 0;+ private long _delay = 1000 * 60 * 15;+ + public OfflineTradeStore()+ {+ ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); + }+ + private class store implements Runnable+ {+ public void run()+ {+ try+ {+ if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)+ {+ OfflineTradersTable.storeOffliners();+ _log.info("Offline traders stored via cron!");+ }+ }+ catch (Throwable t)+ {+ _log.log(Level.WARNING, "Error saving offline shops.", t);+ }+ }+ }+ + + public static void main(String[] args)+ {+ new OfflineTradeStore();+ }+}\ No newline at end of fileIndex: data/cron.cfg===================================================================--- data/cron.cfg (revision 0)+++ data/cron.cfg (revision 0)@@ -0,0 +1,4 @@+# Feel free to add here your own scripts++# CRON+cron/OfflineTradeStore.java\ No newline at end of file [/diff]

core:
[diff]Index: com/l2jserver/Config.java===================================================================--- com/l2jserver/Config.java (revision 4410)+++ com/l2jserver/Config.java (working copy)@@ -398,6 +398,7 @@ public static boolean ALT_DEV_NO_HANDLERS; public static boolean ALT_DEV_NO_QUESTS; public static boolean ALT_DEV_NO_SPAWNS;+ public static boolean ALT_DEV_NO_CRON; public static boolean SERVER_LIST_TESTSERVER; public static int THREAD_P_EFFECTS; public static int THREAD_P_GENERAL;@@ -1668,6 +1675,7 @@ ALT_DEV_NO_HANDLERS = Boolean.parseBoolean(General.getProperty("AltDevNoHandlers", "False")); ALT_DEV_NO_QUESTS = Boolean.parseBoolean(General.getProperty("AltDevNoQuests", "False")); ALT_DEV_NO_SPAWNS = Boolean.parseBoolean(General.getProperty("AltDevNoSpawns", "False"));+ ALT_DEV_NO_CRON = Boolean.parseBoolean(General.getProperty("AltDevNoCron", "False")); THREAD_P_EFFECTS = Integer.parseInt(General.getProperty("ThreadPoolSizeEffects", "10")); THREAD_P_GENERAL = Integer.parseInt(General.getProperty("ThreadPoolSizeGeneral", "13")); IO_PACKET_THREAD_CORE_SIZE = Integer.parseInt(General.getProperty("UrgentPacketThreadCoreSize", "2"));Index: com/l2jserver/gameserver/GameServer.java===================================================================--- com/l2jserver/gameserver/GameServer.java (revision 4410)+++ com/l2jserver/gameserver/GameServer.java (working copy)@@ -464,6 +467,20 @@ _log.info("Server Loaded in " + ((serverLoadEnd - serverLoadStart) / 1000) + " seconds"); AutoAnnounceTaskManager.getInstance();+ + try+ {+ _log.info("Loading Cron Scripts...");+ File cron = new File(Config.DATAPACK_ROOT + "/data/cron.cfg");+ if(!Config.ALT_DEV_NO_CRON)+ L2ScriptEngineManager.getInstance().executeScriptList(cron);+ else+ _log.info("Loading Cron Scripts disabled by alternative configuration.");+ }+ catch (IOException ioe)+ {+ _log.severe("Failed loading cron.cfg, no script going to be loaded");+ } } public static void main(String[] args) throws Exception\ No newline at end of fileIndex: config/General.properties===================================================================--- config/General.properties (revision 4410)+++ config/General.properties (working copy)@@ -758,4 +758,8 @@ # Don't load spawntable. # Default: False AltDevNoSpawns = False++# Don't load cron.cfg+# Default: False+AltDevNoCron = False\ No newline at end of file[/diff]
DP:
[diff]### Eclipse Workspace Patch 1.0#P gameserverIndex: data/scripts/cron/OfflineTradeStore.java===================================================================--- data/scripts/cron/OfflineTradeStore.java (revision 0)+++ data/scripts/cron/OfflineTradeStore.java (revision 0)@@ -0,0 +1,49 @@+package cron;+ +import java.util.logging.Level;+import java.util.logging.Logger;++import com.l2jserver.Config;+import com.l2jserver.gameserver.ThreadPoolManager;+import com.l2jserver.gameserver.datatables.OfflineTradersTable;++/**+ * @author denser+ * @author ThE_PuNiSheR+ */+public class OfflineTradeStore+{+ public static final Logger _log = Logger.getLogger(OfflineTradeStore.class.getName());+ private long _init = 0;+ private long _delay = 1000 * 60 * 15;+ + public OfflineTradeStore()+ {+ ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new store(), _init, _delay); + }+ + private class store implements Runnable+ {+ public void run()+ {+ try+ {+ if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)+ {+ OfflineTradersTable.storeOffliners();+ _log.info("Offline traders stored via cron!");+ }+ }+ catch (Throwable t)+ {+ _log.log(Level.WARNING, "Error saving offline shops.", t);+ }+ }+ }+ + + public static void main(String[] args)+ {+ new OfflineTradeStore();+ }+}\ No newline at end of fileIndex: data/cron.cfg===================================================================--- data/cron.cfg (revision 0)+++ data/cron.cfg (revision 0)@@ -0,0 +1,4 @@+# Feel free to add here your own scripts++# CRON+cron/OfflineTradeStore.java\ No newline at end of file [/diff]
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
L2J - the place where glad to see you any time!