1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-03 16:44:12 +02:00

bit more robust

This commit is contained in:
Robin Appelman 2015-02-01 19:02:10 +01:00
commit 1cb6d881b6

View file

@ -117,14 +117,16 @@ Parser.prototype.parseBody = function () {
break;
case 'player_spawn':
userId = packet.event.values.userid;
if (!this.state.users[userId].team) { //only register first spawn
this.state.users[userId].team = packet.event.values.team === 2 ? 'red' : 'blue'
if (this.state.users[userId]) {
if (!this.state.users[userId].team) { //only register first spawn
this.state.users[userId].team = packet.event.values.team === 2 ? 'red' : 'blue'
}
var classId = packet.event.values.class;
if (!this.state.users[userId].classes[classId]) {
this.state.users[userId].classes[classId] = 0;
}
this.state.users[userId].classes[classId]++;
}
var classId = packet.event.values.class;
if (!this.state.users[userId].classes[classId]) {
this.state.users[userId].classes[classId] = 0;
}
this.state.users[userId].classes[classId]++;
break;
}
break;