#Anti-Cheat for Stamina & Run Speed

1 messages · Page 1 of 1 (latest)

white crypt
#

i'm curious as to how i could approach anti-cheat for stamina, as of right now the client handles everything, which isn't ideal due to it being able to be manipulated easily by exploiters

one of my thoughts was to have the server handle all the stamina related calculations and repeatedly ping it back to client for ui, but that would cause a potential huge amount of delay

does anyone have any ideas that could lead me into the correct path?

somber sable
late coralBOT
#

studio** You are now Level 20! **studio

somber sable
#

Then you only have to let the server know when the stamina is being drained (the player is running) and when the stamina stops being drained

white crypt
# somber sable Calculate the stamina on both server and client. And only use the calculated sta...

so should it be like:

  • both server and client do the calculations, client for ui, server for actual stamina
  • when you start sprinting or stop sprinting, the server gets pinged and starts depleting stamina on the server

would it then be ideal to make it so the player's speed is set on the server, then have some sort of check every time the player starts running to see what their speed is?

im basically interpreting this as the client is fake stamina that just displays as in sync to the server as possible while the server is the real one

#

im not sure how bad this would be but would it also be ideal to have the server ping the client with the correct stamina every 10 seconds or so? just in case it gets out of sync

somber sable
somber sable
white crypt
#

i was more or less thinking in case a player gets ping then the ping goes down, allowing it to properly catch up

somber sable
white crypt
#

well my thought is like, if a player starts lagging and the client and server go out of sync with the stamina, if the ping goes back down to something stable, the server/client could still be out of sync

#

i mean i guess it wouldnt be after the stamina is fully regained?

somber sable
#

Just give it a try if there is the need for re syncing then you could maybe fire the client after the server stopped the stamina draining to re sync

white crypt
#

alright ill give it a go, thank you very much for the insight

white crypt
#

ive went about this the wrong way probably i should ideally be only depleting/giving whenever its used instead of every frame, only issue is client uses deltatime so the fps doesnt change the speed of the ui on diff fps and otherwise i cant get deltatime so itll be out of sync regardless

white crypt
#

this approach def doesnt work anyway, i really only just need to figure out how to make the client depletion work on any framerate and i should be able to make it work properly without runservice on server

late coralBOT
#

studio** You are now Level 2! **studio

white crypt
#

i think i could do a tween for the client bar instead? might be easier to combine together + no risk of fps issues

burnt marlin
#

im going to be honest there is no point in making an anticheat for such stuff, as its heavily reliant on client side

#

but whatever u create, give me the game link and il get around it unless its something stupid like net owner

white crypt
burnt marlin
#

do simple constraints and logic checks server side

#

but if it requires goofy stuff from both sides, ur likely playing with fire

white crypt
#

what should i be checking on the server? i was thinking of somehow checking the player's walk speed every few seconds just to make sure it isnt too high but im not sure if thats needed really

burnt marlin
#

keep stamina in a server table per player, drain/regen on sprint remotes only not every frame. dont check walkspeed just set it server side and theres nothing to spoof. resync client on sprint/stop and tween the bar to make it smoother, then u can just do a simple max velocity check with pos

white crypt
#

oh i think i see what you mean, so the bar tweens based on if youre sprinting or not, and when you start sprinting/stop sprinting it pings to the server to let it know, start depleting or recovery, then fire back to the client what the count was before the depletion/recovery to start tweening?

my only concern really is getting the tweening speed to match the depletion/recovery speed on the server, what would you recommend i do for it to roughly be the same?

burnt marlin
#

yeah exactly, just use the same drain rate as your tween time so if stamina takes 3s to empty the tween duration is 3s. on resync just cancel the current tween and start a new one from the synced value, itll correct itself

white crypt
#

would i send the tweening info back to the client each time? just so it can do the tweens with correct timing and all

burnt marlin
#

just fire the current stamina value + draining or regen state, client already knows the rates so it can work out the tween duration itself.

late coralBOT
#

studio** You are now Level 6! **studio