Page MenuHomeFeedback Tracker

Current amount of stamina doesn't get saved on server. Always on full when relogging in.
New, NormalPublic

Description

Player starts its stamina always full. I even increased max stamina from 100 -> 10000 through the cfggameplay.json, consumed it fully, log out and log in back after 1 min and the stamina was full even when it should be impossible.

Other stuff like hunger, thirst, blood, health, etc. are saved and loaded right. If I understand the scripts in PlayerBase.c, the Stamina should be save just like those other things.

Any insight why this happens and how to fix this?

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Stamina
Steps To Reproduce
  • Increase max stamina from cfggameplay.json to 10000 for your server.
  • Get in the server and consume the stamina fully. It should regenerate very slow and shouldn't be possible to get full in couple minutes.
  • Get out of the server and get back in the same server.
  • Notice that your stamina is full but other stats have kept their states.
Additional Information

Here are logs from server and myself:

Event Timeline

StJimmy created this task.Aug 17 2023, 2:46 PM
StJimmy added a comment.EditedSep 3 2023, 4:38 AM

So just this is really needed for the Stamina to get loaded from the PlayerStats since seems like PlayerStats aren't loaded before the Init but they're loaded before the first Update cycle. There's not a single m_Player.GetStatStamina().Get() in the StaminaHandler to actually load the Stamina from save. Why is it even build like this? Also there's basically three times m_Player.GetStatStamina().Set(m_Stamina) calls because SetStamina also calls it though SyncStamina, which there are two in the Update.

protected bool StatsLoaded;// Stats should be already loaded when the first Update cycle starts.

override void Update(float deltaT, int pCurrentCommandID)
{
  if (m_Player)
  {
    // Stats should be already loaded when the first Update cycle starts. Gets the last saved Stamina Stat.
    if (StatsLoaded == false) // This should be false on the first Update.
    {
      m_Stamina = m_Player.GetStatStamina().Get(); // Loading saved Stamina from the Stats/server.
      StatsLoaded = true; // Loaded once and not needed anymore.
    }
  }
  super.Update(deltaT, pCurrentCommandID);
}
StJimmy added a comment.EditedSep 5 2023, 12:30 AM

Actually even better solution:

modded class PlayerBase
{
	override void AfterStoreLoad()
	{
		super.AfterStoreLoad();
		GetStaminaHandler().SetStamina(GetStatStamina().Get());
	}
}