Skip to content

Commit

Permalink
Merge pull request #702 from bitpredator/dev
Browse files Browse the repository at this point in the history
convert esx_allowlist > bpt_allowlist
  • Loading branch information
bitpredator authored May 18, 2024
2 parents 048d6e7 + 261855a commit 027d8bb
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 271 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

esx_whitelist
Copyright (C) 2015-2022 Jérémie N'gadi
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2024 bitpredator

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
Expand All @@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

esx_whitelist Copyright (C) 2015-2022 Jérémie N'gadi
<program> Copyright (C) 2024 bitpredator
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand All @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.
19 changes: 19 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1 align='center'>bpt_allowlist</a></h1>
<p align='center'><a href='https://discord.gg/ksGfNvDEfq'>Discord</a>

Copyright (C) 2024 bitpredator

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.

This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.

ATTENTION:
You are not authorized to change the name of the resource and the resources within it.

If you want to contribute you can open a pull request.

You are not authorized to sell this software (this is free project).

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
4 changes: 4 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Config = {}

Config.Locale = GetConvar('esx:locale', 'en')
Config.MinPlayer = 10 --Set how many players need to be connect before whitelist start, 0-32
19 changes: 19 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
fx_version 'adamant'

game 'gta5'

author 'bitpredator'
description 'Allowlist system that allows you to only allow specific people to access your server'

version '1.0.0'

lua54 'yes'
server_only 'yes'

server_scripts {
'@es_extended/imports.lua',
'@es_extended/locale.lua',
'config.lua',
'locales/*.lua',
'server/main.lua'
}
14 changes: 14 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Locales['en'] = {
['allowlist_check'] = 'Checking if you are Allowlisted.',
['not_allowlisted'] = 'You Must be Allowlisted to join this server!',
['allowlist_empty'] = 'There Are no allowlists saved for this server.',
['license_missing'] = 'Error: Your Identifier is missing!',
['help_allowlist_add'] = 'add someone to the allowlist',
['help_allowlist_load'] = 'reload the allowlist',
['help_allowlist_remove'] = 'remove someone from the allowlist',
['error'] = 'There Was An Error, Please Contact the server owner!',
['already_allowlisted'] = 'The player is already allowlisted on this server!',
['license'] = 'license',
['help_license'] = 'the player license',
['identifier_not_allowlisted'] = 'Identifier is not Allowlisted on this server!',
}
14 changes: 14 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Locales['it'] = {
['allowlist_check'] = 'verifica Allowlist.',
['not_allowlisted'] = 'devi essere nella Allowlist per unirti a questo server!',
['allowlist_empty'] = 'non ci sono allowlist salvate per questo server.',
['license_missing'] = 'Errore: il tuo identificatore è mancante!',
['help_allowlist_add'] = 'aggiungi qualcuno alla allowlist',
['help_allowlist_load'] = 'ricarica la allowlist',
['help_allowlist_remove'] = 'rimuovi un utente dalla allowlist',
['error'] = 'É stato riscontrato un errore, contatta il proprietario del server!',
['already_allowlisted'] = 'Il giocatore è già allowlistato nel server',
['license'] = 'licenza',
['help_license'] = 'la licenza del giocatore',
['identifier_not_allowlisted'] = 'L\' identificativo non è allowlistato nel server',
}
83 changes: 83 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
local allowList = {}

local function loadAllowList()
allowList = {}

local list = LoadResourceFile(GetCurrentResourceName(), 'players.json')
if list then
allowList = json.decode(list)
end
end

CreateThread(loadAllowList)

AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
local players = GetPlayers()
if #players < Config.MinPlayer then return end

deferrals.defer()

local playerId, kickReason = source, TranslateCap('error')

deferrals.update(TranslateCap('allowlist_check'))

--Not for nothing was this 100 but even this is not the best solution.
Wait(100)

local identifier = ESX.GetIdentifier(playerId)

if ESX.Table.SizeOf(allowList) == 0 then
kickReason = "[BPT] " .. TranslateCap('allowlist_empty')
elseif not identifier then
kickReason = "[BPT] " .. TranslateCap('license_missing')
elseif not allowList[identifier] then
kickReason = "[BPT] " .. TranslateCap('not_allowlist')
end

if kickReason then return deferrals.done(kickReason) end

deferrals.done()
end)

ESX.RegisterCommand('alrefresh', 'admin', function(xPlayer, args)
loadAllowList()
print('[^2INFO^7] Allowlist ^5Refreshed^7!')
end, true, { help = TranslateCap('help_allowlist_load') })

ESX.RegisterCommand('aladd', 'admin', function(xPlayer, args, showError)
local playerLicense = args.license:lower()

if allowList[playerLicense] then
showError('The player is already allowlisted on this server!')
else
allowList[playerLicense] = true
SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(allowList))
loadAllowList()
return
end
end, true, {
help = TranslateCap('help_allowlist_add'),
validate = true,
arguments = {
{ name = TranslateCap('license'), help = TranslateCap('help_license'), type = 'string' }
}
})

ESX.RegisterCommand('alremove', 'admin', function(xPlayer, args, showError)
local playerLicense = args.license:lower()

if allowList[playerLicense] then
allowList[playerLicense] = nil
SaveResourceFile(GetCurrentResourceName(), 'players.json', json.encode(allowList))
loadAllowList()
else
showError(TranslateCap('identifier_not_allowlisted'))
return
end
end, true, {
help = TranslateCap('help_allowlist_remove'),
validate = true,
arguments = {
{ name = TranslateCap('license'), help = TranslateCap('help_license'), type = 'string' }
}
})
16 changes: 0 additions & 16 deletions server-data/resources/[esx_addons]/esx_allowlist/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions server-data/resources/[esx_addons]/esx_allowlist/config.lua

This file was deleted.

19 changes: 0 additions & 19 deletions server-data/resources/[esx_addons]/esx_allowlist/fxmanifest.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/cs.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/de.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/el.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/en.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/es.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/fi.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/fr.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/hu.lua

This file was deleted.

14 changes: 0 additions & 14 deletions server-data/resources/[esx_addons]/esx_allowlist/locales/it.lua

This file was deleted.

Loading

0 comments on commit 027d8bb

Please sign in to comment.