Skip to content

Commit

Permalink
finalized version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatH0r committed Jan 28, 2016
1 parent aa9578a commit c9975a5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions source/scripts/quakeTv.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name QuakeTV: prototype for automated connect + spec of high rated matches
// @version 0.3
// @version 1.0
// @author PredatH0r
// @description Use "/qtv help" to get a list of supported commands
// @description Use "/qtv 0" to stop connecting + following
Expand All @@ -12,6 +12,11 @@

/*
Version 1.0
- using ZMQ relay stream from qlstats.net to get notified about player deaths/joins so POV can be updated instantly
- reduced console spam to a minimum
Version 0.3
- combined various commands and cvars into "/qtv".
- added support to follow the n-th best match and connect to the next best match if a connection can't be established within 10sec
Expand All @@ -36,7 +41,7 @@ var $;
var autoReconnect;
var eventSource = null;
var deadPlayers = [];
var clientIdCache = null; // dictionary with steam-id => client-id
var clientIdCache = null;

var HELP_MSG = "use ^2\\qtv help^7 to get a list of qtv commands";

Expand Down Expand Up @@ -95,8 +100,9 @@ var $;
echo("^3all^7,^3eu^7,^3na^7... set region to all,eu,na,sa,au,as,af");
echo("^31^7..^310^7 connect to + follow the n-th best match");
echo("^30^7 stop automatic connecting and following");
echo("^5qtv_announce ^30^7|^31^7 to turn announcements off/on when switching POV")
echo("Multiple commands can be separated with comma, spaces are NOT allowed");
echo("e.g.: \\qtv duel,all,1");
echo("e.g.: ^2\\qtv duel,all,1^7");
}

function connect(matchRank) {
Expand Down Expand Up @@ -213,18 +219,17 @@ var $;
}
else if (event.TYPE == "PLAYER_SWITCHTEAM")
clientIdCache = null;
else if (event.TYPE == "ROUND_OVER")
else if (event.TYPE == "ROUND_OVER") {
deadPlayers = [];
clearTimeout(followTimer);
followTimer = setTimeout(followBestPlayerOnCurrentServer, 5000);
}
else if (event.TYPE == "MATCH_REPORT") {
deadPlayers = [];
if (autoReconnect) {
clearTimeout(connectTimer);
connectTimer = setTimeout(connect, 10 * 1000);
}
else {
clearTimeout(followTimer);
followTimer = setTimeout(followBestPlayerOnCurrentServer, 3000);
}
}
}

Expand Down Expand Up @@ -292,9 +297,9 @@ var $;
log("emptyServer");
connect();
}
else if (serverBrowserData[0].steamid != following) {
else if (serverBrowserData.length >= 1 && serverBrowserData[0].steamid != following) {
// either a higher rated player joined, or the highest rated player left or moved to spec
log("povNotAvailable");
log("notFollowingBestPlayer");
switchPov();
}
}
Expand All @@ -303,9 +308,9 @@ var $;
}
});

// safeguard timer to make sure we don't accidentally end up in free-float cam
followTimer = setTimeout(followBestPlayerOnCurrentServer, 10 * 1000);


function switchPov() {
log("switchPov()");
if (!clientIdCache)
Expand Down

0 comments on commit c9975a5

Please sign in to comment.