mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-15 15:04:53 +02:00
Full Distribution
This commit is contained in:
36
data/talkactions/scripts/ipban.lua
Normal file
36
data/talkactions/scripts/ipban.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
local ipBanDays = 7
|
||||
|
||||
function onSay(player, words, param)
|
||||
if not player:getGroup():getAccess() then
|
||||
return true
|
||||
end
|
||||
|
||||
local resultId = db.storeQuery("SELECT `account_id`, `lastip` FROM `players` WHERE `name` = " .. db.escapeString(param))
|
||||
if resultId == false then
|
||||
return false
|
||||
end
|
||||
|
||||
local targetIp = result.getDataLong(resultId, "lastip")
|
||||
result.free(resultId)
|
||||
|
||||
local targetPlayer = Player(param)
|
||||
if targetPlayer then
|
||||
targetIp = targetPlayer:getIp()
|
||||
targetPlayer:remove()
|
||||
end
|
||||
|
||||
if targetIp == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
resultId = db.storeQuery("SELECT 1 FROM `ip_bans` WHERE `ip` = " .. targetIp)
|
||||
if resultId ~= false then
|
||||
result.free(resultId)
|
||||
return false
|
||||
end
|
||||
|
||||
local timeNow = os.time()
|
||||
db.query("INSERT INTO `ip_bans` (`ip`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
|
||||
targetIp .. ", '', " .. timeNow .. ", " .. timeNow + (ipBanDays * 86400) .. ", " .. player:getGuid() .. ")")
|
||||
return false
|
||||
end
|
Reference in New Issue
Block a user