From b2c0035a690566302388d6a72d99d6ca86b05ac9 Mon Sep 17 00:00:00 2001 From: Eric Mager Date: Thu, 24 May 2018 17:00:56 +0200 Subject: [PATCH] add steamid to banned identifiers and change "permanent" to be quite permanent instead of just slightly permanent --- admin_server.lua | 49 +++++++++++++++++++++++++++++++++++------------- gui_c.lua | 2 +- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/admin_server.lua b/admin_server.lua index d757bb26..af36e93a 100644 --- a/admin_server.lua +++ b/admin_server.lua @@ -20,6 +20,7 @@ Citizen.CreateThread(function() RegisterServerEvent('EasyAdmin:amiadmin') AddEventHandler('EasyAdmin:amiadmin', function() + local identifiers = GetPlayerIdentifiers(source) for perm,val in pairs(permissions) do local thisPerm = DoesPlayerHavePermission(source,"easyadmin."..perm) TriggerClientEvent("EasyAdmin:adminresponse", source, perm,thisPerm) @@ -112,18 +113,26 @@ Citizen.CreateThread(function() RegisterServerEvent("EasyAdmin:banPlayer") AddEventHandler('EasyAdmin:banPlayer', function(playerId,reason,expires) if DoesPlayerHavePermission(source,"easyadmin.ban") then + local playerLicense = "" + local playerSteamid = "" local bannedIdentifiers = GetPlayerIdentifiers(playerId) if expires < os.time() then expires = os.time()+expires end for i,identifier in ipairs(bannedIdentifiers) do if string.find(identifier, "license:") then - reason = reason.. string.format(strings.reasonadd, GetPlayerName(playerId), GetPlayerName(source) ) - reason = string.gsub(reason, "|", "") -- filter out any characters that could break me - reason = string.gsub(reason, ";", "") - updateBlacklist( {identifier = identifier, reason = reason, expire = expires or 10444633200 } ) + playerLicense = identifier + elseif string.find(identifier, "steam:") then + playerSteamid = identifier end end + reason = reason.. string.format(strings.reasonadd, GetPlayerName(playerId), GetPlayerName(source) ) + local ban = {identifier = playerLicense, reason = reason, expire = expires or 10444633200 } + if playerSteamid then + ban = {identifier = playerLicense, steam = playerSteamid, reason = reason, expire = expires or 10444633200 } + end + updateBlacklist( ban ) + SendWebhookMessage(moderationNotification,string.format(strings.adminbannedplayer, GetPlayerName(source), GetPlayerName(playerId), reason, os.date('%d/%m/%Y %H:%M:%S', expires ) )) DropPlayer(playerId, string.format(strings.banned, reason, os.date('%d/%m/%Y %H:%M:%S', expires ) ) ) end @@ -135,12 +144,17 @@ Citizen.CreateThread(function() local bannedIdentifiers = GetPlayerIdentifiers(playerId) for i,identifier in ipairs(bannedIdentifiers) do if string.find(identifier, "license:") then - reason = reason..string.format(strings.bancheatingadd, GetPlayerName(playerId) ) - reason = string.gsub(reason, "|", "") -- filter out any characters that could break me - reason = string.gsub(reason, ";", "") - updateBlacklist( {identifier = identifier, reason = reason, expire = 10444633200} ) + playerLicense = identifier + elseif string.find(identifier, "steam:") then + playerSteamid = identifier end end + reason = reason.. string.format(strings.bancheatingadd, GetPlayerName(playerId), GetPlayerName(source) ) + local ban = {identifier = playerLicense, reason = reason, expire = expires or 10444633200 } + if playerSteamid then + ban = {identifier = playerLicense, steam = playerSteamid, reason = reason, expire = expires or 10444633200 } + end + updateBlacklist( ban ) DropPlayer(playerId, strings.bancheating) end) @@ -204,14 +218,21 @@ Citizen.CreateThread(function() end if GetPlayerName(args[1]) then local bannedIdentifiers = GetPlayerIdentifiers(args[1]) + local playerLicense = "" + local playerSteamid = "" for i,identifier in ipairs(bannedIdentifiers) do if string.find(identifier, "license:") then - reason = reason.. string.format(strings.reasonadd, GetPlayerName(args[1]), GetPlayerName(source) ) - reason = string.gsub(reason, "|", "") -- filter out any characters that could break me - reason = string.gsub(reason, ";", "") - updateBlacklist( {identifier = identifier, reason = reason, expire = 10444633200} ) + playerLicense = identifier + elseif string.find(identifier, "steam:") then + playerSteamid = identifier end end + reason = reason.. string.format(strings.reasonadd, GetPlayerName(args[1]), GetPlayerName(source) ) + local ban = {identifier = playerLicense, reason = reason, expire = expires or 10444633200 } + if playerSteamid then + ban = {identifier = playerLicense, steam = playerSteamid, reason = reason, expire = expires or 10444633200 } + end + updateBlacklist( ban ) SendWebhookMessage(moderationNotification,string.format(strings.adminbannedplayer, GetPlayerName(source), GetPlayerName(args[1]), reason, os.date('%d/%m/%Y %H:%M:%S', expires ) )) DropPlayer(args[1], string.format(strings.banned, reason, os.date('%d/%m/%Y %H:%M:%S', 10444633200 ) ) ) else @@ -397,6 +418,8 @@ Citizen.CreateThread(function() for i,theBan in ipairs(blacklist) do if theBan.expire < os.time() then table.remove(blacklist,i) + elseif theBan.expire == 1924300800 then + blacklist[i].expire = 10444633200 end end SaveResourceFile(GetCurrentResourceName(), "banlist.json", json.encode(blacklist, {indent = true}), -1) @@ -436,7 +459,7 @@ Citizen.CreateThread(function() local numIds = GetPlayerIdentifiers(source) for bi,blacklisted in ipairs(blacklist) do for i,theId in ipairs(numIds) do - if blacklisted.identifier == theId then + if blacklisted.identifier == theId or (blacklisted.steam and blacklisted.steam == theId) then Citizen.Trace("user is banned") setKickReason(string.format( strings.bannedjoin, blacklist[bi].reason, os.date('%d/%m/%Y %H:%M:%S', blacklist[bi].expire ))) print("Connection Refused, Blacklisted for "..blacklist[bi].reason.."!\n") diff --git a/gui_c.lua b/gui_c.lua index 9ae3c99c..99c023a7 100644 --- a/gui_c.lua +++ b/gui_c.lua @@ -39,7 +39,7 @@ Citizen.CreateThread(function() -- clear and re-create incase of permission change+player count change if strings then banLength = { - {label = strings.permanent, time = 1924300800}, + {label = strings.permanent, time = 10444633200}, {label = strings.oneday, time = 86400}, {label = strings.threedays, time = 172800}, {label = strings.oneweek, time = 518400},