Secure Weapon Reloading

One of the things I’m working on right now is a weapon ammo system. Pretty standard stuff – you have a number of shots in your magazine and when that’s empty, you take some time to reload your magazine from your extra ammo supply.

The “problem” I’m running into is programming this in a way that it can’t be easily bypassed by exploiters but without making it too affected by latency. The placeholder system I’ve been using is having the wait being done entirely on the clientside – when the player reloads, the client waits the reloading time then sends a request to the server to instantly actually enact the effects of the reloading. But as the wait is clientside, an exploiter could pretty easily have their weapon instantly reload.

Does anyone have any recommended ways of approaching this? To have the client reload their weapon without completely trusting the client or being too affected by latency. Or should I just accept the consequences of trusting the client here?

1 Like

Why should the effects of the reload take effect on the server? I’ve done reloading client-side.

I’m not sure entirely if this may work or not, but could it be possible to move the wait to the server? The client would fire the request to reload, which is received, waited for the time it takes to do so, then enacting the effects of reloading? I’m not sure if this can fit in, but it is an idea.

Although I’m not making a firearm system right now (and the fact that this post is from 2020), I ran into this question some time ago. My best idea for a solution is:

  • Player fires an event to the server.
  • The server gets the event and runs a timer that can be stopped if the player cancels the reload. (Note: the player cannot shoot while reloading, so if an exploiter fires the shoot event, the server dismisses it)
  • Locally, the player plays the reload animation and everything goes smoothly for them.
  • If the player cancels the reload, fire an event to the server and dont reload the weapon.

I’m not very sure about how to make it work for shotguns and stuff like that, but I think you can make it so every time the player reloads, they put only 1 bullet.