From: Michael Andreen Date: Mon, 3 Mar 2008 22:46:41 +0000 (+0100) Subject: Some help messages for intel commands X-Git-Url: https://ruin.nu/git/%3CTMPL_VAR%20NAME=PAGE%3E?a=commitdiff_plain;h=490d9c4cc048f00111f8979b20a34c5adaf22006;p=NDIRC.git Some help messages for intel commands --- diff --git a/Intel.pm b/Intel.pm index 63c2ebd..bc9a925 100644 --- 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");