Compare commits

..
4 Commits
Author SHA1 Message Date
MattiandGitHub c6afa3909c fix(runcode): timeout sweep and ped-money-drops cleanup (#231)
* fix(runcode): use pairs for codes timeout sweep

Signed-off-by: matti.bat <[email protected]>

* fix(ped-money-drops): match entityRemoved cleanup key

Signed-off-by: matti.bat <[email protected]>

---------

Signed-off-by: matti.bat <[email protected]>
2026-09-23 21:52:35 +02:00
Mathu-lmnandGitHub 39b91b14ce 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]>
2026-09-23 21:00:01 +02:00
Mathu-lmnandGitHub 2935a6ba1d Misc fixes (#233)
* fix(spawnmanager): correct native arguments and enable ped model check

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

* fix(mapmanager): restrict the gametype command

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

* fix(example-loadscreen): handle unknown init types such as INIT_CORE

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

---------

Signed-off-by: Mathu-lmn <[email protected]>
2026-09-23 20:59:47 +02:00
Mathu-lmnandGitHub 478ba4a47d chore: bump fx_version to cerulean (#232)
Signed-off-by: Mathu-lmn <[email protected]>
2026-09-23 20:58:04 +02:00
32 changed files with 92 additions and 170 deletions
@@ -10,5 +10,5 @@ resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
map 'map.lua' map 'map.lua'
fx_version 'adamant' fx_version 'cerulean'
games { 'gta5', 'gta5enhanced' } games { 'gta5', 'gta5enhanced' }
@@ -59,5 +59,3 @@ spawnpoint 'a_m_y_hipster_01' { x = 714.109, y = 4151.15, z = 35.7792 }
spawnpoint 'a_m_y_hipster_02' { x = -103.651, y = -967.93, z = 296.52 } spawnpoint 'a_m_y_hipster_02' { x = -103.651, y = -967.93, z = 296.52 }
spawnpoint 'a_m_y_hipster_01' { x = -265.333, y = -2419.35, z = 122.366 } spawnpoint 'a_m_y_hipster_01' { x = -265.333, y = -2419.35, z = 122.366 }
spawnpoint 'a_m_y_hipster_02' { x = 1788.25, y = 3890.34, z = 34.3849 } spawnpoint 'a_m_y_hipster_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
--
@@ -10,5 +10,5 @@ resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
map 'map.lua' map 'map.lua'
fx_version 'adamant' fx_version 'cerulean'
games { 'gta5', 'gta5enhanced' } games { 'gta5', 'gta5enhanced' }
@@ -58,5 +58,3 @@ spawnpoint 'a_m_y_skater_01' { x = 714.109, y = 4151.15, z = 35.7792 }
spawnpoint 'a_m_y_skater_02' { x = -103.651, y = -967.93, z = 296.52 } spawnpoint 'a_m_y_skater_02' { x = -103.651, y = -967.93, z = 296.52 }
spawnpoint 'a_m_y_skater_01' { x = -265.333, y = -2419.35, z = 122.366 } spawnpoint 'a_m_y_skater_01' { x = -265.333, y = -2419.35, z = 122.366 }
spawnpoint 'a_m_y_skater_02' { x = 1788.25, y = 3890.34, z = 34.3849 } spawnpoint 'a_m_y_skater_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
--
@@ -10,7 +10,7 @@ resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
map 'map.lua' map 'map.lua'
fx_version 'adamant' fx_version 'cerulean'
game 'rdr3' game 'rdr3'
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
@@ -11,4 +11,4 @@ resource_type 'gametype' { name = 'Freeroam' }
client_script 'basic_client.lua' client_script 'basic_client.lua'
game 'common' game 'common'
fx_version 'adamant' fx_version 'cerulean'
@@ -6,7 +6,7 @@ description 'An example money system client containing a money fountain.'
repository 'https://github.com/citizenfx/cfx-server-data' repository 'https://github.com/citizenfx/cfx-server-data'
author 'Cfx.re <[email protected]>' author 'Cfx.re <[email protected]>'
fx_version 'bodacious' fx_version 'cerulean'
game 'gta5' game 'gta5'
client_script 'client.lua' client_script 'client.lua'
@@ -80,14 +80,12 @@ local function handleFountainStuff(source, id, pickup)
end end
-- event for picking up fountain->player -- event for picking up fountain->player
RegisterNetEvent('money_fountain:tryPickup') RegisterNetEvent('money_fountain:tryPickup', function(id)
AddEventHandler('money_fountain:tryPickup', function(id)
handleFountainStuff(source, id, true) handleFountainStuff(source, id, true)
end) end)
-- event for donating player->fountain -- event for donating player->fountain
RegisterNetEvent('money_fountain:tryPlace') RegisterNetEvent('money_fountain:tryPlace', function(id)
AddEventHandler('money_fountain:tryPlace', function(id)
handleFountainStuff(source, id, false) handleFountainStuff(source, id, false)
end) end)
@@ -3,9 +3,7 @@ local moneyTypes = {
bank = `BANK_BALANCE`, bank = `BANK_BALANCE`,
} }
RegisterNetEvent('money:displayUpdate') RegisterNetEvent('money:displayUpdate', function(type, money)
AddEventHandler('money:displayUpdate', function(type, money)
local stat = moneyTypes[type] local stat = moneyTypes[type]
if not stat then return end if not stat then return end
StatSetInt(stat, math.floor(money)) StatSetInt(stat, math.floor(money))
@@ -6,11 +6,12 @@ description 'An example money system using KVS.'
repository 'https://github.com/citizenfx/cfx-server-data' repository 'https://github.com/citizenfx/cfx-server-data'
author 'Cfx.re <[email protected]>' author 'Cfx.re <[email protected]>'
fx_version 'bodacious' fx_version 'cerulean'
game 'gta5' game 'gta5'
client_script 'client.lua' client_script 'client.lua'
server_script 'server.lua' server_script 'server.lua'
--dependency 'cfx.re/playerData.v1alpha1'
lua54 'yes' lua54 'yes'
dependency 'player-data'
@@ -1,4 +1,4 @@
local playerData = exports['cfx.re/playerData.v1alpha1'] local playerData = exports['player-data']
local validMoneyTypes = { local validMoneyTypes = {
bank = true, bank = true,
@@ -88,9 +88,7 @@ AddEventHandler('money:updated', function(data)
end end
end) end)
RegisterNetEvent('money:requestDisplay') RegisterNetEvent('money:requestDisplay', function()
AddEventHandler('money:requestDisplay', function()
local source = source local source = source
local playerId = playerData:getPlayerId(source) local playerId = playerData:getPlayerId(source)
@@ -1,7 +1,6 @@
AddEventHandler('gameEventTriggered', function(eventName, args) AddEventHandler('gameEventTriggered', function(eventName, args)
if eventName == 'CEventNetworkEntityDamage' then if eventName == 'CEventNetworkEntityDamage' then
local victim = args[1] local victim = args[1]
local culprit = args[2]
local isDead = args[6] == 1 local isDead = args[6] == 1
if isDead then if isDead then
@@ -6,7 +6,7 @@ description 'An example money system client.'
author 'Cfx.re <[email protected]>' author 'Cfx.re <[email protected]>'
repository 'https://github.com/citizenfx/cfx-server-data' repository 'https://github.com/citizenfx/cfx-server-data'
fx_version 'bodacious' fx_version 'cerulean'
game 'gta5' game 'gta5'
client_script 'client.lua' client_script 'client.lua'
@@ -1,8 +1,6 @@
local safePositions = {} local safePositions = {}
RegisterNetEvent('money:allowPickupNear') RegisterNetEvent('money:allowPickupNear', function(pedId)
AddEventHandler('money:allowPickupNear', function(pedId)
local entity = NetworkGetEntityFromNetworkId(pedId) local entity = NetworkGetEntityFromNetworkId(pedId)
Wait(250) Wait(250)
@@ -19,9 +17,7 @@ AddEventHandler('money:allowPickupNear', function(pedId)
safePositions[pedId] = coords safePositions[pedId] = coords
end) end)
RegisterNetEvent('money:tryPickup') RegisterNetEvent('money:tryPickup', function(entity)
AddEventHandler('money:tryPickup', function(entity)
if not safePositions[entity] then if not safePositions[entity] then
return return
end end
@@ -38,5 +34,5 @@ AddEventHandler('money:tryPickup', function(entity)
end) end)
AddEventHandler('entityRemoved', function(entity) AddEventHandler('entityRemoved', function(entity)
safePositions[entity] = nil safePositions[NetworkGetNetworkIdFromEntity(entity)] = nil
end) end)
@@ -6,11 +6,7 @@ description 'A basic resource for storing player identifiers.'
author 'Cfx.re <[email protected]>' author 'Cfx.re <[email protected]>'
repository 'https://github.com/citizenfx/cfx-server-data' repository 'https://github.com/citizenfx/cfx-server-data'
fx_version 'bodacious' fx_version 'cerulean'
game 'common' game 'common'
server_script 'server.lua' server_script 'server.lua'
provides {
'cfx.re/playerData.v1alpha1'
}
+4 -21
View File
@@ -3,7 +3,7 @@
-- it works in a fairly simple way: a set of identifiers is assigned to an account ID, and said -- it works in a fairly simple way: a set of identifiers is assigned to an account ID, and said
-- account ID is then returned/added as state bag -- account ID is then returned/added as state bag
-- --
-- it also implements the `cfx.re/playerData.v1alpha1` spec, which is exposed through the following: -- it also implements the `player-data` spec, which is exposed through the following:
-- - getPlayerId(source: string) -- - getPlayerId(source: string)
-- - getPlayerById(dbId: string) -- - getPlayerById(dbId: string)
-- - getPlayerIdFromIdentifier(identifier: string) -- - getPlayerIdFromIdentifier(identifier: string)
@@ -130,8 +130,6 @@ AddEventHandler('playerConnecting', function()
end) end)
-- and migrate them to a 'joining' ID where possible -- and migrate them to a 'joining' ID where possible
RegisterNetEvent('playerJoining')
AddEventHandler('playerJoining', function(oldIdx) AddEventHandler('playerJoining', function(oldIdx)
-- resource restart race condition -- resource restart race condition
local oldPlayer = players[tostring(oldIdx)] local oldPlayer = players[tostring(oldIdx)]
@@ -189,25 +187,10 @@ RegisterCommand('playerData', function(source, args)
end end
end, true) end, true)
-- COMPATIBILITY for server versions that don't export provide
local function getExportEventName(resource, name)
return string.format('__cfx_export_%s_%s', resource, name)
end
function AddExport(name, fn)
if not Citizen.Traits or not Citizen.Traits.ProvidesExports then
AddEventHandler(getExportEventName('cfx.re/playerData.v1alpha1', name), function(setCB)
setCB(fn)
end)
end
exports(name, fn)
end
-- exports -- exports
AddExport('getPlayerIdFromIdentifier', getPlayerIdFromIdentifier) exports('getPlayerIdFromIdentifier', getPlayerIdFromIdentifier)
AddExport('getPlayerId', function(playerIdx) exports('getPlayerId', function(playerIdx)
local player = players[tostring(playerIdx)] local player = players[tostring(playerIdx)]
if not player then if not player then
@@ -217,6 +200,6 @@ AddExport('getPlayerId', function(playerIdx)
return player.dbId return player.dbId
end) end)
AddExport('getPlayerById', function(playerId) exports('getPlayerById', function(playerId)
return playersById[tostring(playerId)] return playersById[tostring(playerId)]
end) end)
@@ -13,24 +13,11 @@ server_script 'playernames_api.lua'
client_script 'playernames_cl.lua' client_script 'playernames_cl.lua'
server_script 'playernames_sv.lua' server_script 'playernames_sv.lua'
-- make exports
local exportList = {
'setComponentColor',
'setComponentAlpha',
'setComponentVisibility',
'setWantedLevel',
'setHealthBarColor',
'setNameTemplate'
}
exports(exportList)
server_exports(exportList)
-- add files -- add files
files { files {
'template/template.lua' 'template/template.lua'
} }
-- support the latest resource manifest -- support the latest resource manifest
fx_version 'adamant' fx_version 'cerulean'
game 'gta5' game 'gta5'
@@ -42,6 +42,13 @@ setHealthBarColor = getTriggerFunction('sehc')
setNameTemplate = getTriggerFunction('tpl') setNameTemplate = getTriggerFunction('tpl')
setName = getTriggerFunction('name') setName = getTriggerFunction('name')
exports('setComponentColor', setComponentColor)
exports('setComponentAlpha', setComponentAlpha)
exports('setComponentVisibility', setComponentVisibility)
exports('setWantedLevel', setWantedLevel)
exports('setHealthBarColor', setHealthBarColor)
exports('setNameTemplate', setNameTemplate)
if not io then if not io then
io = { write = nil, open = nil } io = { write = nil, open = nil }
end end
@@ -142,9 +142,7 @@ local function getSettings(id)
return mpGamerTagSettings[i] return mpGamerTagSettings[i]
end end
RegisterNetEvent('playernames:configure') RegisterNetEvent('playernames:configure', function(id, key, ...)
AddEventHandler('playernames:configure', function(id, key, ...)
local args = table.pack(...) local args = table.pack(...)
if key == 'tglc' then if key == 'tglc' then
@@ -183,7 +181,7 @@ AddEventHandler('onResourceStop', function(name)
end end
end) end)
SetTimeout(0, function() CreateThread(function()
TriggerServerEvent('playernames:init') TriggerServerEvent('playernames:init')
end) end)
@@ -37,8 +37,7 @@ AddEventHandler('playerDropped', function()
activePlayers[source] = nil activePlayers[source] = nil
end) end)
RegisterNetEvent('playernames:init') RegisterNetEvent('playernames:init', function()
AddEventHandler('playernames:init', function()
reconfigure(source) reconfigure(source)
activePlayers[source] = true activePlayers[source] = true
end) end)
+5 -17
View File
@@ -6,25 +6,13 @@ author 'Cfx.re <[email protected]>'
description 'A flexible handler for game type/map association.' description 'A flexible handler for game type/map association.'
repository 'https://github.com/citizenfx/cfx-server-data' repository 'https://github.com/citizenfx/cfx-server-data'
client_scripts { client_script 'mapmanager_client.lua'
"mapmanager_shared.lua",
"mapmanager_client.lua"
}
server_scripts { server_script 'mapmanager_server.lua'
"mapmanager_shared.lua",
"mapmanager_server.lua"
}
fx_version 'adamant' shared_script 'mapmanager_shared.lua'
fx_version 'cerulean'
games { 'gta5', 'rdr3' } games { 'gta5', 'rdr3' }
server_export "getCurrentGameType"
server_export "getCurrentMap"
server_export "changeGameType"
server_export "changeMap"
server_export "doesMapSupportGameType"
server_export "getMaps"
server_export "roundEnded"
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
@@ -40,8 +40,8 @@ AddEventHandler('onClientResourceStart', function(res)
loadMap(res) loadMap(res)
-- defer this to the next game tick to work around a lack of dependencies -- defer this to the next game tick to work around a lack of dependencies
Citizen.CreateThread(function() CreateThread(function()
Citizen.Wait(15) Wait(15)
if maps[res] then if maps[res] then
TriggerEvent('onClientMapStart', res) TriggerEvent('onClientMapStart', res)
@@ -264,7 +264,7 @@ RegisterCommand("gametype", function(source, args)
end end
changeGameType(args[1]) changeGameType(args[1])
print('gametype ' .. args[1] .. "\n") print('gametype ' .. args[1] .. "\n")
end) end, true)
function getCurrentGameType() function getCurrentGameType()
return currentGameType return currentGameType
@@ -313,3 +313,11 @@ function doesMapSupportGameType(gameType, map)
return maps[map].gameTypes[gameType] return maps[map].gameTypes[gameType]
end end
exports('getCurrentGameType', getCurrentGameType)
exports('getCurrentMap', getCurrentMap)
exports('changeGameType', changeGameType)
exports('changeMap', changeMap)
exports('doesMapSupportGameType', doesMapSupportGameType)
exports('getMaps', getMaps)
exports('roundEnded', roundEnded)
@@ -8,7 +8,7 @@ repository 'https://github.com/citizenfx/cfx-server-data'
client_script 'spawnmanager.lua' client_script 'spawnmanager.lua'
fx_version 'adamant' fx_version 'cerulean'
games { 'rdr3', 'gta5' } games { 'rdr3', 'gta5' }
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.' rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
@@ -41,7 +41,7 @@ AddEventHandler('getMapDirectives', function(add)
-- recalculate the model for storage -- recalculate the model for storage
if not tonumber(model) then if not tonumber(model) then
model = GetHashKey(model, _r) model = GetHashKey(model)
end end
-- store the spawn data in the state so we can erase it later on -- store the spawn data in the state so we can erase it later on
@@ -110,11 +110,10 @@ function addSpawnPoint(spawn)
error("invalid spawn model") error("invalid spawn model")
end end
-- is is even a ped? -- is the model a ped?
-- not in V? if not IsModelAPed(model) then
--[[if not IsThisModelAPed(model) then
error("this model ain't a ped!") error("this model ain't a ped!")
end]] end
-- overwrite the model in case we hashed it -- overwrite the model in case we hashed it
spawn.model = model spawn.model = model
@@ -153,17 +152,17 @@ end
-- function as existing in original R* scripts -- function as existing in original R* scripts
local function freezePlayer(id, freeze) local function freezePlayer(id, freeze)
local player = id local player = id
SetPlayerControl(player, not freeze, false) SetPlayerControl(player, not freeze, 0)
local ped = GetPlayerPed(player) local ped = GetPlayerPed(player)
if not freeze then if not freeze then
if not IsEntityVisible(ped) then if not IsEntityVisible(ped) then
SetEntityVisible(ped, true) SetEntityVisible(ped, true, false)
end end
if not IsPedInAnyVehicle(ped) then if not IsPedInAnyVehicle(ped, false) then
SetEntityCollision(ped, true) SetEntityCollision(ped, true, true)
end end
FreezeEntityPosition(ped, false) FreezeEntityPosition(ped, false)
@@ -171,14 +170,13 @@ local function freezePlayer(id, freeze)
SetPlayerInvincible(player, false) SetPlayerInvincible(player, false)
else else
if IsEntityVisible(ped) then if IsEntityVisible(ped) then
SetEntityVisible(ped, false) SetEntityVisible(ped, false, false)
end end
SetEntityCollision(ped, false) SetEntityCollision(ped, false, false)
FreezeEntityPosition(ped, true) FreezeEntityPosition(ped, true)
--SetCharNeverTargetted(ped, true) --SetCharNeverTargetted(ped, true)
SetPlayerInvincible(player, true) SetPlayerInvincible(player, true)
--RemovePtfxFromPed(ped)
if not IsPedFatallyInjured(ped) then if not IsPedFatallyInjured(ped) then
ClearPedTasksImmediately(ped) ClearPedTasksImmediately(ped)
@@ -187,17 +185,11 @@ local function freezePlayer(id, freeze)
end end
function loadScene(x, y, z) function loadScene(x, y, z)
if not NewLoadSceneStart then if not NewLoadSceneStart then return end
return
end
NewLoadSceneStart(x, y, z, 0.0, 0.0, 0.0, 20.0, 0) NewLoadSceneStart(x, y, z, 0.0, 0.0, 0.0, 20.0, 0)
while IsNewLoadSceneActive() do while IsNewLoadSceneActive() do NetworkUpdateLoadScene() end
networkTimer = GetNetworkTimer()
NetworkUpdateLoadScene()
end
end end
-- to prevent trying to spawn multiple times -- to prevent trying to spawn multiple times
@@ -205,13 +197,11 @@ local spawnLock = false
-- spawns the current player at a certain spawn point index (or a random one, for that matter) -- spawns the current player at a certain spawn point index (or a random one, for that matter)
function spawnPlayer(spawnIdx, cb) function spawnPlayer(spawnIdx, cb)
if spawnLock then if spawnLock then return end
return
end
spawnLock = true spawnLock = true
Citizen.CreateThread(function() CreateThread(function()
-- if the spawn isn't set, select a random one -- if the spawn isn't set, select a random one
if not spawnIdx then if not spawnIdx then
spawnIdx = GetRandomIntInRange(1, #spawnPoints + 1) spawnIdx = GetRandomIntInRange(1, #spawnPoints + 1)
@@ -237,7 +227,7 @@ function spawnPlayer(spawnIdx, cb)
DoScreenFadeOut(500) DoScreenFadeOut(500)
while not IsScreenFadedOut() do while not IsScreenFadedOut() do
Citizen.Wait(0) Wait(0)
end end
end end
@@ -308,7 +298,7 @@ function spawnPlayer(spawnIdx, cb)
local time = GetGameTimer() local time = GetGameTimer()
while (not HasCollisionLoadedAroundEntity(ped) and (GetGameTimer() - time) < 5000) do while (not HasCollisionLoadedAroundEntity(ped) and (GetGameTimer() - time) < 5000) do
Citizen.Wait(0) Wait(0)
end end
ShutdownLoadingScreen() ShutdownLoadingScreen()
@@ -317,7 +307,7 @@ function spawnPlayer(spawnIdx, cb)
DoScreenFadeIn(500) DoScreenFadeIn(500)
while not IsScreenFadedIn() do while not IsScreenFadedIn() do
Citizen.Wait(0) Wait(0)
end end
end end
@@ -338,10 +328,10 @@ end
local respawnForced local respawnForced
local diedAt local diedAt
Citizen.CreateThread(function() CreateThread(function()
-- main loop thing -- main loop thing
while true do while true do
Citizen.Wait(50) Wait(50)
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
+1 -1
View File
@@ -10,5 +10,5 @@ client_script 'deathevents.lua'
client_script 'vehiclechecker.lua' client_script 'vehiclechecker.lua'
server_script 'server.lua' server_script 'server.lua'
fx_version 'adamant' fx_version 'cerulean'
game 'gta5' game 'gta5'
+7 -19
View File
@@ -1,19 +1,7 @@
RegisterServerEvent('baseevents:onPlayerDied') RegisterNetEvent('baseevents:onPlayerWasted')
RegisterServerEvent('baseevents:onPlayerKilled') RegisterNetEvent('baseevents:enteringVehicle')
RegisterServerEvent('baseevents:onPlayerWasted') RegisterNetEvent('baseevents:enteringAborted')
RegisterServerEvent('baseevents:enteringVehicle') RegisterNetEvent('baseevents:enteredVehicle')
RegisterServerEvent('baseevents:enteringAborted') RegisterNetEvent('baseevents:leftVehicle')
RegisterServerEvent('baseevents:enteredVehicle') RegisterNetEvent('baseevents:onPlayerKilled')
RegisterServerEvent('baseevents:leftVehicle') RegisterNetEvent('baseevents:onPlayerDied')
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)
+1 -3
View File
@@ -1,6 +1,4 @@
RegisterNetEvent('runcode:gotSnippet') RegisterNetEvent('runcode:gotSnippet', function(id, lang, code)
AddEventHandler('runcode:gotSnippet', function(id, lang, code)
local res, err = RunCode(lang, code) local res, err = RunCode(lang, code)
if not err then if not err then
+2 -6
View File
@@ -1,8 +1,6 @@
local openData local openData
RegisterNetEvent('runcode:openUi') RegisterNetEvent('runcode:openUi', function(options)
AddEventHandler('runcode:openUi', function(options)
openData = { openData = {
type = 'open', type = 'open',
options = options, options = options,
@@ -48,9 +46,7 @@ RegisterNUICallback('runCodeInBand', function(args, cb)
TriggerServerEvent('runcode:runInBand', id, args) TriggerServerEvent('runcode:runInBand', id, args)
end) end)
RegisterNetEvent('runcode:inBandResult') RegisterNetEvent('runcode:inBandResult', function(id, result)
AddEventHandler('runcode:inBandResult', function(id, result)
if rcCbs[id] then if rcCbs[id] then
local cb = rcCbs[id] local cb = rcCbs[id]
rcCbs[id] = nil rcCbs[id] = nil
+3 -6
View File
@@ -50,9 +50,7 @@ local function handleRunCode(data, res)
end end
end end
RegisterNetEvent('runcode:runInBand') RegisterNetEvent('runcode:runInBand', function(id, data)
AddEventHandler('runcode:runInBand', function(id, data)
local s = source local s = source
local privs = GetPrivs(s) local privs = GetPrivs(s)
@@ -146,7 +144,7 @@ CreateThread(function()
while true do while true do
Wait(100) Wait(100)
for k, v in ipairs(codes) do for k, v in pairs(codes) do
if GetGameTimer() > v.timeout then if GetGameTimer() > v.timeout then
source = nil source = nil
returnCode(k, '', 'Timed out waiting on the target client.') returnCode(k, '', 'Timed out waiting on the target client.')
@@ -155,8 +153,7 @@ CreateThread(function()
end end
end) end)
RegisterNetEvent('runcode:gotResult') RegisterNetEvent('runcode:gotResult', returnCode)
AddEventHandler('runcode:gotResult', returnCode)
SetHttpHandler(function(req, res) SetHttpHandler(function(req, res)
local path = req.path local path = req.path
@@ -28,6 +28,7 @@ var count = 0;
var thisCount = 0; var thisCount = 0;
const emoji = { const emoji = {
INIT_CORE: [ '🍇' ],
INIT_BEFORE_MAP_LOADED: [ '🍉' ], INIT_BEFORE_MAP_LOADED: [ '🍉' ],
INIT_AFTER_MAP_LOADED: [ '🍋', '🍊' ], INIT_AFTER_MAP_LOADED: [ '🍋', '🍊' ],
INIT_SESSION: [ '🍐', '🍅', '🍆' ], INIT_SESSION: [ '🍐', '🍅', '🍆' ],
@@ -38,7 +39,7 @@ const handlers = {
{ {
count = data.count; count = data.count;
document.querySelector('.letni h3').innerHTML += emoji[data.type][data.order - 1] || ''; document.querySelector('.letni h3').innerHTML += (emoji[data.type] || [])[data.order - 1] || '';
}, },
initFunctionInvoking(data) initFunctionInvoking(data)