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
@@ -185,9 +185,7 @@ local function freezePlayer(id, freeze)
end
function loadScene(x, y, z)
if not NewLoadSceneStart then
return
end
if not NewLoadSceneStart then return end
NewLoadSceneStart(x, y, z, 0.0, 0.0, 0.0, 20.0, 0)
@@ -199,13 +197,11 @@ local spawnLock = false
-- spawns the current player at a certain spawn point index (or a random one, for that matter)
function spawnPlayer(spawnIdx, cb)
if spawnLock then
return
end
if spawnLock then return end
spawnLock = true
Citizen.CreateThread(function()
CreateThread(function()
-- if the spawn isn't set, select a random one
if not spawnIdx then
spawnIdx = GetRandomIntInRange(1, #spawnPoints + 1)
@@ -231,7 +227,7 @@ function spawnPlayer(spawnIdx, cb)
DoScreenFadeOut(500)
while not IsScreenFadedOut() do
Citizen.Wait(0)
Wait(0)
end
end
@@ -302,7 +298,7 @@ function spawnPlayer(spawnIdx, cb)
local time = GetGameTimer()
while (not HasCollisionLoadedAroundEntity(ped) and (GetGameTimer() - time) < 5000) do
Citizen.Wait(0)
Wait(0)
end
ShutdownLoadingScreen()
@@ -311,7 +307,7 @@ function spawnPlayer(spawnIdx, cb)
DoScreenFadeIn(500)
while not IsScreenFadedIn() do
Citizen.Wait(0)
Wait(0)
end
end
@@ -332,10 +328,10 @@ end
local respawnForced
local diedAt
Citizen.CreateThread(function()
CreateThread(function()
-- main loop thing
while true do
Citizen.Wait(50)
Wait(50)
local playerPed = PlayerPedId()