Código Javascript:
Ver original
client.query("SELECT id FROM world_areas", function(errors, rows) { for(var i = 0;i < rows.length; i++) { var map = rows[i].id; client.query('SELECT * FROM objects WHERE regeneration = "1"', function(errors, rows) { for(var e = 0;e < rows.length; e++) { var max_objects = rows[e].max_objects; var name = rows[e].name; var ammount = rows[e].ammount; var type = rows[e].id; client.query('SELECT id FROM world_objects WHERE type = "' + type + '" AND map = "' + map + '"', function(errors, rows) { var dif = parseInt(max_objects)-rows.length; var a = 0; do { var x = 1100 + Math.floor(Math.random() * 3600); var y = 1100 + Math.floor(Math.random() * 3600); client.query('INSERT INTO world_objects (name, type, map, x, y) VALUES ("' + name + '", "' + type + '", "' + map + '", "' + x + '", "' + y + '")'); a++; console.log('OBJETO[' + a + '] => ' + type ); }while(a < dif); }); } }); console.log(' [' + date + '] -> GENERADOS OBJETOS EN EL MAPA ' + rows[0].id); } });
¿Alguna idea?