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

1

1 Answer 1

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!");
  }
});
Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for your help but i got this: TypeError: allowedPlayers.includes is not a function if (!allowedPlayers.includes(player.socialClub)) {
hahha it was ur code. includes is es6+ feature try with .indexOf i have updated solution
if i use my old code it works :D im completly confused
index.js:5: TypeError: allowedPlayers.indexOf is not a function if (allowedPlayers.indexOf(player.socialClub) === -1) {
//accounts.json ["Socialclubuser1", "Socialclubuser2", "Socialclubuser3"]
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.