-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathconvars.js
33 lines (33 loc) · 962 Bytes
/
convars.js
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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConVars = void 0;
const events_1 = require("events");
/**
* Manages console variables.
*/
class ConVars extends events_1.EventEmitter {
constructor() {
super(...arguments);
this.vars = new Map();
}
listen(demo) {
demo.on("net_SetConVar", (msg) => {
const convars = msg.convars;
if (!convars)
return;
for (const cvar of convars.cvars) {
const oldValue = this.vars.get(cvar.name);
this.vars.set(cvar.name, cvar.value);
const args = {
name: cvar.name,
value: cvar.value,
oldValue
};
this.emit(cvar.name, args);
this.emit("change", args);
}
});
}
}
exports.ConVars = ConVars;
//# sourceMappingURL=convars.js.map