1

im searching for an idea to fix my problem. First of all, there is a server.exe software, that can load some stuff. But if i change something, it needs a restart, but not, if i use a json file to store account names. Look:

    const allowedPlayers = 

    [

    "Socialclubuser1", 
    "Socialclubuser2", 
    "Socialclubuser3"

    ]

mp.events.add("playerJoin", (player) => {

if (!allowedPlayers.includes(player.socialClub)) {
    player.notify('Youre not whitelisted!');
}

});

mp.events.add("playerJoin", (player) => {

if (!allowedPlayers.includes(player.socialClub)) {

    player.kick('Youre not whitelisted!');    
}

});

i would use account.json, and insert there the stuff but how?

greetings

MrMexico
  • 21
  • 1
  • Does this answer your question? [Using Node.JS, how do I read a JSON file into (server) memory?](https://stackoverflow.com/questions/10011011/using-node-js-how-do-i-read-a-json-file-into-server-memory) – nicholaswmin Dec 03 '19 at 16:36

1 Answers1

1

Create an account.json file and require it using require on start.

// account.json
// ["Socialclubuser1", "Socialclubuser2", "Socialclubuser3"]

const allowedPlayers = require("./account.json");

// rest of the code
mp.events.add("playerJoin", player => {
  if (allowedPlayers.indexOf(player.socialClub) === -1) {
    player.notify("Youre not whitelisted!");
    player.kick("Youre not whitelisted!");
  }
});
xdeepakv
  • 7,835
  • 2
  • 22
  • 32