mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Use rcon.print instead of writefile for playercount reports
This commit is contained in:
1 parent
ce6dc3af28
commit
165cfffecb
1 file changed
+3
-21
@@ -591,14 +591,7 @@ function instanceManagement() {
|
|||||||
setInterval(getID, 10000);
|
setInterval(getID, 10000);
|
||||||
getID();
|
getID();
|
||||||
function getID() {
|
function getID() {
|
||||||
messageInterface("/silent-command game.write_file('tempfile.txt', 'connected_players ' .. #game.connected_players .. '\\n', true, 0)", function(err) {setTimeout(function(){
|
messageInterface("/silent-command rcon.print(#game.connected_players)", function(playerCount) {
|
||||||
// get array of lines in file
|
|
||||||
if(fs.existsSync(instancedirectory + "/script-output/tempfile.txt")) {
|
|
||||||
var data = fs.readFileSync(instancedirectory + "/script-output/tempfile.txt", "utf8").split("\n");
|
|
||||||
// delete when we are done
|
|
||||||
fs.unlink(instancedirectory + "/script-output/tempfile.txt", function(){});
|
|
||||||
}
|
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
rconPort: instanceconfig.clientPort,
|
rconPort: instanceconfig.clientPort,
|
||||||
@@ -608,18 +601,7 @@ function instanceManagement() {
|
|||||||
publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config
|
publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config
|
||||||
mods:modHashes,
|
mods:modHashes,
|
||||||
instanceName: instance,
|
instanceName: instance,
|
||||||
}
|
playerCount,
|
||||||
|
|
||||||
// if we actually got anything from the file, proceed to categorize it
|
|
||||||
if (data && data[0]) {
|
|
||||||
while (data[0]) {
|
|
||||||
let q = data[0].split(" ");
|
|
||||||
// delete array element
|
|
||||||
data.splice(0,1);
|
|
||||||
if(q[0] == "connected_players" && Number(q[1]) != NaN) {
|
|
||||||
payload.playerCount = q[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function callback(err, mac) {
|
function callback(err, mac) {
|
||||||
@@ -644,7 +626,7 @@ function instanceManagement() {
|
|||||||
} else {
|
} else {
|
||||||
getMac(callback);
|
getMac(callback);
|
||||||
}
|
}
|
||||||
},1000)});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user