Błąd:
/var/www/html/bot/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'rjEWOpx9c6AW5OhmAAAB' of undefined
at /var/www/html/bot/driver.js:886:36
at Array.forEach (<anonymous>)
at Query.<anonymous> (/var/www/html/bot/driver.js:885:38)
at Query.<anonymous> (/var/www/html/bot/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/var/www/html/bot/node_modules/mysql/lib/Connection.js:488:16)
at Query.Sequence.end (/var/www/html/bot/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query._handleFinalResultPacket (/var/www/html/bot/node_modules/mysql/lib/protocol/sequences/Query.js:149:8)
at Query.OkPacket (/var/www/html/bot/node_modules/mysql/lib/protocol/sequences/Query.js:74:10)
at Protocol._parsePacket (/var/www/html/bot/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/var/www/html/bot/node_modules/mysql/lib/protocol/Parser.js:433:10)
Funkcja kodu z błędem:
socket.on('roulette play', function(play, color) {
if(!user) return socket.emit('notify','error','notLoggedIn');
if((!play) || (!color)) return socket.emit('notify','error','roulettePlayFailed');
if((typeof play != 'string') && (typeof play != 'number')) return socket.emit('notify','error','roulettePlayFailed');
if(typeof color != 'string') return socket.emit('notify','error','roulettePlayFailed');
if((usersBr[user.steamid] !== undefined) && (usersBr[user.steamid] == 3)) {
socket.emit('notify','error','rouletteMaxBets',[3]);
return;
}
play = parseInt(play);
if(isNaN(play)) return socket.emit('notify','error','cannotParseValue');
play = ''+play;
play = play.replace(/\D/g,'');
if(color !== 'green' && color !== 'red' && color !== 'black') return socket.emit('notify','error','rouletteUnknownColor');
if(play < 1) return socket.emit('notify','error','rouletteMinBet', [play,1]);
if(play > 1000000) return socket.emit('notify','error','rouletteMaxBet', [play,1000000]);
if(!pause) {
connection.query('SELECT `wallet`,`deposit_sum` FROM `users` WHERE `steamid` = '+connection.escape(user.steamid)+' LIMIT 1', function(err, row) {
if((err) || (!row.length)) {
console.log(err);
socket.emit('notify','error','roulettePlayFailed');
return;
}
if(row[0].wallet >= play) {
connection.query('UPDATE `users` SET `wallet` = `wallet` - '+parseInt(play)+', `total_bet` = `total_bet` + '+parseInt(play)+' WHERE `steamid` = '+connection.escape(user.steamid), function(err2, row2) {
if(row[0].deposit_sum >= 2500){
connection.query('UPDATE `users` SET `wager` = `wager` + '+parseInt(play)+' WHERE `steamid` = '+connection.escape(user.steamid));
}
if(err2) {
console.log(err2);
socket.emit('notify','error','roulettePlayFailed');
return;
}
connection.query('INSERT INTO `wallet_change` SET `user` = '+connection.escape(user.steamid)+', `change` = -'+connection.escape(play)+', `reason` = \'Roulette #'+currentRollid+' '+color+'\'', function(err3, row3) {
if(err3) {
console.log('important error at wallet_change');
console.log(err3);
socket.emit('notify','error','serverError');
return;
}
if(usersBr[user.steamid] === undefined) {
usersBr[user.steamid] = 1;
} else {
usersBr[user.steamid]++;
}
io.sockets.to('roulette').emit('roulette player',{
amount: play,
player: {
avatar: user.avatar,
steamid: user.steamid,
username: user.username
}
}, color);
currentBets[color].push({
amount: play,
player: {
avatar: user.avatar,
steamid: user.steamid,
username: user.username
}
});
if(users[user.steamid])
users[user.steamid].socket.forEach(function(asocket) {
if(io.sockets.connected[asocket]) << linijka 886
io.sockets.connected[asocket].emit('balance change', parseInt('-'+play));
if(io.sockets.connected[asocket])
io.sockets.connected[asocket].emit('notify','success','roulettePlaySuccess',[play,color,usersBr[user.steamid],3]);
});
});
});
} else {
socket.emit('notify','error','notEnoughCoins');
}
});
} else
socket.emit('notify','error','roulettePlayFailed');
});