mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2026-11-10 13:57:18 +01:00
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:
@@ -1,19 +1,7 @@
|
||||
RegisterServerEvent('baseevents:onPlayerDied')
|
||||
RegisterServerEvent('baseevents:onPlayerKilled')
|
||||
RegisterServerEvent('baseevents:onPlayerWasted')
|
||||
RegisterServerEvent('baseevents:enteringVehicle')
|
||||
RegisterServerEvent('baseevents:enteringAborted')
|
||||
RegisterServerEvent('baseevents:enteredVehicle')
|
||||
RegisterServerEvent('baseevents:leftVehicle')
|
||||
|
||||
AddEventHandler('baseevents:onPlayerKilled', function(killedBy, data)
|
||||
local victim = source
|
||||
|
||||
RconLog({msgType = 'playerKilled', victim = victim, attacker = killedBy, data = data})
|
||||
end)
|
||||
|
||||
AddEventHandler('baseevents:onPlayerDied', function(killedBy, pos)
|
||||
local victim = source
|
||||
|
||||
RconLog({msgType = 'playerDied', victim = victim, attackerType = killedBy, pos = pos})
|
||||
end)
|
||||
RegisterNetEvent('baseevents:onPlayerWasted')
|
||||
RegisterNetEvent('baseevents:enteringVehicle')
|
||||
RegisterNetEvent('baseevents:enteringAborted')
|
||||
RegisterNetEvent('baseevents:enteredVehicle')
|
||||
RegisterNetEvent('baseevents:leftVehicle')
|
||||
RegisterNetEvent('baseevents:onPlayerKilled')
|
||||
RegisterNetEvent('baseevents:onPlayerDied')
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
RegisterNetEvent('runcode:gotSnippet')
|
||||
|
||||
AddEventHandler('runcode:gotSnippet', function(id, lang, code)
|
||||
RegisterNetEvent('runcode:gotSnippet', function(id, lang, code)
|
||||
local res, err = RunCode(lang, code)
|
||||
|
||||
if not err then
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
local openData
|
||||
|
||||
RegisterNetEvent('runcode:openUi')
|
||||
|
||||
AddEventHandler('runcode:openUi', function(options)
|
||||
RegisterNetEvent('runcode:openUi', function(options)
|
||||
openData = {
|
||||
type = 'open',
|
||||
options = options,
|
||||
@@ -48,9 +46,7 @@ RegisterNUICallback('runCodeInBand', function(args, cb)
|
||||
TriggerServerEvent('runcode:runInBand', id, args)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('runcode:inBandResult')
|
||||
|
||||
AddEventHandler('runcode:inBandResult', function(id, result)
|
||||
RegisterNetEvent('runcode:inBandResult', function(id, result)
|
||||
if rcCbs[id] then
|
||||
local cb = rcCbs[id]
|
||||
rcCbs[id] = nil
|
||||
|
||||
@@ -50,9 +50,7 @@ local function handleRunCode(data, res)
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('runcode:runInBand')
|
||||
|
||||
AddEventHandler('runcode:runInBand', function(id, data)
|
||||
RegisterNetEvent('runcode:runInBand', function(id, data)
|
||||
local s = source
|
||||
local privs = GetPrivs(s)
|
||||
|
||||
@@ -113,7 +111,7 @@ end
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(1000)
|
||||
|
||||
|
||||
if attempts > 0 and (GetGameTimer() - lastAttempt) > 5000 then
|
||||
attempts = 0
|
||||
lastAttempt = 0
|
||||
@@ -155,8 +153,7 @@ CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('runcode:gotResult')
|
||||
AddEventHandler('runcode:gotResult', returnCode)
|
||||
RegisterNetEvent('runcode:gotResult', returnCode)
|
||||
|
||||
SetHttpHandler(function(req, res)
|
||||
local path = req.path
|
||||
|
||||
Reference in New Issue
Block a user