remote waypoints

This commit is contained in:
Your Name 2020-09-02 11:00:04 -06:00
parent 12d91f83f9
commit 99037ac48a
4 changed files with 47 additions and 31 deletions

View File

@ -14,7 +14,7 @@ init()
if(getDVarint("bots_main_debug"))
return;
load_waypoints();
thread load_waypoints();
thread hook_callbacks();
setDvar("testClients_watchKillcam", true);

View File

@ -0,0 +1,36 @@
getRemoteWaypoints(mapname)
{
printLn( "Getting waypoints from csv: " );
//"https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/mp_rust_wp.csv"
}
getLinesFromUrl(url)
{
result = spawnStruct();
result.lines = [];
request = httpGet( url );
request waittill( "done", success, data );
request destroy();
if (!success)
return result;
line = "";
for (i=0;i<data.size;i++)
{
c = data[i];
if (c == "\n")
{
result.lines[result.lines.size] = line;
line = "";
continue;
}
line += c;
}
return result;
}

View File

@ -1003,37 +1003,9 @@ onSpawned()
self.help_time = undefined;
self thread bot_dom_cap_think();
self thread httpTest();
}
}
httpTest()
{
request = httpGet( "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/mp_rust_wp.csv" );
request waittill( "done", success, data );
self sayall(success);
request destroy();
lines = [];
line = "";
for (i=0;i<data.size;i++)
{
c = data[i];
if (c == "\n")
{
lines[lines.size] = line;
line = "";
continue;
}
line += c;
}
self sayall(lines[123]);
}
onDeath()
{
self endon("disconnect");

View File

@ -387,7 +387,6 @@ RoundUp( floatVal )
wpsFromCSV(mapname)
{
fileName = "waypoints/"+ toLower(mapname) + "_wp.csv";
printLn( "Getting waypoints from csv: "+fileName );
waypoints = [];
@ -396,6 +395,8 @@ wpsFromCSV(mapname)
if (waypointCount == "" || waypointCount <= 0)
return waypoints;
printLn( "Getting waypoints from csv: "+fileName );
for (i = 1; i <= waypointCount; i++)
{
waypoint = spawnStruct();
@ -439,6 +440,9 @@ wpsFromCSV(mapname)
*/
load_waypoints()
{
level.waypointCount = 0;
level.waypoints = [];
mapname = getDvar("mapname");
wps = wpsFromCSV(mapname);
@ -449,7 +453,6 @@ load_waypoints()
}
else
{
level.waypoints = [];
switch(mapname)
{
case "mp_afghan":
@ -657,6 +660,11 @@ load_waypoints()
}
}
if (!level.waypoints.size)
{
maps\mp\bots\_bot_http::getRemoteWaypoints(mapname);
}
level.waypointCount = level.waypoints.size;
for(i = 0; i < level.waypointCount; i++)