Skip to content

Commit

Permalink
fix issue where defaultstats did not set player stats correctly
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
MittellBuurman committed Feb 21, 2024
1 parent 53050dd commit ce65a54
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions [gameplay]/defaultstats/defaultstats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ce65a54

Please sign in to comment.