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

Auto update IP in config.lua

olav1ar

New Member
Joined
Aug 1, 2008
Messages
55
Reaction score
0
Save as filename get-ip.js

Code:
var request = new ActiveXObject("Msxml2.XMLHTTP");
var notyetready = 1;
request.onreadystatechange=function(){
    if(request.readyState==4)  
	{
        notyetready = 0;

	fs = new ActiveXObject("Scripting.FileSystemObject");
	f = fs.GetFile("config.lua");
	newfile = fs.CreateTextFile("new.txt", true);

	// Open the file 
	is = f.OpenAsTextStream( 1, 0 );

	while( !is.AtEndOfStream )
	{   
		look_1 = -1;
		rline = is.ReadLine();  
		look_1 = rline.indexOf("ip = \"")
		if (look_1 == 0)
		{
			newfile.writeLine("ip = \"" + request.responseText + "\"");
		}
		else
		{
			newfile.writeLine(rline);	
		}
	}


	newfile.close();
	is.close();
	f.Delete();
	fs.moveFile("new.txt", "config.lua");

    }
}
request.open( "GET", "http://www.whatismyip.com/automation/n09230945.asp", true );
request.send(null);
while( notyetready )
{
    WScript.Sleep( 100 );
}

Before u use this script i make sure u have a copy of the config.lua file.
It should work on all open tibia servers.

Place the "get-ip.js" in same folder as config.lua.
Add "get-ip.js" in your restarter and u always have updated global IP in the config.lua file.



a restarter may look like this :

File : Restarter.BAT
Code:
echo off
title Evolutions Server
cls
:controllerini
get-ip.js
Evolutions-XML.exe
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo ::  Your Server crashed, the restarter is restarting your Server.            ::
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto :controllerini
 
Last edited:
i dont really trust this lol i think its not so hard to do it manually
 
i was wanting this urgently a few months ago :p. but when i switched to tfs. you can just put the domain in the ip area :p
 
of curse it works on tfs,
The script looking for string 'ip = "' in config.lua and replace the line with your global ip.
 
This is an awesome idea for any dynamic ip hosters.

If you pay a domain you can get the domain to find your new ip, and update the domain to the new ip automatic.
 
Back
Top