Multiple Heartbeats

I’m trying to solve an exploiting issue in my game by keeping track of something on the server, as well as on clients. In my game, money is awarded based on your rocket’s altitude at the end of a flight.

Since clients have network ownership of their rockets, I willingly trust whatever they say was their altitude at the end of a flight, knowing that exploiters would come but I didn’t care because they aren’t affecting other players. But now I want to patch it, so I’m keeping track of the altitudes on the server to verify that what the client says is correct.

Right now, whenever the player spawns a rocket, I add a heartbeat connection to a table. The heartbeat connection is what actually keeps track of the rocket’s altitude.

TLDR

My question is, is is better to just have one heartbeat connection and loop through every spawned rocket, or better to have a heartbeat connection for each individual rocket? Does the difference make any significant performance difference or is it negligible?

Multiple connections means more memory usage, so it’s best to just use one connection for all

2 Likes

It is better to have one heartbeat looking through many rockets, this is purely because it’s a singular function the server has to handle instead of it having to handle singular things connected to the heartbeat multiple times. It’s also a lot more beneficial on the memory and requires less handling on the server.

You would probably notice little difference in either methods, however in regards to efficiency: handling rockets as a collective is more advantageous then handling each rocket as an individual seeming as at the base these rockets are all the same.

Trusting the client is never a good idea, so I’m glad you’ve decided to do checks on the server. You may want to rethink the entire system to be more dependent on the server however, purely because the policy is “never trust the client”.

4 Likes

I’m aware that the general consensus is to never trust the client, but when I was scripting the system is knowingly allowed clients to be trusted in this scenario because exploiters can only give themsevles money. I don’t care if they do that because exploiters aren’t the type of people to spend money on the game or legitimately play it.

I made this decision with client smoothness in mind. Giving clients full control of their rocket makes things like stage separation much smoother, but now that my game has gotten a bit more popular I want to patch these exploits for the sole reason that I don’t like exploiters.

Thanks for your input on the heartbeat, I’ll make one central heartbeat for every rocket.

2 Likes

Same as what @Raretendoblox , it would be better to only use 1 heartbeat, but if you absolutely have to use multiple heartbeats its not the end of the world and the performance drop would be minuscule.

1 Like