From ce65a54e0801a096a6ee174eeac12fa531c25579 Mon Sep 17 00:00:00 2001 From: mittellbuurman Date: Wed, 21 Feb 2024 02:27:03 +0100 Subject: [PATCH] fix issue where defaultstats did not set player stats correctly - changed resourceRoot to root in defaultstats.lua - added conditions in applyStatsForEveryone to only apply stats when resource `type` is `gamemode` or `map`; or the resource itself. --- [gameplay]/defaultstats/defaultstats.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/[gameplay]/defaultstats/defaultstats.lua b/[gameplay]/defaultstats/defaultstats.lua index dcfa665a0..2fc5770b5 100644 --- a/[gameplay]/defaultstats/defaultstats.lua +++ b/[gameplay]/defaultstats/defaultstats.lua @@ -26,12 +26,18 @@ local function applyStatsForSource() end addEventHandler("onPlayerJoin", root, applyStatsForSource) -local function applyStatsForEveryone() +local function applyStatsForEveryone(loadedResource) + local resourceType = getResourceInfo(loadedResource, "type") + local isGamemodeResource = resourceType == "gamemode" + local isMapResource = resourceType == "map" + + if not (loadedResource == resource or isGamemodeResource or isMapResource) then return end + local playersTable = getElementsByType("player") for playerID = 1, #playersTable do applyStatsForPlayer(playersTable[playerID]) end end -addEventHandler("onResourceStart", resourceRoot, applyStatsForEveryone) +addEventHandler("onResourceStart", root, applyStatsForEveryone) addEventHandler("onGamemodeMapStart", root, applyStatsForEveryone)