That should work...
// Connection file
var mysql = require('mysql');
module.exports = {
Handle: null,
Connect: function(callback) {
this.Handle = mysql.createConnection({
host : 'your_host',
user : 'your_user',
password : 'your_pass',
database : 'your_database'
});
this.Handle.connect(function(e) {
if ( !e ) { callback(); }
else console.log ("Error in Database " + e);
});
}
};
// White list file
var db = require("./database");
mp.events.add("playerJoin", (player) => {
db.Handle.query("SELECT * FROM whitelist WHERE socialID = ?", [player.socialClub], function(e, result) {
if (!result.length){
player.kick("Not in whitelist.");
}else{
// In Whitelist :)
}
});
But instead of using the social club, I recommend creating a login with a unique user ID. Players with pirate gta do not have the socialClub! Sorry for my English, I'm Brazilian.