Code modernize (#234)

* refactor: declare exports at runtime and drop the player-data provides alias

Signed-off-by: Mathu-lmn <[email protected]>

* refactor: pass handlers directly to RegisterNetEvent

Signed-off-by: Mathu-lmn <[email protected]>

* refactor: use CreateThread/Wait without the Citizen prefix

Signed-off-by: Mathu-lmn <[email protected]>

* chore: remove trailing whitespace, stray lines and unused locals

Signed-off-by: Mathu-lmn <[email protected]>

---------

Signed-off-by: Mathu-lmn <[email protected]>
This commit is contained in:
Mathu-lmn
2026-09-23 21:00:01 +02:00
committed by GitHub
parent 2935a6ba1d
commit 39b91b14ce
23 changed files with 64 additions and 137 deletions
@@ -80,14 +80,12 @@ local function handleFountainStuff(source, id, pickup)
end
-- event for picking up fountain->player
RegisterNetEvent('money_fountain:tryPickup')
AddEventHandler('money_fountain:tryPickup', function(id)
RegisterNetEvent('money_fountain:tryPickup', function(id)
handleFountainStuff(source, id, true)
end)
-- event for donating player->fountain
RegisterNetEvent('money_fountain:tryPlace')
AddEventHandler('money_fountain:tryPlace', function(id)
RegisterNetEvent('money_fountain:tryPlace', function(id)
handleFountainStuff(source, id, false)
end)
@@ -3,9 +3,7 @@ local moneyTypes = {
bank = `BANK_BALANCE`,
}
RegisterNetEvent('money:displayUpdate')
AddEventHandler('money:displayUpdate', function(type, money)
RegisterNetEvent('money:displayUpdate', function(type, money)
local stat = moneyTypes[type]
if not stat then return end
StatSetInt(stat, math.floor(money))
@@ -12,5 +12,6 @@ game 'gta5'
client_script 'client.lua'
server_script 'server.lua'
--dependency 'cfx.re/playerData.v1alpha1'
lua54 'yes'
dependency 'player-data'
@@ -1,4 +1,4 @@
local playerData = exports['cfx.re/playerData.v1alpha1']
local playerData = exports['player-data']
local validMoneyTypes = {
bank = true,
@@ -88,9 +88,7 @@ AddEventHandler('money:updated', function(data)
end
end)
RegisterNetEvent('money:requestDisplay')
AddEventHandler('money:requestDisplay', function()
RegisterNetEvent('money:requestDisplay', function()
local source = source
local playerId = playerData:getPlayerId(source)
@@ -1,7 +1,6 @@
AddEventHandler('gameEventTriggered', function(eventName, args)
if eventName == 'CEventNetworkEntityDamage' then
local victim = args[1]
local culprit = args[2]
local isDead = args[6] == 1
if isDead then
@@ -1,8 +1,6 @@
local safePositions = {}
RegisterNetEvent('money:allowPickupNear')
AddEventHandler('money:allowPickupNear', function(pedId)
RegisterNetEvent('money:allowPickupNear', function(pedId)
local entity = NetworkGetEntityFromNetworkId(pedId)
Wait(250)
@@ -19,9 +17,7 @@ AddEventHandler('money:allowPickupNear', function(pedId)
safePositions[pedId] = coords
end)
RegisterNetEvent('money:tryPickup')
AddEventHandler('money:tryPickup', function(entity)
RegisterNetEvent('money:tryPickup', function(entity)
if not safePositions[entity] then
return
end