Advertisement
cocaineee

checkBadGame (resend offers)

Feb 19th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkBadGame() {
  2. var mysql = require('mysql');
  3. var connection = mysql.createConnection({
  4. host: 'localhost'
  5. , user: 'root'
  6. , password: ''
  7. , database: ''
  8. });
  9.  
  10. connection.connect();
  11.  
  12. getBadGame = 'SELECT won_items, winner_id, items, won_items, g.id as id, steamid64, accessToken FROM `games` as g JOIN users as u ON winner_id = u.id WHERE `status_prize` = 2 AND status = 3 ORDER BY id DESC LIMIT 0,1';
  13. connection.query(getBadGame, function (err, rows, fields) {
  14. if(rows.length == 0){
  15. return;
  16. }
  17. rows.forEach(function (item, i, arr) {
  18. console.log('Игра # ' + item.id + ' пользователю #' + item.winner_id + ' не отправлено ' + item.items + " предметов. Пытаемся отправить.");
  19. sendoffer = [];
  20. offer = JSON.parse(item.won_items);
  21. offer.forEach(function (it, key, array) {
  22. sendoffer.push(it.classid);
  23. });
  24. sendTradeOffer(730, item.steamid64, item.accessToken, sendoffer, '', item.id, '');
  25. });
  26. });
  27. connection.end();
  28. }
  29. setInterval(function () {
  30. checkBadGame();
  31. }, 10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement