MOD REQUIRED: Essential-Mode !
Warning: make a backup of your script before running this tutorial
(I would not be responsible for any loss, it is at your own risk)
Please, Before reading this tutorial, excuse me for my bad English, I try to do my best.
Hello everyone.
Today I will explain how to put whitelist to your server.
You have nothing to add in your server folder, only scripts to edit and one table to be added in your database.
- add this to your database:
whitelist.sql (1.1 KB)
-
go in your _/resources/essential-mode/server/ folder and edit main.lua.
-
Add this below the line 12 (line 12 =[‘banReason’]):
[‘listmsg’] = “You are not whitelisted !”,
like this:
- Always in main.lua, add this below the line 43 (below the first AddEventHandler):
AddEventHandler(‘playerConnecting’, function(name, setCallback)
local identifiers = GetPlayerIdentifiers(source)
for i = 1, #identifiers do
local identifier = identifiers[i]
debugMsg('Checking user whitelist: ’ … identifier … " (" … name … “)”)
local listed = isWhiteListed(identifier) if(listed)then if(type(settings.defaultSettings.listmsg) == "string")then setCallback(settings.defaultSettings.listmsg) elseif(type(settings.defaultSettings.listmsg) == "function")then setCallback(settings.defaultSettings.listmsg(identifier, name)) else setCallback("Not whitelisted !") end CancelEvent() end
end
end)
like this:
-
go in your _/resources/essential-mode/server/player/ folder and edit login.lua
-
Add this below the line 54 (below the isIdentifierBanned function):
function isWhiteListed(identifier)
local executed_query = MySQL:executeQuery(“SELECT * FROM whitelist WHERE identifier = ‘@name’”, {[‘@name’] = identifier})
local result = MySQL:getResults(executed_query, {‘listed’}, “identifier”)
if(result)then
for k,v in ipairs(result)do
if v.listed == 1 then
return false
end
end
end
return true
end
like this:
After this, just insert in whitelist table the identifier of your user (like in your users table) and replace the “0” by “1” in listed.
(by default) 0 = Player not whitelisted
and 1 = Player whitelisted
[Whitelist] add user by steamID64:
first, go to this website and take the user ID:
https://steamid.io/ (or other website).
- Go to this website and put the steamid64 of your user to the Decimal Value field and convert it.
Decimal to Hexadecimal Converter
After this, put the Hexadecimal Value to your database.
dont forget to put steam: before the Hexadecimal Value
Exemple: steam:11000010ABCDEF123
[Whitelist] add user by IP adress:
Put The ip adress of your user to the whitelist.
http://whatismyipaddress.com (or other website).
dont forget to put ip: before the ip adress
Exemple: ip:127.0.0.1
And your user will be on white list and will be able to join you !
Enjoy !