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.63 by root, Sun Oct 7 15:52:05 2007 UTC vs.
Revision 1.64 by root, Thu Oct 25 09:01:23 2007 UTC

47cf::register_command who => sub { 47cf::register_command who => sub {
48 my ($ob, $arg) = @_; 48 my ($ob, $arg) = @_;
49 49
50 $ob->speed_left ($ob->speed_left - 4); 50 $ob->speed_left ($ob->speed_left - 4);
51 51
52 my $CHANNEL = {
53 id => "who",
54 title => "Players",
55 reply => undef,
56 tooltip => "Shows players who are currently online",
57 };
58
59 $ob->send_msg ($CHANNEL => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF); 52 $ob->send_msg ("c/who" => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF);
60}; 53};
61 54
62cf::register_command seen => sub { 55cf::register_command seen => sub {
63 my ($pl, $args) = @_; 56 my ($pl, $args) = @_;
64 57
103 $reply .= "You are not allowed to wear armor\n\n" 96 $reply .= "You are not allowed to wear armor\n\n"
104 unless $ob->flag (cf::FLAG_USE_ARMOUR); 97 unless $ob->flag (cf::FLAG_USE_ARMOUR);
105 $reply .= "You are not allowed to use weapons\n\n" 98 $reply .= "You are not allowed to use weapons\n\n"
106 unless $ob->flag (cf::FLAG_USE_WEAPON); 99 unless $ob->flag (cf::FLAG_USE_WEAPON);
107 100
108 my $CHANNEL = {
109 id => "body",
110 title => "Body Parts",
111 reply => undef,
112 tooltip => "Shows which body parts you posess and are available",
113 };
114
115 $ob->send_msg ($CHANNEL => $reply, cf::NDI_REPLY); 101 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY);
116}; 102};
117 103
118cf::register_command mark => sub { 104cf::register_command mark => sub {
119 my ($pl, $arg) = @_; 105 my ($pl, $arg) = @_;
120 106
152 138
153 $ob->contr->$oncmd (0); 139 $ob->contr->$oncmd (0);
154 }; 140 };
155} 141}
156 142
157our $MAPINFO_CHANNEL = {
158 id => "mapinfo",
159 title => "Map Info",
160 reply => undef,
161 tooltip => "Information about the map",
162};
163
164cf::register_command mapinfo => sub { 143cf::register_command mapinfo => sub {
165 my ($ob) = @_; 144 my ($ob) = @_;
166 145
167 my $observe = $ob->contr->observe; 146 my $observe = $ob->contr->observe;
168 147
172 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname; 151 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname;
173 $msg .= sprintf "\n\nplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", 152 $msg .= sprintf "\n\nplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d",
174 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout 153 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout
175 if $ob->flag (cf::FLAG_WIZ); 154 if $ob->flag (cf::FLAG_WIZ);
176 155
177 $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 156 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
178}; 157};
179 158
180cf::register_command whereami => sub { 159cf::register_command whereami => sub {
181 my ($ob) = @_; 160 my ($ob) = @_;
182 161
183 my $reg = $ob->contr->observe->region; 162 my $reg = $ob->contr->observe->region;
184 $ob->send_msg ($MAPINFO_CHANNEL => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); 163 $ob->send_msg ("c/mapinfo" => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR);
185}; 164};
186 165
187cf::register_command whereabouts => sub { 166cf::register_command whereabouts => sub {
188 my ($ob, $arg) = @_; 167 my ($ob, $arg) = @_;
189 168
194 } 173 }
195 174
196 my $msg = "In the world currently there are:\n\n" 175 my $msg = "In the world currently there are:\n\n"
197 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; 176 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count;
198 177
199 $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 178 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
200}; 179};
201 180
202cf::register_command hiscore => sub { 181cf::register_command hiscore => sub {
203 my ($ob, $arg) = @_; 182 my ($ob, $arg) = @_;
204 183
391cf::register_command uptime => sub { 370cf::register_command uptime => sub {
392 my ($ob, $arg) = @_; 371 my ($ob, $arg) = @_;
393 372
394 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; 373 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME;
395 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; 374 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
396 $ob->send_msg (log => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY); 375 $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY);
397}; 376};
398 377
399my %IN_MEMORY = ( 378my %IN_MEMORY = (
400 cf::MAP_IN_MEMORY => "I", 379 cf::MAP_IN_MEMORY => "I",
401 cf::MAP_SWAPPED => "S", 380 cf::MAP_SWAPPED => "S",
407 386
408 no re 'eval'; $arg = qr<$arg>; 387 no re 'eval'; $arg = qr<$arg>;
409 388
410 my $format = "%2s %1s %3s %5s %.60s\n"; 389 my $format = "%2s %1s %3s %5s %.60s\n";
411 390
412 $ob->send_msg ($MAPINFO_CHANNEL => (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_REPLY | cf::NDI_CLEAR); 391 $ob->send_msg ("c/mapinfo" => (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_REPLY | cf::NDI_CLEAR);
413 392
414 for (sort keys %cf::MAP) { 393 for (sort keys %cf::MAP) {
415 my $map = $cf::MAP{$_} 394 my $map = $cf::MAP{$_}
416 or next; 395 or next;
417 396
419 next if $map->{deny_list}; 398 next if $map->{deny_list};
420 399
421 my $svd = int $cf::RUNTIME - $map->{last_save}; 400 my $svd = int $cf::RUNTIME - $map->{last_save};
422 $svd = "++" if $svd > 99; 401 $svd = "++" if $svd > 99;
423 402
424 $ob->send_msg ($MAPINFO_CHANNEL => 403 $ob->send_msg ("c/mapinfo" =>
425 (sprintf $format, 404 (sprintf $format,
426 (scalar $map->players), 405 (scalar $map->players),
427 $IN_MEMORY{$map->in_memory} || "?", 406 $IN_MEMORY{$map->in_memory} || "?",
428 $svd, 407 $svd,
429 (int $map->reset_at - $cf::RUNTIME), 408 (int $map->reset_at - $cf::RUNTIME),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines