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

Autoupdater

poe6man3

Member
Joined
Aug 6, 2020
Messages
87
Solutions
1
Reaction score
12
Hello could somebody explain how the autoupdater works and stuff i need for it to work for example in otcv8

Lua:
-- CONFIG
APP_NAME = "otclientv8" -- important, change it, it's name for config dir and files in appdata
APP_VERSION = 1337      -- client version for updater and login to indentify outdated client
DEFAULT_LAYOUT = "retro"

-- If you don't use updater or other service, set it to updater = ""
Services = {
  website = "http://************", -- currently not used
  updater = "http://************/api/updater.php",
  news = "http://************/api/news.php",
  stats = "",
  crash = "http://************/api/crash.php",
  feedback = "http://************/api/feedback.php"
}

-- Servers accept http login url or ip:port:version
Servers = {
  OTClientV8 = "http://************/api/login.php",
  OTClientV8proxy = "http://************/api/login.php?proxy=1",
  OTClientV8classic = "************:7171:1099",
  OTClientV8cwithfeatures = "************:7171:1099:25:30:80:90",
}
ALLOW_CUSTOM_SERVERS = true -- if true it will show option ANOTHER on server list
-- CONFIG END

for now i understand the first 3 things but the rest is a black magic is anybody that is acknowledged in this stuff help me out ?
 
Assuming you have the updater.php files and the rest.. You just set the ****** to your ip/.com address. Make sure the locations are correct for the files. The servers is what the players can connect to in the client.

If you are using tibia 11+ I believe you do:

Lua:
Servers = {
     anyName = "http://YourWebsite/api/login.php"
}

if its any other you do

Lua:
Servers = {
    anyName = "ip:port:clientVersion"
}

The other options are for specific cases which you probably dont need. The main question is have you downloaded the files for the updater that go into your website folder?
 
I know 0 about autoupdater but going on from what u said i get it like this

  • i have to have website for it
  • all my files from client have to be somewhere in the website
  • and i just put the website adress into the updater
 
No, there is a set of files you need to download that has: updater.php, news.php, stats.php, crash.php, and feedback.php.
I am not sure where to get them but I spoke to Kondra and he said this should work for the updater.php or atleast you can make it work with it:

PHP:
<?php
// CONFIG
$files_dir = "/var/www/otclient/files";
$files_url = "http://************/files";
$files_and_dirs = array("data", "modules", "layouts", "init.lua");
$checksum_file = "checksums.txt";
$checksum_update_interval = 30; // seconds
$binaries = array(
    "WIN32-WGL" => "otclient_dx.exe",
    "WIN32-EGL" => "otclient_gl.exe",
    "WIN32-WGL-GCC" => "otclient_gcc_dx.exe",
    "WIN32-EGL-GCC" => "otclient_gcc_gl.exe",
    "X11-GLX" => "otclient_linux",
    "X11-EGL" => "otclient_linux",
    "ANDROID-EGL" => "" // we can't update android binary
);
// CONFIG END
function sendError($error) {
    echo(json_encode(array("error" => $error)));
    die();
}
$data = json_decode(file_get_contents("php://input"));
//if(!$data) {
//    sendError("Invalid input data");
//}
$version = $data->version ?: 0; // APP_VERSION from init.lua
$build = $data->build ?: ""; // 2.4, 2.4.1, 2.5, etc
$os = $data->os ?: "unknown"; // android, windows, mac, linux, unknown
$platform = $data->platform ?: ""; // WIN32-WGL, X11-GLX, ANDROID-EGL, etc
$args = $data->args; // custom args when calling Updater.check()
$binary = $binaries[$platform] ?: "";
if($build != "3.1" && strpos($platform, "ANDROID") !== false) {
    sendError("Outdated client ($build).\nUinstall current client and then download new from:\nhttp://************/otclientv8.apk");
}
$forVersion = "";
if($args && $args->version) {
    $forVersion = strval($args->version);
}
$cache = null;
$cache_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $checksum_file;
if (file_exists($cache_file) && (filemtime($cache_file) + $checksum_update_interval > time())) {
    $cache = json_decode(file_get_contents($cache_file), true);
}
if(!$cache) { // update cache
    $dir = realpath($files_dir);
    $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS));
    $cache = array();
    foreach ($rii as $file) {
        if (!$file->isFile())
            continue;
        $path = str_replace($dir, '', $file->getPathname());
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        $cache[$path] = hash_file("crc32b", $file->getPathname());
    }
    file_put_contents($cache_file . ".tmp", json_encode($cache));
    rename($cache_file . ".tmp", $cache_file);
}
$ret = array("url" => $files_url, "files" => array(), "keepFiles" => empty($forVersion) ? false : true);
foreach($cache as $file => $checksum) {
    $base = trim(explode("/", ltrim($file, "/"))[0]);
    if(strpos($file, "data/things") !== false && (empty($forVersion) || strpos($file, $forVersion) === false)) {
        continue;
    }
    if(in_array($base, $files_and_dirs)) {
        $ret["files"][$file] = $checksum;
    }
    if($base == $binary && !empty($binary)) {
        $ret["binary"] = array("file" => $file, "checksum" => $checksum);
    }
}
echo(json_encode($ret, JSON_PRETTY_PRINT));
?>

So you would create a file in yourwebsite/api folder name it updater.php and add that code to it. The rest you have to make manually unless you can find the files.

Lua:
Services = {
  website = "http://yourwebsite.com", -- currently not used
  updater = "http://yourwebsite.com/api/updater.php",
  news = "http://yourwebsite.com/api/news.php",
  stats = "",
  crash = "http://yourwebsite.com/api/crash.php",
  feedback = "http://yourwebsite.com/api/feedback.php"
}

Hopefully that makes it easier to understand. You only need the updater.php code/file above to make the updater work. The files you want to update would be in your website in the location:

$files_url = "http://************/files";
 
No problem, its confusing because half of the code needed isnt there haha. You have the client side and nothing for the website.
 
Back
Top