From d76f9352816546cc7557b1925bfc7e552f0151e8 Mon Sep 17 00:00:00 2001 From: maiconkkl Date: Wed, 15 Jan 2020 16:45:50 -0300 Subject: [PATCH 1/6] Added Portuguese translation (#13) * Correcting and improving translation * Correcting and improving translation * Update br.lua --- __resource.lua | 1 + locales/br.lua | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 locales/br.lua diff --git a/__resource.lua b/__resource.lua index 35ea7766..75959689 100644 --- a/__resource.lua +++ b/__resource.lua @@ -8,6 +8,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', diff --git a/locales/br.lua b/locales/br.lua new file mode 100644 index 00000000..0f442a3c --- /dev/null +++ b/locales/br.lua @@ -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)', +} + From 39e31b40b0a285e662369d5978b0874b14376952 Mon Sep 17 00:00:00 2001 From: rex2630 Date: Sun, 19 Jan 2020 17:04:54 +0100 Subject: [PATCH 2/6] Replace __resource.lua with fxmanifest.lua --- __resource.lua => fxmanifest.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename __resource.lua => fxmanifest.lua (80%) diff --git a/__resource.lua b/fxmanifest.lua similarity index 80% rename from __resource.lua rename to fxmanifest.lua index 75959689..f3754627 100644 --- a/__resource.lua +++ b/fxmanifest.lua @@ -1,4 +1,6 @@ -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' +fx_version 'adamant' + +game 'gta5' description 'ESX Whitelist' From c73b222a1e3d04f8f1b87a79e7a6e006190d601c Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 17 Feb 2020 22:12:33 +0100 Subject: [PATCH 3/6] Code cleanup --- README.md | 2 +- esx_whitelist.sql | 2 +- locales/en.lua | 2 +- locales/fr.lua | 2 +- locales/sv.lua | 2 +- server/commands.lua | 48 +++++++++++++++------------------------------ server/main.lua | 48 ++++++++++++++++++++------------------------- 7 files changed, 42 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index a1c2d105..c4acb4fb 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/esx_whitelist.sql b/esx_whitelist.sql index 2798b56a..bcdddb77 100644 --- a/esx_whitelist.sql +++ b/esx_whitelist.sql @@ -1,7 +1,7 @@ USE `essentialmode`; CREATE TABLE `whitelist` ( - `identifier` varchar(60) NOT NULL, + `identifier` varchar(40) NOT NULL, PRIMARY KEY (`identifier`) ); diff --git a/locales/en.lua b/locales/en.lua index ad20b913..8b7443c6 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -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', } diff --git a/locales/fr.lua b/locales/fr.lua index 59a3f71e..028ba663 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -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', } diff --git a/locales/sv.lua b/locales/sv.lua index 918f1461..6270ffb0 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -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', } diff --git a/server/commands.lua b/server/commands.lua index c05873bb..ef87f319 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -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 steam ID length!') end -end) \ No newline at end of file +end, true, {help = _U('help_whitelist_add'), validate = true, arguments = { + {name = 'license', help = 'the player license', type = 'string'} +}}) diff --git a/server/main.lua b/server/main.lua index 33a6c76c..d239c7c6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,14 +1,14 @@ -WhiteList = {} +WhiteList = {} 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) @@ -22,7 +22,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')) @@ -30,30 +30,24 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) -- Needed, not sure why. Citizen.Wait(100) - local whitelisted, kickReason, steamID = false, nil, GetPlayerIdentifiers(_source)[1] - - if #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 + for k,v in ipairs(GetPlayerIdentifiers(playerId)) do + if string.match(v, 'license:') then + identifier = string.sub(v, 9) + break end - - if not whitelisted then - kickReason = _U('not_whitelisted') - end - end - if whitelisted then - deferrals.done() - else + if ESX.Table.SizeOf(WhiteList) == 0 then + kickReason = _U('whitelist_empty') + elseif not identifier then + kickReason = _U('license_missing') + elseif not WhiteList[identifier] then + kickReason = _U('not_whitelisted') + end + + if kickReason then deferrals.done(kickReason) + else + deferrals.done() end end) From c2e63b08009665f131ffa22dd7b2f5d44a7e7643 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 17 Feb 2020 22:47:25 +0100 Subject: [PATCH 4/6] Fixed commands not registering --- server/commands.lua | 2 +- server/main.lua | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/commands.lua b/server/commands.lua index ef87f319..70bfd3e0 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -19,7 +19,7 @@ ESX.RegisterCommand('wladd', 'admin', function(xPlayer, args, showError) end) end else - showError('Invalid steam ID length!') + showError('Invalid license ID length!') end end, true, {help = _U('help_whitelist_add'), validate = true, arguments = { {name = 'license', help = 'the player license', type = 'string'} diff --git a/server/main.lua b/server/main.lua index d239c7c6..54c693a1 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,4 +1,6 @@ -WhiteList = {} +ESX, WhiteList = nil, {} + +TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) function loadWhiteList(cb) Whitelist = {} From a6bdce89f3430099e8234cf88816f01006df81ff Mon Sep 17 00:00:00 2001 From: userMacieG Date: Sat, 25 Apr 2020 22:16:59 +0200 Subject: [PATCH 5/6] Update database name Update database name from `essentialmode` to `es_extended` --- esx_whitelist.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esx_whitelist.sql b/esx_whitelist.sql index bcdddb77..b1ecd6e5 100644 --- a/esx_whitelist.sql +++ b/esx_whitelist.sql @@ -1,4 +1,4 @@ -USE `essentialmode`; +USE `es_extended`; CREATE TABLE `whitelist` ( `identifier` varchar(40) NOT NULL, From 8e8e189972e91244e9b1e0c1980ce167fc72db80 Mon Sep 17 00:00:00 2001 From: HypeLevels <61633775+HypeLevels@users.noreply.github.com> Date: Tue, 1 Dec 2020 21:44:57 +0000 Subject: [PATCH 6/6] Update config.lua Changed default language to english as its the universal language --- config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.lua b/config.lua index 56a8b5e9..5290495d 100644 --- a/config.lua +++ b/config.lua @@ -1,2 +1,2 @@ Config = {} -Config.Locale = 'fr' +Config.Locale = 'en'