• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent DDoS protection*

I re-wrote your script, it's now more clear and more up-to-date :p
(Note: Haven't tested, i hope it works.)
Code:
local config = {
	websites = {
		urls = {
			"http://google.com",
			"http://wikipedia.org"
		},
		status = {
			true,
			true
		}
	},
	security = {
		kickall = true,
		save = true,
		shutdown = true
	}
}

config.security.kickall = getBooleanFromString(config.security.kickall)
config.security.save = getBooleanFromString(config.security.save)
config.security.shutdown = getBooleanFromString(config.security.shutdown)

function onThink(interval, lastExecution)
	for i = 1, #config.websites.urls do
		local tmpUrl = config.websites.urls[i]
		if(not socket.http.request(tmpUrl))
			config.websites.status[i] = false
			print(">> ".. tmpUrl .." seems to be offline.")
		else
			config.websites.status[i] = true
		end
	end

	if(not isInArray(config.websites.status, true)) then
		print(">> Server is probably under attack...")
		if(config.security.kickall) then
			for _, player in ipairs(getPlayersOnline()) do
				doRemoveCreature(player)
			end
			print("\tAll players were kicked.")
		end
		if(config.security.save) then
			doSaveServer(false)
			print("\tServer has been saved.")
		end
		if(config.security.shutdown) then
			doSetGameState(GAMESTATE_SHUTDOWN)
			print("\tShutting down...")
		end
	end
	return true
end
 
Last edited:
J have problem. J tested all this script and every time show me this error:

[31/01/2010 20:08:00] Lua Script Error: [GlobalEvent Interface]
[31/01/2010 20:08:00] data/globalevents/scripts/noDDoS.lua:eek:nThink

[31/01/2010 20:08:00] data/globalevents/scripts/noDDoS.lua:22: attempt to index global 'socket' (a nil value)
[31/01/2010 20:08:00] stack traceback:
[31/01/2010 20:08:00] data/globalevents/scripts/noDDoS.lua:22: in function <data/globalevents/scripts/noDDoS.lua:21>
[31/01/2010 20:08:00] [Error - GlobalEvents::think] Couldn't execute event: ddos</dos>

Did you help me? J use TFS 0.3.5.
 
ddos.png


It doesn't work, whats wrong?
 
Back
Top