So, I have a project, its a "cookie clicker" by definition, and I wish to work out how I can protect the game from users being able to edit <button id="cooker" onclick="cookieClick(1)"></button> and setting (1) to like (123129).

I tried a few things first: JQuery: I tried using an old on() function with a dom searching function, and then to run an alert saying "Dumb Hacker! Im corrupting your save data" and then of course it would run Function clearDat() then function corrupt() which clears the localstorage data and sets it to an invalid value (usually wounds up as NaN) which prevents them from Playing.

Unfortunately the cookieclicker was editing the program so hastily, that it was "changing" the button above, and I wound up getting a million alerts (And because I was using a windows based HTML editor, I was getting WINDOW alerts, which i had to spam esc and try to delete the alert function and rerun the whole game, it was a pain)

I also tried a similar method using an old JS function, but it wound up not working.

I think you may see where im getting at, I'm really stuck in a pickle.

Heres the current code: https://hatebin.com/tgsdqzhzlc

  • \$\begingroup\$ No client-side anticheat will defeat a determined hacker. Your time and energy is likely better-spent validating game logic on your server, where you know users can't modify your code. \$\endgroup\$ – DMGregory Jun 22 '19 at 14:34
  • \$\begingroup\$ In a cookie clicker, why do you care about cheating? It's a single player game; a change one player makes won't affect anyone else. \$\endgroup\$ – Alex F Jun 22 '19 at 17:44
  • \$\begingroup\$ hacker doesn't need to modify your button he can just go to console and run cookieClick(1500100900) it would be a little bit more interesting if you would hide your game under private scoped variables but with your current code there is no need for such solution as you try to do there \$\endgroup\$ – Xesenix Jun 24 '19 at 9:27
  • \$\begingroup\$ you need to learn a lot more to even start trying to make hackers life misserable \$\endgroup\$ – Xesenix Jun 24 '19 at 9:31
  • \$\begingroup\$ Dude.... I dont care anymore, its just a dumb fricking cookie clicker LOL... get over it. \$\endgroup\$ – Mister SirCode Jun 24 '19 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.