diff --git a/client/module/modules/drift_counter.lua b/client/module/modules/drift_counter.lua index 47fd22b..178103e 100644 --- a/client/module/modules/drift_counter.lua +++ b/client/module/modules/drift_counter.lua @@ -36,6 +36,9 @@ function Modules.DriftCounter.GetCurrentAngle() end end +function Modules.DriftCounter.SendDriftDataToServer(points) + TriggerServerEvent('drift:logToDiscord', points) +end -- Cleaning the cache to avoid any memory leak as the system will load up every vehicule entity the player goes in. If the entity is deleted or not in range it will be removed from the list to avoid memory leaks function Modules.DriftCounter.CleanUpCache() for veh, allowed in pairs(Modules.DriftCounter.CachedAllowedVeh) do @@ -94,6 +97,7 @@ function Modules.DriftCounter.StartChainBreakLoop() Modules.DriftCounter.FadeInHud() end TriggerEvent(ConfigShared.DriftStartEvent) + Citizen.CreateThread(function() Modules.Utils.RealWait(Modules.DriftCounter.ChainCooldown, function(cb, timeLeft) Modules.DriftCounter.ChainTimeLeft = timeLeft - (timeLeft * 2) -- Duh @@ -101,10 +105,15 @@ function Modules.DriftCounter.StartChainBreakLoop() cb(false, ConfigShared.DriftChainTime) end end) + + -- Once the drift ends and before resetting the variables, log the points if ConfigShared.UseDefaultUI then Modules.DriftCounter.FadeOutHud() end TriggerEvent(ConfigShared.DriftFinishedEvent, Modules.DriftCounter.CurrentPoints) + Modules.DriftCounter.SendDriftDataToServer(Modules.DriftCounter.CurrentPoints) -- Add this line here + + -- Resetting the drift variables Modules.DriftCounter.ChainCooldown = ConfigShared.DriftChainTime Modules.DriftCounter.ChainLoopStarted = false Modules.DriftCounter.CurrentPoints = 0 @@ -114,6 +123,7 @@ function Modules.DriftCounter.StartChainBreakLoop() end end + function Modules.DriftCounter.FadeInHud() Citizen.CreateThread(function() Modules.DriftCounter.InAnimation = true @@ -191,3 +201,4 @@ end) AddEventHandler(ConfigShared.ToggleEvent, function() Modules.DriftCounter.IsEnabled = not Modules.DriftCounter.IsEnabled end) + diff --git a/config/config_shared.lua b/config/config_shared.lua index b595380..a04a0ff 100644 --- a/config/config_shared.lua +++ b/config/config_shared.lua @@ -1,7 +1,7 @@ ConfigShared = {} ConfigShared.devmod = false -- Keep the UI on by default, usefull when tweaking UI ConfigShared.UseDefaultUI = true -- Set this to false if you want to use your own UI - +ConfigShared.DiscordLog = 'WEBHOOK HERE' ConfigShared.DriftChainTime = 5000 -- Time in MS ConfigShared.AddStaticPointOnDrifting = true -- Add a static number of point on every frame when the player is drifting diff --git a/fxmanifest.lua b/fxmanifest.lua index 349d602..683fcd0 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -13,6 +13,10 @@ client_scripts { "client/module/modules/ui_native_pages/*.lua", } +server_scripts { + "server.lua" +} + -- server_scripts { -- "server/modules/*.lua", -- } \ No newline at end of file diff --git a/server.lua b/server.lua new file mode 100644 index 0000000..6b02715 --- /dev/null +++ b/server.lua @@ -0,0 +1,20 @@ +-- server.lua +RegisterServerEvent('drift:logToDiscord') +AddEventHandler('drift:logToDiscord', function(points) + local discordWebhook = ConfigShared.DiscordLog -- Replace with your webhook URL + local playerName = GetPlayerName(source) + local playerIdentifier = GetPlayerIdentifier(source, 0) -- 0 for license identifier + + local message = { + { + ["color"] = 16711680, + ["title"] = "**Drift Points Logged**", + ["description"] = "Player: " .. playerName .. "\nSteam License: " .. playerIdentifier .. "\nPoints: " .. points, + ["footer"] = { + ["text"] = "Drift Logging System By Clin", + }, + } + } + + PerformHttpRequest(discordWebhook, function(err, text, headers) end, 'POST', json.encode({username = 'Drift Logger', embeds = message}), { ['Content-Type'] = 'application/json' }) +end)