Skip to content

Commit

Permalink
add steamid to banned identifiers and change "permanent" to be quite …
Browse files Browse the repository at this point in the history
…permanent instead of just slightly permanent
  • Loading branch information
Blumlaut committed May 24, 2018
1 parent 889db26 commit b2c0035
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
49 changes: 36 additions & 13 deletions admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion gui_c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit b2c0035

Please sign in to comment.