How to access to login`s database from gameserver?

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

How to access to login`s database from gameserver?

Post by Arantir »

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?
User avatar
UnAfraid
L2j Veteran
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?

Post by UnAfraid »

Login Server have established connection with each Game Server you can use it to get what do you need.
Here's example Changeset 4917
Image
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

You means that I have to create own loginserverpacket?
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: How to access to login`s database from gameserver?

Post by Zoey76 »

Arantir wrote:You means that I have to create own loginserverpacket?
Both a sendable and a receivable packets.
Powered by Eclipse 4.30 🌌 | Eclipse Temurin 21 ☕ | MariaDB 11.3.2 🗃️ | L2J Server 2.6.3.0 - High Five 🚀

🔗 Join our Discord! 🎮💬
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

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...
User avatar
UnAfraid
L2j Veteran
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?

Post by UnAfraid »

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 :)
Image
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

Yeah, now I know the name of this packet! =)
Found the packet structure in a gide for l2phx :mrgreen: :mrgreen:

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?
maybe try to implement...
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: How to access to login`s database from gameserver?

Post by jurchiks »

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.
User avatar
UnAfraid
L2j Veteran
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?

Post by UnAfraid »

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
UnAfraid wrote:It need's a big rework .. :)
Image
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

Hm... It was not hard to implement sending and receiving the packet... I already done it before saw your post.
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));} 
It is enough to get current ping =)
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

About the login`s database...
I expected something like

Code: Select all

ResultSet data = getFromLogin("SELECT ...");
. 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?
User avatar
tukune
Posts: 533
Joined: Sun Mar 29, 2009 2:35 pm
Location: Japan

Re: How to access to login`s database from gameserver?

Post by tukune »

:idea:

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();
Arantir
Posts: 151
Joined: Wed Jan 04, 2012 7:10 pm

Re: How to access to login`s database from gameserver?

Post by Arantir »

:D exactly what i want!
Post Reply