Merge branch 'master' into master

This commit is contained in:
ArkSeyonet
2021-02-01 13:58:36 -06:00
committed by GitHub
10 changed files with 61 additions and 66 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ start esx_whitelist
### License
esx_whitelist - Whitelist script
Copyright (C) 2015-2018 Jérémie N'gadi
Copyright (C) 2015-2020 Jérémie N'gadi
This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.
+2 -1
View File
@@ -1,3 +1,4 @@
Config = {}
Config.Locale = 'fr'
Config.MinPlayer = 0 --Set how many players need to be connect before whitelist start, 0-32
Config.MinPlayer = 0 --Set how many players need to be connect before whitelist start, 0-32
+2 -2
View File
@@ -1,7 +1,7 @@
USE `essentialmode`;
USE `es_extended`;
CREATE TABLE `whitelist` (
`identifier` varchar(60) NOT NULL,
`identifier` varchar(40) NOT NULL,
PRIMARY KEY (`identifier`)
);
+4 -1
View File
@@ -1,4 +1,6 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
fx_version 'adamant'
game 'gta5'
description 'ESX Whitelist'
@@ -8,6 +10,7 @@ server_scripts {
'@mysql-async/lib/MySQL.lua',
'@es_extended/locale.lua',
'config.lua',
'locales/br.lua',
'locales/en.lua',
'locales/fr.lua',
'locales/sv.lua',
+9
View File
@@ -0,0 +1,9 @@
Locales['br'] = {
['whitelist_check'] = 'certificando-se de que você está na lista de permitidos(whitelist) neste servidor. . .',
['not_whitelisted'] = 'você não está na lista de permitidos(whitelist) neste servidor',
['steamid_error'] = 'seu ID do Steam não foi encontrado, o Steam está aberto?',
['whitelist_empty'] = 'a lista de permitidos(whitelist) ainda não foi carregada ou ninguém foi incluído!',
['help_whitelist_add'] = 'adicionar alguém à lista de permitidos(whitelist) no servidor',
['help_whitelist_load'] = 'recarregar a lista de permitidos(whitelist)',
}
+1 -1
View File
@@ -1,8 +1,8 @@
Locales['en'] = {
['whitelist_check'] = 'making sure you\'re whitelisted on this server . . .',
['not_whitelisted'] = 'you are not whitelisted on this server',
['steamid_error'] = 'your Steam ID was not found, is Steam running?',
['whitelist_empty'] = 'the whitelist hasn\'t been loaded yet, or alternatively no one has been whitelisted!',
['license_missing'] = 'your license could not be found',
['help_whitelist_add'] = 'add someone to the whitelist',
['help_whitelist_load'] = 'reload the whitelist',
}
+1 -1
View File
@@ -1,8 +1,8 @@
Locales['fr'] = {
['whitelist_check'] = 'making sure you\'re whitelisted on this server . . .',
['not_whitelisted'] = 'ceci est un serveur avec whitelist',
['steamid_error'] = 'nous n\'arrivons pas à lire votre SteamID',
['whitelist_empty'] = 'the whitelist hasn\'t been loaded yet, or alternatively no one has been whitelisted!',
['license_missing'] = 'your license could not be found',
['help_whitelist_add'] = 'ajouter quelqu\'un dans la Whitelist',
['help_whitelist_load'] = 'recharger la Whitelist',
}
+1 -1
View File
@@ -1,8 +1,8 @@
Locales['sv'] = {
['whitelist_check'] = 'making sure you\'re whitelisted on this server . . .',
['not_whitelisted'] = 'du är inte whitelistad på denna server!',
['steamid_error'] = 'ditt Steam ID kunde ej hittas, är Steam påslaget?',
['whitelist_empty'] = 'whitelisten har ännu inte laddats in, eller så är ingen whitelitad!',
['license_missing'] = 'din licens kunde ej hittas',
['help_whitelist_add'] = 'lägg till någon till whitelisten',
['help_whitelist_load'] = 'ladda om whitelist',
}
+16 -32
View File
@@ -1,42 +1,26 @@
TriggerEvent('es:addGroupCommand', 'wlrefresh', 'admin', function (source, args, user)
ESX.RegisterCommand('wlrefresh', 'admin', function(xPlayer, args, showError)
loadWhiteList(function()
TriggerEvent('esx_whitelist:sendMessage', source, 'Whitelist', 'Whitelist reloaded')
showError('Whitelist reloaded')
end)
end, function (source, args, user)
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficienct permissions!' } })
end, { help = _U('help_whitelist_load') })
end, true, {help = _U('help_whitelist_load')})
TriggerEvent('es:addGroupCommand', 'wladd', 'admin', function (source, args, user)
local steamID = 'steam:' .. args[1]:lower()
ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError)
args.license = args.license:lower()
if string.len(steamID) ~= 21 then
TriggerEvent('esx_whitelist:sendMessage', source, '^1SYSTEM', 'Invalid steam ID length!')
return
end
MySQL.Async.fetchAll('SELECT * FROM whitelist WHERE identifier = @identifier', {
['@identifier'] = steamID
}, function(result)
if result[1] ~= nil then
TriggerEvent('esx_whitelist:sendMessage', source, '^1SYSTEM', 'The player is already whitelisted on this server!')
if string.len(args.license) == 40 then
if WhiteList[args.license] then
showError('The player is already whitelisted on this server!')
else
MySQL.Async.execute('INSERT INTO whitelist (identifier) VALUES (@identifier)', {
['@identifier'] = steamID
}, function (rowsChanged)
table.insert(WhiteList, steamID)
TriggerEvent('esx_whitelist:sendMessage', source, 'Whitelist', 'The player has been whitelisted!')
['@identifier'] = args.license
}, function(rowsChanged)
WhiteList[args.license] = true
showError('The player has been whitelisted!')
end)
end
end)
end, function (source, args, user)
TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficienct permissions!' } })
end, { help = _U('help_whitelist_add'), params = { steam = 'SteamID', help = 'SteamID formated to hex, begins with 11' }})
-- console / rcon can also utilize es:command events, but breaks since the source isn't a connected player, ending up in error messages
AddEventHandler('esx_whitelist:sendMessage', function(source, title, message)
if source ~= 0 then
TriggerClientEvent('chat:addMessage', source, { args = { title, message } })
else
print('esx_whitelist: ' .. message)
showError('Invalid license ID length!')
end
end)
end, true, {help = _U('help_whitelist_add'), validate = true, arguments = {
{name = 'license', help = 'the player license', type = 'string'}
}})
+24 -26
View File
@@ -1,17 +1,17 @@
ESX = nil
WhiteList = {}
ESX, WhiteList = nil, {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
function loadWhiteList(cb)
Whitelist = {}
MySQL.Async.fetchAll('SELECT * FROM whitelist', {}, function (identifiers)
for i=1, #identifiers, 1 do
table.insert(WhiteList, tostring(identifiers[i].identifier):lower())
MySQL.Async.fetchAll('SELECT identifier FROM whitelist', {}, function(result)
for k,v in ipairs(result) do
WhiteList[v.identifier] = true
end
if cb ~= nil then
if cb then
cb()
end
end)
@@ -27,7 +27,7 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
-- Mark this connection as deferred, this is to prevent problems while checking player identifiers.
deferrals.defer()
local _source = source
local playerId, kickReason, identifier = source
-- Letting the user know what's going on.
deferrals.update(_U('whitelist_check'))
@@ -35,30 +35,28 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
-- Needed, not sure why.
Citizen.Wait(100)
local whitelisted, kickReason, steamID = false, nil, GetPlayerIdentifiers(_source)[1]
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
identifier = string.sub(v, 9)
break
end
end
if #WhiteList == 0 then
if ESX.Table.SizeOf(WhiteList) == 0 then
kickReason = _U('whitelist_empty')
elseif not string.match(steamID, 'steam:1') then
kickReason = _U('steamid_error')
else
for i = 1, #WhiteList, 1 do
if tostring(WhiteList[i]) == tostring(steamID) then
whitelisted = true
break
end
end
if not whitelisted then
kickReason = _U('not_whitelisted')
end
elseif not identifier then
kickReason = _U('license_missing')
elseif not WhiteList[identifier] then
kickReason = _U('not_whitelisted')
end
if whitelisted or #xPlayers < Config.MinPlayer then
deferrals.done()
else
deferrals.done(kickReason)
end
if kickReason then
deferrals.done(kickReason)
else
deferrals.done()
end
end
end)