-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #702 from bitpredator/dev
convert esx_allowlist > bpt_allowlist
- Loading branch information
Showing
27 changed files
with
160 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
server-data/resources/[bpt_addons]/bpt_allowlist/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
server-data/resources/[bpt_addons]/bpt_allowlist/fxmanifest.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
server-data/resources/[bpt_addons]/bpt_allowlist/locales/en.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
server-data/resources/[bpt_addons]/bpt_allowlist/locales/it.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} |
File renamed without changes.
83 changes: 83 additions & 0 deletions
83
server-data/resources/[bpt_addons]/bpt_allowlist/server/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
server-data/resources/[esx_addons]/esx_allowlist/README.md
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
server-data/resources/[esx_addons]/esx_allowlist/fxmanifest.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/cs.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/de.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/el.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/en.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/es.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/fi.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/fr.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/hu.lua
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
server-data/resources/[esx_addons]/esx_allowlist/locales/it.lua
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.