-
Notifications
You must be signed in to change notification settings - Fork 0
How it connects
Let's build up the picture one step at a time.
Your server and your database are two separate programs. They might even be on two different machines. They need a way to talk:
[ open.mp server ] -------- ??? -------- [ MySQL server ]
(your gamemode) (your data)
What goes in the middle? Something has to:
- open a network connection to MySQL,
- speak MySQL's wire protocol,
- keep it secure (you don't want passwords sent in plain text),
- not freeze your game while waiting for the database.
That "something" is omp-MySQL.
[ open.mp server ] -- [ omp-MySQL component ] == TLS ==> [ MySQL server ]
your .pwn calls (the translator) 5.7 / 8.x / 9.x
mysql_execute(...) speaks MySQL + TLS,
runs it off the main thread
- Your Pawn code calls
mysql_*functions. - omp-MySQL turns them into real SQL, sends them over an encrypted (TLS) link.
- The
==>is always encrypted — omp-MySQL refuses to connect without TLS.
YOUR GAMEMODE (main thread) WORKER THREAD MYSQL
--------------------------- ------------- -----
1. mysql_execute(db,
"SELECT money ...", ---- hands the job to ---> (queue)
"OnMoneyLoaded")
2. sends SQL over TLS ---->
3. runs query
4. reads the rows <--------
... game keeps running ... (no lag on your server!)
5. next server tick: <--- result is ready ---
OnMoneyLoaded() is
called with the rows
The key idea: step 1 does not wait. Your server keeps ticking (players keep
moving, no freeze) while the worker thread does the slow network/database work.
When the answer comes back, omp-MySQL calls your callback (OnMoneyLoaded) on
the next tick. This is called an asynchronous (async) query.
If the query were synchronous (blocking), your whole server would freeze every time the database was slow — every player would lag. Async means one slow query never stops the game. omp-MySQL gives each connection its own worker thread, so queries run in the background.
[ omp-MySQL ] ===== encrypted tunnel (TLS 1.3 / 1.2) ===== [ MySQL ]
nobody on the network can read the
passwords or data going through
TLS is the same technology that puts the padlock in your web browser. omp-MySQL always uses it and refuses to connect if the server can't do TLS — so your players' hashed passwords and data are never sent in the clear.
your server machine
+-------------------------------------------------+
| [ omp-server ] |
| | loads |
| [ components/omp-mysql.dll | .so ] |
| | (+ bundled OpenSSL on Windows) |
| | async, TLS |
+-------|-----------------------------------------+
| encrypted MySQL protocol
v
+-------------------------------+
| [ MySQL server 5.7 / 8 / 9 ] | (same box, or anywhere on the network)
| accounts, vehicles, ... |
+-------------------------------+
Now you know what's happening under the hood. Next: Why omp-MySQL? → or jump to Getting started →.
Understand
Use
- Installing MySQL
- Docker Compose
- Getting started
- Configuration
- SQL crash course
- Designing your tables
- Storing game data
- Dates & times
- First queries
- Async patterns
- Reading results
- Prepared statements
- Passwords & hashing
- Transactions
- Models (active-record)
- Tutorial: login system
- mysql-admin demo
Deeper
Reference