- my ($coords) = $ND::DBH->selectrow_array(q{
- SELECT coords(p.x,p.y,p.z) FROM current_planet_stats p JOIN planet_stats ps using (id) WHERE
- ps.tick = ? AND (2000*?*?/ps.value)::int = $stolen ;
- }, undef, $tick,$agents,$value,$stolen);
- $ND::server->command("notice $ND::target The planet that cov opped you is: $coords");
+ unless ($value){
+ $ND::server->command("notice $ND::nick No value found for tick $tick, can't find your cov opper.");
+ return;
+ }
+ my $attackers = $ND::DBH->prepare(q{
+ SELECT coords(p.x,p.y,p.z), ruler, planet FROM current_planet_stats p JOIN planet_stats ps using (id) WHERE
+ ps.tick = $1 AND (2000*$2*$3/ps.value)::int = $4 ;
+ });
+ $attackers->execute($tick,$agents,$value,$stolen);
+ if ($attackers->rows == 0){
+ $ND::server->command("notice $ND::nick No cov opper found, did you specify the right tick, and was the stolen amount not capped?");
+ return;
+ }
+ my $coords = '';
+ while (my $attacker = $attackers->fetchrow_hashref){
+ $coords .= " ($attacker->{coords} : $attacker->{ruler} OF $attacker->{planet})";
+ }
+ $ND::server->command("notice $ND::nick The planet that cov opped you is one of: $coords");