02.02.2014, 14:22
Quote:
Yup, that's the best option. You might want to add option for tablename prefixes (few small servers using same database).
|
I'm not only storing player-data in MySQL, but also alot of other things:
- speedcameras
- police stations
- gas-stations
- housing data
- locations
- cargo-types
- route-data for performing trucker routes for example
All that data is only loaded when the server starts and the data will be stored in arrays for fast access.
Most of that data is pretty static, unless the admin edits stuff in-game.
Let's say an admin creates a new speedcamera on server 1.
That script will hold the data for the new speedcamera in it's arrays and also the new speedcamera is stored in MySQL.
But server 2 (which already runs and has loaded the data on startup) doesn't know a new speedcamera is created in MySQL.
If an admin on server 2 would create a new speedcamera as well, the query fails to insert the data because that ID is already created.
But the speedcamera is created in the script, and next time server 1 will have the new speedcamera loaded properly, but server 2 has the same new speedcamera that was created on server 1, and the new camera created on server 2 is gone as it wasn't saved.
And I don't want to use MySQL queries all the time, as there are timers that run for multiple players every second to check the distance to ALL speedcams and see if they're speeding.
And the same problems will appear for all other data as well: houses, gas-stations, locations, route-data, ...
But I think you mean every server should have their own tables in the same database?
Server 1 could have "ppc_speedcameras" while server 2 uses "test_speedcameras" as table names, under the same database?
And the script needs to put "ppc_" in front of the tablenames for every query, for server 1, and server 2 puts "test_" in front of the table names?
Nice idea, I didn't know hosts did that as well.
I've never used MySQL before, and I also haven't hosted a server yet.
I only home-hosted my test-server.
EDIT:
Table-prefixes already implemented as it wasn't much to edit.