• 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!

A script that kill theforgottenserver when ip changes

Luciano

Member
Joined
Feb 18, 2010
Messages
998
Reaction score
24
Hi!
I have a problem here:
My ip changes almost like each 24-48h, i tryed fix it by downloading no-ip DUC to auto-change the ip, so the players could keep playing.
But the problem is: the ip change, DUC atualize it, but players cant login, i need to re-start server.
Would it be hard to make a bat, or maybe one C++ code to check if the external IP change, close server, and re-start in 3 minutes? (IF possible, save and then quit theforgottenserver)
Thx

Distro: 0.3.6 running 8.6
 
Use LuaSocket to load the IP from whatismyip.com with http.request function and save it in either global variable from lib or global storage key then execute the function each hour and compare both IPs to check if the shutdown is needed and then use os.exit or set game state to closed.
 
okay.
function getip whatismyip.com
check if ip not = to older ip
if ip not same
then
shutdown theforgottenserver
wait 1000
start theforgottenserver
loop
///// didnt work
 
Code:
 if newIp ~= oldIP then
	open config.lua
	rewrite config.lua only changing the ip
	save config.lua
	doReloadInfo(RELOAD_CONFIG)
end

Not sure if that works but you can try it
 
Code:
require('socket.http')
local data, status = http.request('http://automation.whatismyip.com/n09230945.asp')
if status == 200 then
	setGlobalStorage(1234, data)
end

Code:
require('socket.http')
function onThink(interval)
	local data, status = http.request('http://automation.whatismyip.com/n09230945.asp')
	if status == 200 then
		if getGlobalStorage(1234) ~= data then
			setGameState(GAMESTATE_SHUTDOWN)
		enf
	end
	return true
end

@darkhaos:
I don't think it would work with config reload, TFS needs to bind the IP address to socket again.
 
Back
Top