--- deliantra/maps/perl/commands.ext 2006/09/14 19:39:09 1.3 +++ deliantra/maps/perl/commands.ext 2006/11/08 00:54:11 1.11 @@ -33,13 +33,55 @@ $ob->esrv_update_item (cf::UPD_NAME, $item); - return 1; + 1 } -cf::register_command rename => 0, sub { +sub who_listing(;$) { + my ($privileged) = @_; + + my ($numwiz, $numafk) = (0, 0); + my @pl; + + foreach my $pl (cf::player::list) { + my $ob = $pl->ob; + + next unless $ob->map + && ($privileged || !$pl->hidden); + + $numwiz++ if $ob->flag (cf::FLAG_WIZ); + $numafk++ if $ob->flag (cf::FLAG_AFK); + + push @pl, $pl; + } + + ( + "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)", + map { + my ($pl, $ob) = ($_, $_->ob); + + "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) + . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") + . ($ob->flag (cf::FLAG_AFK) ? " [AFK]" : "") + . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") + . " [" . $pl->client . "]" + . " [" . ($pl->peaceful || $privileged ? $ob->map->path : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" + . ($privileged ? " " . $pl->host : "") + } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl + ) +} + +cf::register_command who => $cf::TICK, sub { + my ($ob, $arg) = @_; + + $ob->reply (undef, (join "\n", who_listing $ob->flag (cf::FLAG_WIZ)), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); + + 1 +}; + +cf::register_command rename => $cf::TICK, sub { my ($ob, $arg) = @_; - if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]+)> \s*$/x) { + if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]*)> \s*$/x) { # compatibility syntax rename_to $ob, $1, $2; } elsif ($arg =~ / @@ -54,6 +96,9 @@ # does not unquote $1 or $3 rename_to $ob, $2||$1, $4||$3; } else { - $ob->message ('Syntax error. Rename usage: rename ["oldname"] to "newname"'); + $ob->reply (undef, 'Syntax error. Rename usage: rename ["oldname"] to "newname"'); } + + 1 }; +