Move players record to lua
Pull Request Prelude
- [x] I have followed proper The Forgotten Server code styling.
- [x] I have read and understood the contribution guidelines before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
- Move players record to lua.
- Saves the record only when the server save.
- Remove globalevent onRecord.
Test required
- I added a
ScriptInterfacetoGame, but I am unsure of its limitations. It’s necessary to check whether what I’ve implemented is correct, includingGame::getPlayersRecord()
@MillhioreBT I agree—if only we had a status server in Lua or something like an Http Client, we wouldn’t need to call Lua in Game.cpp.
-
However, I disagree regarding performance. Unlike before, where an UPDATE was performed every time a player joined, now it only occurs when save the game.
-
I didn’t recall
Game.getPlayerCount(). I'll make the adjustment! -
If I’m not mistaken, it’s no longer necessary to call
result.free. This is because of the automatic cleanup we perform after every Lua call, usingtfs::lua::resetScriptEnv(). However, I can add it explicitly if needed.
I’m not a fan of Game::Game() : scriptInterface("Game Interface"). If anyone has a better idea, im open to suggestions 🫤
Just keep a running counter of players online that increases with a creaturescript of type login and decreases with a logout
Wasn't this already a thing back in like 1.2 1.0 and it got removed?