WarTracker
WarTracker is a FiveM event tracking resource.
Use it to collect stats about what are your players doing to improve their experience.
How to Install
-
Download the latest version or clone it
- Add
start wartracker to your server.cfg
- Add
server_script '@wartracker/wartracker.lua' to your __resource.lua
- Add
server_script '@wartracker/wartracker_mysql.lua' to store events in database (for MySQL Async)
Usage
WarTracker.RegisterEvent('Jobs', 'jobFailed')
AddEventHandler('your_resource:jobFailed', function(jobName)
WarTracker.SendEvent('Jobs', 'jobFailed', jobName)
end)
WarTracker.RegisterEvent('Market', 'itemPurchased')
AddEventHandler('your_resource:itemPurchased', function(item, count)
WarTracker.SendEvent('Market', 'itemPurchased', { item = item, count = count })
end)
WarTracker.RegisterServerEvent('playerDropped')
API
--Events
AddEventHandler('wartracker:eventReported', function(category, name, event)
Citizen.Trace(event.time) --os.time()
Citizen.Trace(event.value)
end)
-- Functions
WarTracker.SetLogEnabled(enabled)
WarTracker.RegisterEvent(category, name)
WarTracker.SendEvent(category, name, value)
WarTracker.RegisterServerEvent(eventName)
WarTracker.GetEventCount()
WarTracker.ClearEvents()
-- wartracker_mysql.lua
WarTracker.MySQL.SetLogEnabled(enabled)
WarTracker.MySQL.SetDumpInterval(interval)
WarTracker.MySQL.SetDumpMinEventCount(count)
Changelog
1.1
- (MySQL) Use configurable deferred event queue dump
- New API
WarTracker.GetEventCount()
WarTracker.ClearEvents()
WarTracker.MySQL.SetLogEnabled(enabled)
WarTracker.MySQL.SetDumpInterval(interval)
WarTracker.MySQL.SetDumpMinEventCount(count)
1.0
5 Likes
This is kind of experimental resource and I’m ready to work on improving it.
Leave your feedback.
Interesting resource, I’m not sure if I will implement it but the idea seems cool and something really useful to improve a server without the owner having to ask.
Could explain for noobs what your resource does?
1 Like
With a lot of actions and a lot of players, seems that there will be a lot of MySQL queries all the time. This can cause problems.
I do similar so I would suggest to change your request to a post request somewhere, use that server to do the mysql, it’s more requirements but a much smaller load on the FiveM server.
@ApocGod this resource is for server developers.
It allows them to track any in-game statistics to understand how players are acting on their servers.
This information can help them to improve balance, game mechanics, UI etc.
@MJRamon thanks, I will fix it with the next release.
As soon as someone puts this on a function that runs frequently the server will screech to a halt. MySQL does not enjoy being hammered especially when it’s co-hosted with fxserver on a tiny VPS.
POST requests are not much better as PerformHttpRequest is pretty heavy on the server.
MySQL performance will be fixed with the next release and you will be able to test it by yourself 
POST with javascript, on the client 
Good luck, this is a tough challenge.
You can’t. Client is sandboxed. All external requests have to go through the server.
WarTracker 1.1
Changelog
- (MySQL) Use configurable deferred event queue dump
- New API
WarTracker.RegisterServerEvent(eventName)
WarTracker.GetEventCount()
WarTracker.ClearEvents()
WarTracker.MySQL.SetLogEnabled(enabled)
WarTracker.MySQL.SetDumpInterval(interval)
WarTracker.MySQL.SetDumpMinEventCount(count)
Notes
Use WarTracker.RegisterServerEvent(eventName) to track FiveM events with all their arguments as event.value
Use WarTracker.GetEventCount() and WarTracker.ClearEvents() to clear events after storing them (WarTracker.MySQL already doing it).
Default dumpInterval is 60000 ms and dumpMinEventCount is nil.
Adjust these options to optimize MySQL load if needed.
Performance logs are enabled by default.
Hm…It works…but how? For understanding…
I test it on esx_policejob open __resource.lua include the lines:
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Police Job'
version '1.3.0'
server_scripts {
'@mysql-async/lib/MySQL.lua',
'@es_extended/locale.lua',
'@wartracker/wartracker.lua',
'@wartracker/wartracker_mysql.lua',
'locales/de.lua',
'config.lua',
'server/main.lua'
}
client_scripts {
'@es_extended/locale.lua',
'locales/de.lua',
'config.lua',
'client/main.lua'
}
dependencies {
'es_extended',
'esx_datastore',
'jsfour-register',
'esx_billing'
}
start server with comand server.cfg and it create a table in DB. Run 20 mins as cop in the city, do some stuff and open the db and see nothing inside…
…what will be insert there, please?
This resource is for server DEVELOPERS.
You should use API to specify what exact events would you like to track.
Thats my question … hm maybe so:
WHERE I use the API and I know what a dev is #smile can you imagine that these may also be on the line sometime 
Have you actually added the functions to the script that are required to log the data?
There are examples in the topic on how to use it (Under Usage)
This is not something where you just simply “install” and it does everything for you.