server anti-cheat
This commit is contained in:
parent
448858e594
commit
a9a1a965f4
1 changed files with 20 additions and 3 deletions
|
@ -5,7 +5,6 @@ const fs = require('fs');
|
|||
const objectsModule = require('./objects');
|
||||
|
||||
|
||||
|
||||
const options = {
|
||||
cert: fs.readFileSync("/home/ubuntu/servers/keys/gta6/cert.pem"),
|
||||
key: fs.readFileSync("/home/ubuntu/servers/keys/gta6/privkey.pem")
|
||||
|
@ -76,10 +75,28 @@ function createNewPlayer(socket, name) {
|
|||
connections.add(socket);
|
||||
}
|
||||
|
||||
function kick_player(player_id, socket, reason){
|
||||
//send cheating info to all players
|
||||
broadcast(JSON.stringify({
|
||||
type: "kick",
|
||||
data: {
|
||||
player_id: player_id,
|
||||
reason: reason
|
||||
}
|
||||
}));
|
||||
deletePlayer(socket); //delete player of players list
|
||||
socket.terminate(); //disconnect cheating player
|
||||
}
|
||||
|
||||
function update(message, socket){
|
||||
for (var i = players.length - 1; i >= 0; i--) {
|
||||
if (players[i].id == message.data.id) {
|
||||
players[i] = message.data;
|
||||
if(message.data.health <= MAX_HEALTH) {
|
||||
if (players[i].id == message.data.id) {
|
||||
players[i] = message.data;
|
||||
}
|
||||
}else{
|
||||
//cheat detected
|
||||
kick_player(message.data.id, socket, "health cheat");
|
||||
}
|
||||
}
|
||||
broadcast(JSON.stringify(message), socket.id);
|
||||
|
|
Loading…
Reference in a new issue