How to access to login`s database from gameserver?
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
How to access to login`s database from gameserver?
How to access to login database from gameserver?
Players have one account and they can play in few servers as in any other game, yes?
I have 2 gs and 1 ls. And also there are some things like Premium Account or some donate gold. And it should be related with whole account but not with some character.
Gameservers use different databases. So the most useful way is to save some special account`s data in loginserver`s database.
Aaand... The question is in thread name...
When I try to connect from gs, I get error like "gsDB.lsDB.accounts_data doesn`t exists" with qery like "SELECT * FROM lsDB.accounts_data ...". Scripts automatically put gameserver`s database`s name into a query. How to change this?
Players have one account and they can play in few servers as in any other game, yes?
I have 2 gs and 1 ls. And also there are some things like Premium Account or some donate gold. And it should be related with whole account but not with some character.
Gameservers use different databases. So the most useful way is to save some special account`s data in loginserver`s database.
Aaand... The question is in thread name...
When I try to connect from gs, I get error like "gsDB.lsDB.accounts_data doesn`t exists" with qery like "SELECT * FROM lsDB.accounts_data ...". Scripts automatically put gameserver`s database`s name into a query. How to change this?
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: How to access to login`s database from gameserver?
Login Server have established connection with each Game Server you can use it to get what do you need.
Here's example Changeset 4917
Here's example Changeset 4917
-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
You means that I have to create own loginserverpacket?
- Zoey76
- L2j Inner Circle
- Posts: 7008
- Joined: Tue Aug 11, 2009 3:36 am
Re: How to access to login`s database from gameserver?
Both a sendable and a receivable packets.Arantir wrote:You means that I have to create own loginserverpacket?
Powered by Eclipse 4.34
| Eclipse Temurin 21
| MariaDB 11.3.2
| L2J Server 2.6.3.0 - High Five 
Join our Discord! 

-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
Not so easy that I hope. Will try to do it.
Thanks for the answer.
And may I ask (don`t want create new thread), is there some way to check the ping (in milliseconds) from gs to user?
For example user send ".ping" and see "Your ping is ~62 ms now". I thought about it, but don`t find a way.
In earlier client of game there was a column "ping" in server selection menu. So some way must exists...
You need to send a current time to user and get it back, after than compare old and current time to get the time which it takes to send packet forward and back. But I don`t know how to compel client return packet with time...
Thanks for the answer.
And may I ask (don`t want create new thread), is there some way to check the ping (in milliseconds) from gs to user?
For example user send ".ping" and see "Your ping is ~62 ms now". I thought about it, but don`t find a way.
In earlier client of game there was a column "ping" in server selection menu. So some way must exists...
You need to send a current time to user and get it back, after than compare old and current time to get the time which it takes to send packet forward and back. But I don`t know how to compel client return packet with time...
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: How to access to login`s database from gameserver?
Actually there's retail feature about that.
There's NetPing packets with known structure just nobody implemented that yet
Server sends a packet with 3 d's as far as i remember
first was some randomly generated key
second and third i don't remember, and client responds with another packet the id which server sent him.
So you record somewhere when you sent server packet and when did u received the packet from client
so Received Time - Sent Time = ping
There's NetPing packets with known structure just nobody implemented that yet

Server sends a packet with 3 d's as far as i remember
first was some randomly generated key
second and third i don't remember, and client responds with another packet the id which server sent him.
So you record somewhere when you sent server packet and when did u received the packet from client
so Received Time - Sent Time = ping

-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
Yeah, now I know the name of this packet! =)
Found the packet structure in a gide for l2phx
maybe try to implement...
Found the packet structure in a gide for l2phx


Code: Select all
Server: Lenght 7 [NetPing]07 00 // length 7, constD9 // opcode D9, const99 BD 6A 0F // some ping ID Client: Lenght 15 [NetPing]0F 00 // length 15, constB1 // opcode B1, const99 BD 6A 0F // some ping ID02 00 00 00 // const?00 10 00 00 // const?
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: How to access to login`s database from gameserver?
other forks have been passing that NetPing code around for at least a year now, what do you mean - nobody implemented that yet?
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.
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: How to access to login`s database from gameserver?
When i joined l2j community i shared the some implementation from a russian fork (Don't remember the name)
viewtopic.php?f=72&t=18046
viewtopic.php?f=72&t=18046
UnAfraid wrote:It need's a big rework ..
-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
Hm... It was not hard to implement sending and receiving the packet... I already done it before saw your post.
What I have done:
It is enough to get current ping =)
What I have done:
Code: Select all
// ***serverpacket***:public NetPing(L2PcInstance activeChar) { // write current time activeChar.setEXData("pingTime", System.currentTimeMillis()+""); // EXData - my feature, some extra data for character - just an string array with 50 fields. very useful =)}protected void writeImpl() { writeC(0xd9); writeD(<some_id>); // i use constant =/} /// ***clienspacket***:protected void readImpl() { some_id = readD(); ping = readD(); // strange values returned 0_O... 5 msec one and 150 another time... // so I prefer to compare system time readD();}protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) return; long pingStart = Long.parseLong(activeChar.getEXData("pingTime")); long ping = pingStart - System.currentTimeMillis(); activeChar.sendMessage("Your ping is ~"+ping +"msec."); activeChar.setEXData("LatestPing", ping+"");} //*** handler ***/case 0xb1: // NetPing msg = new NetPing(); break; // ***some voiced***:if (command.equalsIgnoreCase("ping")){ activeChar.sendPacket(new NetPing(activeChar));}
-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
About the login`s database...
I expected something like. But if it will be implemented by the packets then returned value will be in a different thread...
It means than I have to create one more packet for any single query to login database such as ChangePassword.
Is there more universal way to access login`s base?
I expected something like
Code: Select all
ResultSet data = getFromLogin("SELECT ...");
It means than I have to create one more packet for any single query to login database such as ChangePassword.
Is there more universal way to access login`s base?
- tukune
- Posts: 533
- Joined: Sun Mar 29, 2009 2:35 pm
- Location: Japan
Re: How to access to login`s database from gameserver?

Code: Select all
Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://192.168.0.100:3306/l2jls", "root", "open-sesame");PreparedStatement statement = con.prepareStatement("SELECT ...");ResultSet data = statement.executeQuery();
-
- Posts: 151
- Joined: Wed Jan 04, 2012 7:10 pm
Re: How to access to login`s database from gameserver?
