⚠️⚠️ Steam Ditch ⚠️⚠️

This commit is contained in:
GhzGarage
2021-07-08 19:54:57 -05:00
parent b2ec7ae041
commit 0603076be3
5 changed files with 50 additions and 53 deletions
-1
View File
@@ -1,7 +1,6 @@
QBConfig = {}
QBConfig.MaxPlayers = GetConvarInt('sv_maxclients', 64) -- Gets max players from config file, default 32
QBConfig.IdentifierType = "steam" -- Set the identifier type (can be: steam, license)
QBConfig.DefaultSpawn = vector4(-1035.71, -2731.87, 12.86, 0.0)
QBConfig.Money = {}
+10 -10
View File
@@ -1,8 +1,8 @@
CREATE TABLE IF NOT EXISTS `players` (
`#` int(11) NOT NULL AUTO_INCREMENT,
`id` int(11) NOT NULL AUTO_INCREMENT,
`citizenid` varchar(255) NOT NULL,
`cid` int(11) DEFAULT NULL,
`steam` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` text NOT NULL,
@@ -13,26 +13,26 @@ CREATE TABLE IF NOT EXISTS `players` (
`metadata` text NOT NULL,
`inventory` longtext DEFAULT NULL,
`last_updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`#`),
PRIMARY KEY (`id`),
KEY `citizenid` (`citizenid`),
KEY `last_updated` (`last_updated`),
KEY `steam` (`steam`)
KEY `license` (`license`)
) ENGINE=InnoDB AUTO_INCREMENT=4189 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `permissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`steam` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`permission` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `steam` (`steam`)
KEY `license` (`license`)
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `bans` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`steam` varchar(50) DEFAULT NULL,
`license` varchar(50) DEFAULT NULL,
`license` varchar(50) DEFAULT NULL,
`discord` varchar(50) DEFAULT NULL,
`ip` varchar(50) DEFAULT NULL,
@@ -40,17 +40,17 @@ CREATE TABLE IF NOT EXISTS `bans` (
`expire` int(11) DEFAULT NULL,
`bannedby` varchar(255) NOT NULL DEFAULT 'LeBanhammer',
PRIMARY KEY (`id`),
KEY `steam` (`steam`),
KEY `license` (`license`),
KEY `license` (`license`),
KEY `discord` (`discord`),
KEY `ip` (`ip`)
) ENGINE=InnoDB AUTO_INCREMENT=518 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `whitelist` (
`steam` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`license` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`steam`),
PRIMARY KEY (`license`),
UNIQUE KEY `identifier` (`license`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+8 -9
View File
@@ -16,18 +16,18 @@ end)
local function OnPlayerConnecting(name, setKickReason, deferrals)
local player = source
local steamIdentifier
local license
local identifiers = GetPlayerIdentifiers(player)
deferrals.defer()
-- mandatory wait!
Wait(0)
deferrals.update(string.format("Hello %s. Your Steam ID is being checked.", name))
deferrals.update(string.format("Hello %s. Validating Your Rockstar License", name))
for _, v in pairs(identifiers) do
if string.find(v, "steam") then
steamIdentifier = v
if string.find(v, 'license') then
license = v
break
end
end
@@ -43,8 +43,8 @@ local function OnPlayerConnecting(name, setKickReason, deferrals)
deferrals.update(string.format("Welcome %s to {Server Name}.", name))
if not steamIdentifier then
deferrals.done("You are not connected to Steam.")
if not license then
deferrals.done('No Valid Rockstar License Found')
elseif isBanned then
deferrals.done(Reason)
else
@@ -231,11 +231,10 @@ AddEventHandler('QBCore:ToggleDuty', function()
end)
Citizen.CreateThread(function()
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `permissions`", function(result)
exports.ghmattimysql:execute('SELECT * FROM permissions', function(result)
if result[1] ~= nil then
for k, v in pairs(result) do
QBCore.Config.Server.PermissionList[v.steam] = {
steam = v.steam,
QBCore.Config.Server.PermissionList[v.license] = {
license = v.license,
permission = v.permission,
optin = true,
+29 -27
View File
@@ -149,11 +149,11 @@ QBCore.Functions.IsWhitelisted = function(source)
local identifiers = GetPlayerIdentifiers(source)
local rtn = false
if (QBCore.Config.Server.whitelist) then
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `whitelist` WHERE `"..QBCore.Config.IdentifierType.."` = '".. QBCore.Functions.GetIdentifier(source).."'", function(result)
exports['ghmattimysql']:execute('SELECT * FROM whitelist WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}, function(result)
local data = result[1]
if data ~= nil then
for _, id in pairs(identifiers) do
if data.steam == id or data.license == id then
if data.license == id then
rtn = true
end
end
@@ -168,13 +168,18 @@ end
QBCore.Functions.AddPermission = function(source, permission)
local Player = QBCore.Functions.GetPlayer(source)
if Player ~= nil then
QBCore.Config.Server.PermissionList[GetPlayerIdentifiers(source)[1]] = {
steam = GetPlayerIdentifiers(source)[1],
license = GetPlayerIdentifiers(source)[2],
QBCore.Config.Server.PermissionList[QBCore.Functions.GetIdentifier(source, 'license')] = {
license = QBCore.Functions.GetIdentifier(source, 'license'),
permission = permission:lower(),
}
QBCore.Functions.ExecuteSql(true, "DELETE FROM `permissions` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."'")
QBCore.Functions.ExecuteSql(true, "INSERT INTO `permissions` (`name`, `steam`, `license`, `permission`) VALUES ('"..GetPlayerName(source).."', '"..GetPlayerIdentifiers(source)[1].."', '"..GetPlayerIdentifiers(source)[2].."', '"..permission:lower().."')")
exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
exports['ghmattimysql']:execute('INSERT INTO permissions (name, license, permission) VALUES (@name, @license, @permission)', {
['@name'] = GetPlayerName(source),
['@license'] = QBCore.Functions.GetIdentifier(source, 'license'),
['@permission'] = permission:lower()
})
Player.Functions.UpdatePlayerData()
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, permission)
end
@@ -183,23 +188,22 @@ end
QBCore.Functions.RemovePermission = function(source)
local Player = QBCore.Functions.GetPlayer(source)
if Player ~= nil then
QBCore.Config.Server.PermissionList[GetPlayerIdentifiers(source)[1]] = nil
QBCore.Functions.ExecuteSql(true, "DELETE FROM `permissions` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."'")
QBCore.Config.Server.PermissionList[QBCore.Functions.GetIdentifier(source, 'license')] = nil
exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
Player.Functions.UpdatePlayerData()
end
end
QBCore.Functions.HasPermission = function(source, permission)
local retval = false
local steamid = GetPlayerIdentifiers(source)[1]
local licenseid = GetPlayerIdentifiers(source)[2]
local license = QBCore.Functions.GetIdentifier(source, 'license')
local permission = tostring(permission:lower())
if permission == "user" then
retval = true
else
if QBCore.Config.Server.PermissionList[steamid] ~= nil then
if QBCore.Config.Server.PermissionList[steamid].steam == steamid and QBCore.Config.Server.PermissionList[steamid].license == licenseid then
if QBCore.Config.Server.PermissionList[steamid].permission == permission or QBCore.Config.Server.PermissionList[steamid].permission == "god" then
if QBCore.Config.Server.PermissionList[license] ~= nil then
if QBCore.Config.Server.PermissionList[license].license == license then
if QBCore.Config.Server.PermissionList[license].permission == permission or QBCore.Config.Server.PermissionList[license].permission == "god" then
retval = true
end
end
@@ -211,12 +215,11 @@ end
QBCore.Functions.GetPermission = function(source)
local retval = "user"
Player = QBCore.Functions.GetPlayer(source)
local steamid = GetPlayerIdentifiers(source)[1]
local licenseid = GetPlayerIdentifiers(source)[2]
local license = QBCore.Functions.GetIdentifier(source, 'license')
if Player ~= nil then
if QBCore.Config.Server.PermissionList[Player.PlayerData.steam] ~= nil then
if QBCore.Config.Server.PermissionList[Player.PlayerData.steam].steam == steamid and QBCore.Config.Server.PermissionList[Player.PlayerData.steam].license == licenseid then
retval = QBCore.Config.Server.PermissionList[Player.PlayerData.steam].permission
if QBCore.Config.Server.PermissionList[Player.PlayerData.license] ~= nil then
if QBCore.Config.Server.PermissionList[Player.PlayerData.license].license == license then
retval = QBCore.Config.Server.PermissionList[Player.PlayerData.license].permission
end
end
end
@@ -225,34 +228,33 @@ end
QBCore.Functions.IsOptin = function(source)
local retval = false
local steamid = GetPlayerIdentifiers(source)[1]
local license = QBCore.Functions.GetIdentifier(source, 'license')
if QBCore.Functions.HasPermission(source, "admin") then
retval = QBCore.Config.Server.PermissionList[steamid].optin
retval = QBCore.Config.Server.PermissionList[license].optin
end
return retval
end
QBCore.Functions.ToggleOptin = function(source)
local steamid = GetPlayerIdentifiers(source)[1]
local license = QBCore.Functions.GetIdentifier(source, 'license')
if QBCore.Functions.HasPermission(source, "admin") then
QBCore.Config.Server.PermissionList[steamid].optin = not QBCore.Config.Server.PermissionList[steamid].optin
QBCore.Config.Server.PermissionList[license].optin = not QBCore.Config.Server.PermissionList[license].optin
end
end
QBCore.Functions.IsPlayerBanned = function (source)
local retval = false
local message = ""
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `bans` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."' OR `license` = '"..GetPlayerIdentifiers(source)[2].."' OR `ip` = '"..GetPlayerIdentifiers(source)[3].."'", function(result)
exports['ghmattimysql']:execute('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}, function(result)
if result[1] ~= nil then
if os.time() < result[1].expire then
retval = true
local timeTable = os.date("*t", tonumber(result[1].expire))
message = "You have been banned from the server:\n"..result[1].reason.."\nYour ban expires "..timeTable.day.. "/" .. timeTable.month .. "/" .. timeTable.year .. " " .. timeTable.hour.. ":" .. timeTable.min .. "\n"
else
QBCore.Functions.ExecuteSql(true, "DELETE FROM `bans` WHERE `id` = "..result[1].id)
exports['ghmattimysql']:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result[1].id})
end
end
end)
return retval, message
end
end
+3 -6
View File
@@ -35,8 +35,7 @@ QBCore.Player.CheckPlayerData = function(source, PlayerData)
PlayerData.source = source
PlayerData.citizenid = PlayerData.citizenid ~= nil and PlayerData.citizenid or QBCore.Player.CreateCitizenId()
PlayerData.steam = PlayerData.steam ~= nil and PlayerData.steam or QBCore.Functions.GetIdentifier(source, "steam")
PlayerData.license = PlayerData.license ~= nil and PlayerData.license or QBCore.Functions.GetIdentifier(source, "license")
PlayerData.license = PlayerData.license ~= nil and PlayerData.license or QBCore.Functions.GetIdentifier(source, 'license')
PlayerData.name = GetPlayerName(source)
PlayerData.cid = PlayerData.cid ~= nil and PlayerData.cid or 1
@@ -420,10 +419,9 @@ QBCore.Player.Save = function(source)
if PlayerData ~= nil then
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `players` WHERE `citizenid` = '"..PlayerData.citizenid.."'", function(result)
if result[1] == nil then
exports.ghmattimysql:execute('INSERT INTO players (citizenid, cid, steam, license, name, money, charinfo, job, gang, position, metadata) VALUES (@citizenid, @cid, @steam, @license, @name, @money, @charinfo, @job, @gang, @position, @metadata)', {
exports.ghmattimysql:execute('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (@citizenid, @cid, @license, @name, @money, @charinfo, @job, @gang, @position, @metadata)', {
['@citizenid'] = PlayerData.citizenid,
['@cid'] = tonumber(PlayerData.cid),
['@steam'] = PlayerData.steam,
['@license'] = PlayerData.license,
['@name'] = PlayerData.name,
['@money'] = json.encode(PlayerData.money),
@@ -434,9 +432,8 @@ QBCore.Player.Save = function(source)
['@metadata'] = json.encode(PlayerData.metadata)
})
else
exports.ghmattimysql:execute('UPDATE players SET steam=@steam, license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', {
exports.ghmattimysql:execute('UPDATE players SET license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', {
['@citizenid'] = PlayerData.citizenid,
['@steam'] = PlayerData.steam,
['@license'] = PlayerData.license,
['@name'] = PlayerData.name,
['@money'] = json.encode(PlayerData.money),