-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimer.js
More file actions
163 lines (156 loc) · 7.4 KB
/
timer.js
File metadata and controls
163 lines (156 loc) · 7.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
var http = require('http');
var fs = require('fs');
var io = require('socket.io')(1337);
var initialBomb = 0;
var menuSteamID = "";
var playerSide = "";
console.log("CS:GO Bomb Timer, by Ron Melkhior");
console.error("Remember to move the config to your CS:GO cfg folder.");
console.log("Initiating server...");
function now() {
return Math.floor(new Date() / 1000);
}
http.createServer(function (req, res) {
var body = "";
var timerState = "";
var gameState = "";
req.on('data', function (chunk) {
if (req.method == 'POST') {
body += chunk;
}
});
req.on('end', function () {
parsedBody = JSON.parse(body);
if (parsedBody.hasOwnProperty("player")) {
if (parsedBody.player["activity"] == "menu") {
menuSteamID = parsedBody.player["steamid"].toString();
gameState = "I am currently in the CS:GO menu.";
}
if (parsedBody.player["activity"] == "playing") {
if (parsedBody.player["steamid"].toString() == menuSteamID) {
if (parsedBody.player["team"] == "T") {
playerSide = "Terrorist";
} else if (parsedBody.player["team"] == "CT") {
playerSide = "Counter-Terrorist";
}
}
}
}
if (parsedBody.hasOwnProperty("round")) {
if (parsedBody.round["bomb"] == "planted") {
var rightNow = now();
var initialCheck = initialBomb + 41;
if (rightNow > initialCheck) {
initialBomb = now();
timerState = "start";
}
}
}
if (parsedBody.hasOwnProperty("map")) {
if (parsedBody.map["mode"] == "gungameprogressive") {
mapPlayed = parsedBody.map["name"];
gameState = "I am currently playing an Arms Race match on " + mapPlayed + " as a " + playerSide;
} else if (parsedBody.map["mode"] == "deathmatch") {
mapPlayed = parsedBody.map["name"];
gameState = "I am currently playing a Deathmatch match on " + mapPlayed + " as a " + playerSide;
} else if (parsedBody.map["mode"] == "gungametrbomb") {
mapPlayed = parsedBody.map["name"];
terrorScore = parsedBody.map.team_t["score"];
ctScore = parsedBody.map.team_ct["score"];
if (terrorScore > ctScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently winning a Demolition match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently losing a Demolition match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore > terrorScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently losing a Demolition match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently winning a Demolition match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore == terrorScore) {
if (ctScore == 0) {
if (playerSide == "Terrorist") {
gameState = "I am currently starting a Demolition match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently starting a Demolition match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else {
if (playerSide == "Terrorist") {
gameState = "I am currently tying a Demolition match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently tying a Demolition match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
}
}
} else if (parsedBody.map["mode"] == "casual") {
mapPlayed = parsedBody.map["name"];
terrorScore = parsedBody.map.team_t["score"];
ctScore = parsedBody.map.team_ct["score"];
if (terrorScore > ctScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently winning a Casual match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently losing a Casual match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore > terrorScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently losing a Casual match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently winning a Casual match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore == terrorScore) {
if (ctScore == 0) {
if (playerSide == "Terrorist") {
gameState = "I am currently starting a Casual match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently starting a Casual match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else {
if (playerSide == "Terrorist") {
gameState = "I am currently tying a Casual match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently tying a Casual match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
}
}
} else if (parsedBody.map["mode"] == "competitive") {
mapPlayed = parsedBody.map["name"];
terrorScore = parsedBody.map.team_t["score"];
ctScore = parsedBody.map.team_ct["score"];
if (terrorScore > ctScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently winning a Competitive match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently losing a Competitive match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore > terrorScore) {
if (playerSide == "Terrorist") {
gameState = "I am currently losing a Competitive match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently winning a Competitive match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else if (ctScore == terrorScore) {
if (ctScore == 0) {
if (playerSide == "Terrorist") {
gameState = "I am currently starting a Competitive match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently starting a Competitive match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
} else {
if (playerSide == "Terrorist") {
gameState = "I am currently tying a Competitive match (" + terrorScore + "-" + ctScore + ") as a Terrorist on " + mapPlayed;
} else if (playerSide == "Counter-Terrorist") {
gameState = "I am currently tying a Competitive match (" + ctScore + "-" + terrorScore + ") as a Counter-Terrorist on " + mapPlayed;
}
}
}
}
}
var updateArray = {timer:timerState, gamestring:gameState};
jsonUpdate = JSON.stringify(updateArray);
io.emit('update', jsonUpdate);
});
}).listen(3000);
console.error("Script fully initiated...");