37 lines
		
	
	
		
			949 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			949 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
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
 |