]> ruin.nu Git - NDIRC.git/commitdiff
Some help messages for intel commands
authorMichael Andreen <harv@ruin.nu>
Mon, 3 Mar 2008 22:46:41 +0000 (23:46 +0100)
committerMichael Andreen <harv@ruin.nu>
Mon, 3 Mar 2008 22:46:41 +0000 (23:46 +0100)
Intel.pm

index 63c2ebdafab28c32815133d0f460ee808b42079e..bc9a92559285d2544287808422be6b607dc8487e 100644 (file)
--- a/Intel.pm
+++ b/Intel.pm
@@ -67,7 +67,7 @@ sub setNick {
                my $findid = $ND::DBH->prepare_cached(q{SELECT nick, id FROM planets
                        WHERE id = planetid(?,?,?,tick())});
                my ($oldnick,$id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
-               if ($ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2'
+               if ($id && $ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2'
                                ,undef,$nick,$id)){
                        unless (defined $oldnick){
                                $ND::server->command("msg $ND::target $x:$y:$z nick has been set to $ND::B$nick");
@@ -75,6 +75,8 @@ sub setNick {
                                $ND::server->command("msg $ND::target $x:$y:$z nick has been changed from $ND::B$oldnick$ND::B to $ND::B$nick");
                        }
                        intel_log $user->{uid},$id,"Set nick to: $nick";
+               }else{
+                       $ND::server->command("msg $ND::target Couldn't find any planet with coords $x:$y:$z");
                }
        }
 }
@@ -97,10 +99,14 @@ sub setAlly {
                        ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally);
                }
                if ($ally){
-                       my $findid = $ND::DBH->prepare_cached(q{SELECT id,alliance FROM current_planet_stats 
+                       my $findid = $ND::DBH->prepare(q{SELECT id,alliance FROM current_planet_stats 
                                WHERE x = ? AND y = ? and z = ?});
                        my ($id,$alliance) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
-                       if($id && $ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2'
+                       unless ($id){
+                               $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
+                               return;
+                       }
+                       if($ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2'
                                ,undef,$aid,$id)){
                                if (defined $alliance){
                                        $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$alliance$ND::B to $ND::B$ally");
@@ -109,7 +115,7 @@ sub setAlly {
                                }
                                intel_log $user->{uid},$id,"Set alliance_id to: $aid ($ally)";
                        }else{
-                               $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
+                               $ND::server->command("msg $ND::target Couldn't set alliance_id to: $aid");
                        }
                }else{
                        $ND::server->command("msg $ND::target Couldn't find such an alliance");