This standalone FiveM playtime tracker connects to a MySQL database and logs player playtime from PlayersDB.json
(TxData). It’s packaged as an executable with no dependencies required - just configure the config.json
to start tracking and storing playtime.
I have packaged an exe version for simplicity, and included all open-source code for this merging tool.
For the executable version, please follow the instructions provided below. If you prefer to use the open-source version, ensure you have Node.js installed and correctly configure the config.json file.
Why use this script? Traditional resources often encounter issues when trying to access the playersdb.json file outside of the resources folder. This script offers a solution making it easier to work with. Use it if you face similar challenges.
- Formats and tracks player playtime data using a MySQL database and pre-defined target PlayersDB file.
- Automatically creates a table if it doesn't exist.
- Easy configuration through a
config.json
file. - Self-contained executable with no additional dependencies required.
- Windows 10/11 (not tested on older versions).
- MySQL Server installed and running.
- A correctly configured
config.json
file (see below).
## -----------------------------------------------------------------------------------------------------------------------------------------------
## ███████ ███████ ████████ ██ ██ ██████
## ██ ██ ██ ██ ██ ██ ██
## ███████ █████ ██ ██ ██ ██████
## ██ ██ ██ ██ ██ ██
## ███████ ███████ ██ ██████ ██
- Open the
config.json
file, and keep it in the same directory/folder asstorePlaytime.exe
. - Update the
dataFilePath
anddatabase
fields to match your environment:
```json
{
"dataFilePath": "D:/KMRP/localhost-server/txData/default/data/playersDB.json", //PlayersDB.json location
"database": {
"host": "localhost", //locahost or host name
"user": "root", //user or root
"password": "", //password or empty
"database": "qbcoreframework_0caee9" //database name
}
}
```
## -----------------------------------------------------------------------------------------------------------------------------------------------
## ██████ ██████ ███ ██ ███████
## ██ ██ ██ ██ ████ ██ ██
## ██ ██ ██ ██ ██ ██ ██ █████
## ██ ██ ██ ██ ██ ██ ██ ██
## ██████ ██████ ██ ████ ███████
-
Run
storePlaytime.exe
. -
The application will automatically:
- Connect to the MySQL database using the
config.json
settings. - Create the
player_playtimes
table if it doesn’t already exist. - Read player data from the specified
dataFilePath
. - Insert or update playtime records in the database if they are new or they exist.
- The console will show detailed logs, such as database connections, read operations, and any errors encountered, it wil lthen exit once complete.
- Connect to the MySQL database using the
- Run either my paid or free FiveM playtime resource (
td-playtime
) on your server. Links: (Completely free, but i offer a paid version) Free [Link - Tebex] Paid [Link - Tebex] - The script will automatically detect several notification resources and core frameworks, and print the detection results in the server console on startup, if none are detected no worries, it will default to chat output.
- Jump in-game and type
/playtime
to check your current playtime! 😊
## -----------------------------------------------------------------------------------------------------------------------------------------------
## ██ ███ ███ ██████ ██████ ██████ ████████ █████ ███ ██ ████████
## ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
## ██ ██ ████ ██ ██████ ██ ██ ██████ ██ ███████ ██ ██ ██ ██
## ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
## ██ ██ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ████ ██
You must run the exe storePlaytime.exe
each time you want to update playtime, its recommended to add it to the windows startup apps
-
Error:
ER_ACCESS_DENIED_ERROR
- This error occurs if the MySQL user or password is incorrect.
- Solution: Double-check the
user
andpassword
fields inconfig.json
and ensure they match the MySQL server.
-
Error:
ENOTFOUND
orECONNREFUSED
- This means the script is unable to connect to the MySQL server.
- Solution: Ensure MySQL is running and the
host
inconfig.json
is set to the correct IP address or hostname.
-
Missing
config.json
File- The executable won’t run without a valid
config.json
. - Solution: Make sure
config.json
is in the same directory as the executable and has the correct settings.
- The executable won’t run without a valid
-
No Playtime Data Processed
- If no data is processed, the
playersDB.json
file may be empty or not in the correct format. - Solution: Ensure the
dataFilePath
points to a valid JSON file with player data.
- If no data is processed, the
-
Can I run this on a different operating system?
- Currently, the executable is built for Windows. If you need a Linux or macOS version, sorry..
-
Does the executable support remote MySQL servers?
- Yes, you can use a remote MySQL server by updating the
host
field inconfig.json
to the server’s IP address.
- Yes, you can use a remote MySQL server by updating the
-
Is the source code available?
- This executable is distributed as a standalone file, and the source code is not included.