This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
161 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Raccoon Whitelisting | ||
## What is Raccoon Whitelisting? | ||
Raccoon Whitelisting is a new whitelist script, created by TheRaccoon (PeEcEeChIP) for an easy-to-use Discord whitelist. This script uses [Badger's](https://github.com/JaredScar) [Discord API Script](https://github.com/JaredScar/Badger_Discord_API), refraining from having to make another Discord bot token, and grab role ID's, making this whitelist script easier to use for anybody. | ||
|
||
## Configuration | ||
``` | ||
-- Change your server whitelist configurations here. | ||
Configure = { | ||
DiscordKick = 'We couldn\'t detect the desktop client of Discord, please check if your Discord is open.', -- Sends message to the user if they're Discord is not open. | ||
WhitelistKick = 'We\'re sorry, but this server has been whitelisted. Please join the Discord and check how to be whitelisted.', -- Sends message to the user if they're not whitelisted in the server. | ||
RoleIDKick = 'Sorry, but we couldn\'t detect your Role ID\'s. If this problem persist\'s please contact the server developer/development team.', | ||
svname = 'Server Name', | ||
Whitelisted = { -- Roles that you assigned in Badgers API that should pass the whitelist, make sure each role is listed with a comma. | ||
"Whitelisted Role #1", | ||
"Whitelisted Role #2", | ||
"Whitelisted Role #3", | ||
}, | ||
}``` |
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,13 @@ | ||
fx_version "cerulean" | ||
game "gta5" | ||
|
||
-- Define the resource metadata | ||
name "Raccoon-Whitelist" | ||
description "A simple whitelist script that utilizes Badger's new API" | ||
author "TheRaccoon#1023 (PeEcEeChIP)" | ||
version "v0.1.0" | ||
|
||
|
||
server_script "settings.lua" | ||
server_script "server.lua" | ||
server_script "version_check.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,71 @@ | ||
function ExtractIdentifiers(src) | ||
local identifiers = { | ||
discord = "" | ||
} | ||
|
||
--Loop Identifiers | ||
for i = 0, GetNumPlayerIdentifiers(src) - 1 do | ||
local id = GetPlayerIdentifier(src, i) | ||
|
||
|
||
if string.find(id, "discord") then | ||
identifiers.discord = id | ||
end | ||
end | ||
return identifiers | ||
end | ||
|
||
roleList = Configure.Whitelisted; | ||
|
||
AddEventHandler("playerConnecting", function(name, setCallback, deferrals) | ||
local Configure = Configure | ||
deferrals.defer() | ||
local src = source | ||
local identifierDiscord = ""; | ||
deferrals.update("Checking Your Server Permissions For " .. Configure.svname) | ||
|
||
Citizen.Wait(0); | ||
|
||
for k, v in ipairs(GetPlayerIdentifiers(src)) do | ||
if string.sub(v, 1, string.len("discord:")) == "discord:" then | ||
identifierDiscord = v | ||
end | ||
end | ||
local isWhitelisted = false; | ||
if identifierDiscord then | ||
local roleIDs = exports.Badger_Discord_API:GetDiscordRoles(src) | ||
if not (roleIDs == false) then | ||
for i = 1, #roleList do | ||
for j = 1, #roleIDs do | ||
if exports.Badger_Discord_API:CheckEqual(roleList[i], roleIDs[j]) then | ||
print("[Raccoon-Whitelist] (playerConnecting) Allowing " .. GetPlayerName(src) .. " to join with the role " .. roleList[i]) | ||
print("[Raccoon-Whitelist] (playerConnecting) Player " .. GetPlayerName(src) .. " Attempted to connect with Raccoon-Whitelist, They were allowed entry") | ||
isWhitelisted = true; | ||
else | ||
if isWhitelisted == false then | ||
isWhitelisted = false; | ||
end | ||
end | ||
end | ||
end | ||
else | ||
print("[Raccoon-Whitelist] (playerConnecting) Player " .. GetPlayerName(src) .. " We could not get your Role ID\'s, failed to connect.") | ||
print("[Raccoon-Whitelist] (playerConnecting) Player " .. GetPlayerName(src) .. " Attempted to connect with Raccoon-Whitelist, connection has failed.") | ||
deferrals.done(Configure.RoleIDKick) | ||
CancelEvent() | ||
return; | ||
end | ||
else | ||
print("[Raccoon-Whitelist] (playerConnecting) Declined connection from " .. GetPlayerName(src) .. " because they did not have Discord open") | ||
print("[Raccoon-Whitelist] (playerConnecting) Player " .. GetPlayerName(src) .. " Attempted to connect with Raccoon-Whitelist, connection has failed.") | ||
deferrals.done(Configure.DiscordKick) | ||
CancelEvent() | ||
return; | ||
end | ||
if isWhitelisted then | ||
deferrals.done(); | ||
else | ||
deferrals.done(Configure.WhitelistKick); | ||
CancelEvent() | ||
end | ||
end) |
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,12 @@ | ||
-- Change your server whitelist configurations here. | ||
Configure = { | ||
DiscordKick = 'We couldn\'t detect the desktop client of Discord, please check if your Discord is open.', -- Sends message to the user if they're Discord is not open. | ||
WhitelistKick = 'We\'re sorry, but this server has been whitelisted. Please join the Discord and check how to be whitelisted.', -- Sends message to the user if they're not whitelisted in the server. | ||
RoleIDKick = 'Sorry, but we couldn\'t detect your Role ID\'s. If this problem persist\'s please contact the server developer/development team.', | ||
svname = 'Server Name', | ||
Whitelisted = { -- Roles that you assigned in Badgers API that should pass the whitelist, ALSO Make sure that **each** role ends with a comma! | ||
"Whitelisted Role #1", | ||
"Whitelisted Role #2", | ||
"Whitelisted Role #3", | ||
}, | ||
} |
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,47 @@ | ||
local label = | ||
[[ | ||
// | ||
|| ____ _ ____ _ __ ___ __ | ||
|| / __ \____ _______________ ____ ____ | | / / /_ (_) /____ / (_)____/ /_ | ||
|| / /_/ / __ `/ ___/ ___/ __ \/ __ \/ __ \ | | /| / / __ \/ / __/ _ \/ / / ___/ __/ | ||
|| / _, _/ /_/ / /__/ /__/ /_/ / /_/ / / / / | |/ |/ / / / / / /_/ __/ / (__ ) /_ | ||
|| /_/ |_|\__,_/\___/\___/\____/\____/_/ /_/ |__/|__/_/ /_/_/\__/\___/_/_/____/\__/ | ||
|| Created by TheRaccoon#1023 | ||
||]] | ||
Citizen.CreateThread(function() | ||
local CurrentVersion = GetResourceMetadata(GetCurrentResourceName(), 'version', 0) | ||
if not CurrentVersion then | ||
print('^1Raccoon-Whitelist Version Check Failed!^7') | ||
end | ||
|
||
function VersionCheckHTTPRequest() | ||
PerformHttpRequest('https://raw.githubusercontent.com/PeEcEeChIP/version-history/version/raccoon-whitelist.json', VersionCheck, 'GET') | ||
end | ||
|
||
function VersionCheck(err, response, headers) | ||
Citizen.Wait(3000) | ||
if err == 200 then | ||
local Data = json.decode(response) | ||
if CurrentVersion ~= Data.NewestVersion then | ||
print( label ) | ||
print(' || \n || Raccoon-Whitelist is outdated!') | ||
print(' || Current version: ^2' .. Data.NewestVersion .. '^7') | ||
print(' || Your version: ^1' .. CurrentVersion .. '^7') | ||
print(' || Please download the lastest version from ^5' .. Data.DownloadLocation .. '^7') | ||
if Data.Changes ~= '' then | ||
print(' || \n || ^5Changes: ^7' .. Data.Changes .. "\n^0 \\\\\n") | ||
end | ||
else | ||
print( label ) | ||
print(' || ^2Raccoon-Whitelist is up to date!\n^0 ||\n \\\\\n') | ||
end | ||
else | ||
print( label ) | ||
print(' || ^1There was an error getting the latest version information, if the issue persists contact TheRaccoon#1023 on Discord.\n^0 ||\n \\\\\n') | ||
end | ||
|
||
SetTimeout(60000000, VersionCheckHTTPRequest) | ||
end | ||
|
||
VersionCheckHTTPRequest() | ||
end) |