duankeng1911 2011-11-26 13:55
浏览 42
已采纳

防止网络游戏上的AJAX作弊[重复]

This question already has an answer here:

Context

I have a web game in JavaScript.

I send scores and achievements with AJAX during the game.

So anyone can view the source code, copy this request and cheat on my game.

Questions

  • Any idea of how prevent this?
  • With a token from server (I never used this system)?

Code

jquery:

$.post('ajax/score.php', {pseudo: $pseudo, score: $score, achiev: $achiev},
    function(data) {
        $('#loader').show().delay(3000).fadeOut(1000);
    }
);

php:

if (isset($_POST['pseudo']) &&
    isset($_POST['score']) && 
    isset($_POST['achiev'])) {
    ...
}
</div>
  • 写回答

1条回答 默认 最新

  • doushang3352 2011-11-26 14:10
    关注

    As the game is client side, there is no way to ensure that they do not "cheat". There are ways to make it more difficult.

    • Have all calculations performed serverside, and send back tokens...this may not be possible/feasible for your game.
    • Change the code served each time so that it will require more time to "decipher" all the requests.
    • Obfuscate the code...this is only a deterrent.
    • Have "tokens" sent during the game to see if the data matches (for example you can't win the racing game in 5 sec)...this too can be spoofed.

    As long as the game is client side, it cannot be "secured".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器