Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
creating an anti cheat in an online web game

I have a simple website with a little game in it. It has a basic scoreboard using express - every time you die the website send a post request to the server with your score and the server adds it to the leaderboard. My problem is that its very simple for the leaderboard to be exploited. through devtools people can easily just:

  • disable the colliders so they cant die and then turning it back on when they are happy with the score
  • straight up just set the score to what ever value they want
  • use the console to send a post request of their own with a score of their choice

I thought about creating a server side score counter and collision checker but my game is fast paced so I think this would be problematic, not talking about the computing power that it would put on the server if multiple people play at the same time.

Is this really the only solution or are there simpler solutions I'm not thinking of?

server code:

const express = require('express');
const app = express();
const fs = require('fs');

const { json } = require('express');

app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(express.static('Build'))

app.get('/leaderBoard', (req,res)=>{
    var rawData = fs.readFileSync('./database.json');
    var data = JSON.parse(rawData);
    res.json(data);
})

app.post('/leaderBoard', (req, res)=>{
    var rawData = fs.readFileSync('./database.json');
    var leaderBoard = JSON.parse(rawData).leaderBoard;

    for(var i = 0; i < leaderBoard.length; i++){
        if(req.body.score > leaderBoard[i].score){
            for(let i2 = leaderBoard.length -1; i2 > i; i2--)
                leaderBoard[i2] = leaderBoard[i2-1];
            
            leaderBoard[i] = req.body;
            break;
        }
    }

    fs.writeFileSync("./database.json",JSON.stringify({leaderBoard},null,2));
})

app.listen(process.env.PORT || 3000);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

A server side check would be imperative if you want to truly avoid any cheating... BUT, you could always make it harder to cheat on the client side with simple checks, like defining a maximum score change (for example if someone gains more than 100 points in 1 second, then he's cheating).

Using a minified code can't hurt, and you could also replace your variables name by abstract ones (a, b, c, instead of "score"). For that same reason, a collision check shouldn't just be defined by a true/false flag.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda