ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/commands.ext
(Generate patch)

Comparing deliantra/server/ext/commands.ext (file contents):
Revision 1.68 by root, Mon Sep 8 18:34:35 2008 UTC vs.
Revision 1.71 by root, Tue Sep 23 00:24:52 2008 UTC

53}; 53};
54 54
55cf::register_command seen => sub { 55cf::register_command seen => sub {
56 my ($pl, $args) = @_; 56 my ($pl, $args) = @_;
57 57
58 cf::async {
58 if (my ($login) = $args =~ /(\S+)/) { 59 if (my ($login) = $args =~ /(\S+)/) {
59 if ($login eq $pl->name) { 60 if ($login eq $pl->name) {
60 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); 61 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY);
61 } elsif (cf::player::find_active $login) { 62 } elsif (cf::player::find_active $login) {
62 $pl->message ("$login is right here on this server!", cf::NDI_REPLY); 63 $pl->message ("$login is right here on this server!", cf::NDI_REPLY);
63 } elsif (cf::player::exists $login 64 } elsif (cf::player::exists $login
64 and stat cf::player::path $login) { 65 and stat cf::player::path $login) {
65 my $time = (stat _)[9]; 66 my $time = (stat _)[9];
66 67
67 $pl->message ("$login was last seen here " 68 $pl->message ("$login was last seen here "
68 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 69 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
69 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); 70 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY);
71 } else {
72 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY);
73 }
70 } else { 74 } else {
71 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); 75 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
72 } 76 }
73 } else {
74 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
75 } 77 };
76}; 78};
77 79
78cf::register_command body => sub { 80cf::register_command body => sub {
79 my ($ob) = @_; 81 my ($ob) = @_;
80 82
81 # Too hard to try and make a header that lines everything up, so just 83 # Too hard to try and make a header that lines everything up, so just
82 # give a description. (comment from C++) 84 # give a description. (comment from C++)
83 my $reply = 85 my $reply =
84 "The first column is the name of the body location.\r" 86 "The first column is the name of the body location.\r"
85 . "The second column is how many of those locations your body has.\r" 87 . "The second column is how many of those locations your body has.\r"
86 . "The third column is how many slots in that location are available.\r"; 88 . "The third column is how many slots in that location are available.\n\n";
87 89
88 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; 90 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail";
89 for (0 .. cf::NUM_BODY_LOCATIONS - 1) { 91 for (0 .. cf::NUM_BODY_LOCATIONS - 1) {
90 my $msg = cf::object::slot_nonuse_name $_; 92 my $msg = cf::object::slot_nonuse_name $_;
91 $msg =~ s/^.*? a //; 93 $msg =~ s/^.*? a //;
146 my $observe = $ob->contr->observe; 148 my $observe = $ob->contr->observe;
147 149
148 my $map = $observe->map 150 my $map = $observe->map
149 or return; 151 or return;
150 152
151 my $msg = sprintf "%s (%s) %s\r", $map->name, $map->path, $observe->region->longname; 153 my $msg = sprintf "%s (%s)\r%s", $map->name, $map->path, $observe->region->longname;
152 $msg .= sprintf "players: %d difficulty: %d size: %d start: %dx%d timeout: %d", 154 $msg .= sprintf "\rplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d",
153 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout 155 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout
154 if $ob->flag (cf::FLAG_WIZ); 156 if $ob->flag (cf::FLAG_WIZ);
155 157
156 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 158 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
157}; 159};
158 160
159cf::register_command whereami => sub { 161cf::register_command whereami => sub {
160 my ($ob) = @_; 162 my ($ob) = @_;
161 163
162 my $reg = $ob->contr->observe->region; 164 my $reg = $ob->contr->observe->region;
163 $ob->send_msg ("c/who" => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); 165 $ob->send_msg ("c/who" => (sprintf "You are %s.\n\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR);
164}; 166};
165 167
166cf::register_command whereabouts => sub { 168cf::register_command whereabouts => sub {
167 my ($ob, $arg) = @_; 169 my ($ob, $arg) = @_;
168 170
170 172
171 for my $pl (cf::player::list) { 173 for my $pl (cf::player::list) {
172 ++$count{$pl->ob->region->longname}; 174 ++$count{$pl->ob->region->longname};
173 } 175 }
174 176
175 my $msg = "In the world currently there are:\n\n" 177 my $msg = "T<In the world currently there are:>\n\n"
176 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; 178 . join "", map { sprintf " C<%3d >player(s) %s\r", $count{$_}, $_ } sort keys %count;
177 179
178 $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 180 $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
179}; 181};
180 182
181cf::register_command hiscore => sub { 183cf::register_command hiscore => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines