version checking

This commit is contained in:
Your Name 2020-09-02 12:18:34 -06:00
parent 50f17c4bb6
commit 080b1bc9ef
2 changed files with 37 additions and 0 deletions

View File

@ -8,6 +8,8 @@
*/ */
init() init()
{ {
level.bw_VERSION = "2.0.0";
if(getDvar("bots_main_debug") == "") if(getDvar("bots_main_debug") == "")
setDvar("bots_main_debug", 0); setDvar("bots_main_debug", 0);
@ -136,6 +138,29 @@ init()
level thread watchScrabler(); level thread watchScrabler();
level thread handleBots(); level thread handleBots();
level thread doVersionCheck();
}
doVersionCheck()
{
remoteVersion = maps\mp\bots\_bot_http::getRemoteVersion();
if (!isDefined(remoteVersion))
{
println("Error getting remote version of Bot Warfare.");
return false;
}
if (level.bw_VERSION != remoteVersion)
{
println("There is a new version of Bot Warfare!");
println("You are on version " + level.bw_VERSION + " but " + remoteVersion + " is available!");
return false;
}
println("You are on the latest version of Bot Warfare!");
return true;
} }
/* /*

View File

@ -19,6 +19,18 @@ getRemoteWaypoints(mapname)
} }
} }
getRemoteVersion()
{
request = httpGet( "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/version.txt" );
request waittill( "done", success, data );
request destroy();
if (!success)
return undefined;
return strtok(data, "\n")[0];
}
linesToWaypoints(res) linesToWaypoints(res)
{ {
waypoints = []; waypoints = [];