Project Zomboid

Project Zomboid

The Last of Us Infected
DETOX 3 Jul, 2024 @ 11:09pm
Flaw with time based spawning MP
Hello again
there is a flaw in the code with the time system based on os.time, the server after one start and restart return negative values. i suggest you use the World Time age/24.


Fix :
function CalculateEvoDays() -- Check Sandbox option if true. if SandboxVars.YourMOD.DayPerDayCounter == true then -- Check if selected counter is WorldAgeHours. if SandboxVars.YourMOD.DayCounterSelected == 1 then -- You can use math.floor to start from day 0. EvoDays = (math.ceil(getGameTime():getWorldAgeHours() / 24)) print("DAY IS : "..EvoDays) -- Check if selected counter is based on player survived days . -- You could add another else incase the function bugs out. -- Also Another Elseif if you want the os.time as seperte option. elseif SandboxVars.YourMOD.DayCounterSelected == 2 then EvoDays = getGameTime():getDaysSurvived() print("DAY IS : "..EvoDays) end else -- IF Sandbox option is false -- Set the value to x1 EvoDays= 1 end end Events.EveryDays.Add(CalculateEvoDays)