- my ($x,$y,$z,$channel) = @_;
- DB();
- if (officer()){
- if ($ND::DBH->do("UPDATE planets SET channel = ? WHERE id = planetid(?,?,?,0)"
- ,undef,$channel,$x,$y,$z)){
- $ND::server->command("msg $ND::target $x:$y:$z relay channel has been set to: $channel");
+ my ($msg, $command) = @_;
+ my ($x,$y,$z,$channel);
+ if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
+ $x = $1;
+ $y = $2;
+ $z = $3;
+ $channel = $4;
+ }else{
+ $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z channel");
+ return;
+ }
+ if (my $user = officer()){
+ my $findid = $ND::DBH->prepare_cached(q{SELECT id,channel FROM current_planet_stats
+ WHERE x = ? AND y = ? and z = ?});
+ my ($id,$c) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
+ if ($ND::DBH->do('UPDATE planets SET channel = $1 WHERE id = $2'
+ ,undef,$channel,$id)){
+
+ if (defined $c){
+ $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$c$ND::B to $ND::B$channel");
+ }else{
+ $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$channel");
+ }
+ intel_log $user->{uid},$id,"Set channel to: $channel";
+ }else{
+ $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");