Stamina System (client + server)

I’m making a stamina system and I have it client-sided for smooth gameplay and pretty much gets rid of lag UI&UX-wise, however, I’m also thinking of having a service-side stamina system that keeps track of all the player’s actions and then does its own thing, after that, it then tries to assume the amount of stamina a player has, if they have exceeded the threshold, they get punished.

This way: they cannot sprint/run forever; they can’t jump more than X amount of times; any other actions that require stamina can’t be done infinitely.

I’m also planning on implementing this on the server because I already have anti-cheat on the server that watches player character movements.

I know this won’t be perfect, so to compensate for lag, the client will have 100 stamina and the server will have 120?

Do you guys have better suggestions?

My advice:

Having both client and server track stamina separately adds complexity and still isn’t secure. Exploiters can easily bypass the client and fake actions to fool the server. The server can’t truly know what the player is doing without real-time syncing, and assumptions based on timing can lead to false positives (especially with lag). You’re adding overhead for a system that can still be tricked. Might be better to just design stamina as a soft mechanic that doesn’t need strict enforcement, or fully move it to the client so that movement is nice and smooth.

1 Like

As I mentioned: the stamina system is client-sided, the server will have its own copy of all the player’s stats with a few buffers to reduce false-positives, so if for some reason the player exceeds the normal amount of stamina plus some buffer then decrease their health, kill their character, and so on.

The client has full control of the stamina system, it doesn’t need to communicate with the server, but the server will keep track of the player’s stats and act accordingly.

I use attributes a lot and it’s my preferred way of storing data so it should be easy to keep track of it on the server without having to communicate with the clients and avoid unnecessary use of Remotes.

I partially understand where you are coming from and that’s totally fine. However, there are some issues that I feel like can be avoided if you prevent yourself relying on the server to estimate the stamina based on observed actions. Since you are guessing with the server, it can be prone to some inaccuracies especially with lag and desync, and exploiters are able to bypass client sided controls by faking actions and movements. This leaves a blind spot for the server which is unable to track stamina and could create a vunerability to cheats. You’re use of buffers to avoid these circumstances can work but can still lead to inconsistencies, players can abuse this and get an extra advantage, but also players who are innocent get punished for no reason if the server has had an desync or lag issue. It also adds a layer of complexity as it doesn’t really add a real security benefit, it just provides a tame attempt at stopping this. I would say that if you are in the for the security, use chickynoid’s server authoritative movement system or switch over to using client architecture for your stamina system. Apologies for not providing a better suggestion but I feel like providing a different perspective on this.

So you’re saying to just keep everything related to stamina strictly client-sided?

Preferably yes, as exploiters have full control over the character, unless you use a server authoritative movement system like Chickynoid.

I was hoping to make my game exploiter-free as much as possible but I guess not. :face_with_spiral_eyes:
Stamina is the easiest to exploit too, so basically all exploiters including the most basic ones can do everything that requires a stamina infinitely.

It is quite unfortunate, however I would recommend you should focus on your game design instead of worrying about exploits. Happy developing! :wink:

Thanks. I hope this is not game-breaking xD