From 2935a6ba1daacaf488044330f1456f455b83deb0 Mon Sep 17 00:00:00 2001 From: Mathu-lmn <80094438+Mathu-lmn@users.noreply.github.com> Date: Wed, 23 Sep 2026 20:59:47 +0200 Subject: [PATCH] Misc fixes (#233) * fix(spawnmanager): correct native arguments and enable ped model check Signed-off-by: Mathu-lmn <80094438+Mathu-lmn@users.noreply.github.com> * fix(mapmanager): restrict the gametype command Signed-off-by: Mathu-lmn <80094438+Mathu-lmn@users.noreply.github.com> * fix(example-loadscreen): handle unknown init types such as INIT_CORE Signed-off-by: Mathu-lmn <80094438+Mathu-lmn@users.noreply.github.com> --------- Signed-off-by: Mathu-lmn <80094438+Mathu-lmn@users.noreply.github.com> --- .../mapmanager/mapmanager_server.lua | 2 +- .../[managers]/spawnmanager/spawnmanager.lua | 28 ++++++++----------- .../[test]/example-loadscreen/index.html | 3 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/resources/[managers]/mapmanager/mapmanager_server.lua b/resources/[managers]/mapmanager/mapmanager_server.lua index 70f9c7f..545206f 100644 --- a/resources/[managers]/mapmanager/mapmanager_server.lua +++ b/resources/[managers]/mapmanager/mapmanager_server.lua @@ -264,7 +264,7 @@ RegisterCommand("gametype", function(source, args) end changeGameType(args[1]) print('gametype ' .. args[1] .. "\n") -end) +end, true) function getCurrentGameType() return currentGameType diff --git a/resources/[managers]/spawnmanager/spawnmanager.lua b/resources/[managers]/spawnmanager/spawnmanager.lua index 9e940d8..5f3eded 100644 --- a/resources/[managers]/spawnmanager/spawnmanager.lua +++ b/resources/[managers]/spawnmanager/spawnmanager.lua @@ -41,7 +41,7 @@ AddEventHandler('getMapDirectives', function(add) -- recalculate the model for storage if not tonumber(model) then - model = GetHashKey(model, _r) + model = GetHashKey(model) end -- 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") end - -- is is even a ped? - -- not in V? - --[[if not IsThisModelAPed(model) then + -- is the model a ped? + if not IsModelAPed(model) then error("this model ain't a ped!") - end]] + end -- overwrite the model in case we hashed it spawn.model = model @@ -153,17 +152,17 @@ end -- function as existing in original R* scripts local function freezePlayer(id, freeze) local player = id - SetPlayerControl(player, not freeze, false) + SetPlayerControl(player, not freeze, 0) local ped = GetPlayerPed(player) if not freeze then if not IsEntityVisible(ped) then - SetEntityVisible(ped, true) + SetEntityVisible(ped, true, false) end - if not IsPedInAnyVehicle(ped) then - SetEntityCollision(ped, true) + if not IsPedInAnyVehicle(ped, false) then + SetEntityCollision(ped, true, true) end FreezeEntityPosition(ped, false) @@ -171,14 +170,13 @@ local function freezePlayer(id, freeze) SetPlayerInvincible(player, false) else if IsEntityVisible(ped) then - SetEntityVisible(ped, false) + SetEntityVisible(ped, false, false) end - SetEntityCollision(ped, false) + SetEntityCollision(ped, false, false) FreezeEntityPosition(ped, true) --SetCharNeverTargetted(ped, true) SetPlayerInvincible(player, true) - --RemovePtfxFromPed(ped) if not IsPedFatallyInjured(ped) then ClearPedTasksImmediately(ped) @@ -193,11 +191,7 @@ function loadScene(x, y, z) NewLoadSceneStart(x, y, z, 0.0, 0.0, 0.0, 20.0, 0) - while IsNewLoadSceneActive() do - networkTimer = GetNetworkTimer() - - NetworkUpdateLoadScene() - end + while IsNewLoadSceneActive() do NetworkUpdateLoadScene() end end -- to prevent trying to spawn multiple times diff --git a/resources/[test]/example-loadscreen/index.html b/resources/[test]/example-loadscreen/index.html index c3f8446..d2e522b 100644 --- a/resources/[test]/example-loadscreen/index.html +++ b/resources/[test]/example-loadscreen/index.html @@ -28,6 +28,7 @@ var count = 0; var thisCount = 0; const emoji = { + INIT_CORE: [ '🍇' ], INIT_BEFORE_MAP_LOADED: [ '🍉' ], INIT_AFTER_MAP_LOADED: [ '🍋', '🍊' ], INIT_SESSION: [ '🍐', '🍅', '🍆' ], @@ -38,7 +39,7 @@ const handlers = { { 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)