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.61 by root, Tue Aug 14 12:17:34 2007 UTC vs.
Revision 1.62 by root, Sat Sep 8 10:14:09 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
52 $ob->send_msg (log => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY); 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);
53}; 60};
54 61
55cf::register_command seen => sub { 62cf::register_command seen => sub {
56 my ($pl, $args) = @_; 63 my ($pl, $args) = @_;
57 64
58 if (my ($login) = $args =~ /(\S+)/) { 65 if (my ($login) = $args =~ /(\S+)/) {
59 if ($login eq $pl->name) { 66 if ($login eq $pl->name) {
60 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); 67 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY);
61 } elsif (cf::player::find_active $login) { 68 } elsif (cf::player::find_active $login) {
62 $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); 69 $pl->message ("$login is right here on this server!", cf::NDI_REPLY);
63 } elsif (cf::player::exists $login 70 } elsif (cf::player::exists $login
64 and stat cf::player::path $login) { 71 and stat cf::player::path $login) {
65 my $time = (stat _)[9]; 72 my $time = (stat _)[9];
66 73
67 $pl->message ("$login was last seen here " 74 $pl->message ("$login was last seen here "
68 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 75 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
69 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); 76 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY);
70 } else { 77 } else {
71 $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); 78 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY);
72 } 79 }
73 } else { 80 } else {
74 $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE); 81 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
75 } 82 }
76}; 83};
77 84
78cf::register_command body => sub { 85cf::register_command body => sub {
79 my ($ob) = @_; 86 my ($ob) = @_;
96 $reply .= "You are not allowed to wear armor\n\n" 103 $reply .= "You are not allowed to wear armor\n\n"
97 unless $ob->flag (cf::FLAG_USE_ARMOUR); 104 unless $ob->flag (cf::FLAG_USE_ARMOUR);
98 $reply .= "You are not allowed to use weapons\n\n" 105 $reply .= "You are not allowed to use weapons\n\n"
99 unless $ob->flag (cf::FLAG_USE_WEAPON); 106 unless $ob->flag (cf::FLAG_USE_WEAPON);
100 107
101 $ob->reply (undef, $reply); 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);
102}; 116};
103 117
104cf::register_command mark => sub { 118cf::register_command mark => sub {
105 my ($pl, $arg) = @_; 119 my ($pl, $arg) = @_;
106 120
138 152
139 $ob->contr->$oncmd (0); 153 $ob->contr->$oncmd (0);
140 }; 154 };
141} 155}
142 156
157our $MAPINFO_CHANNEL = {
158 id => "mapinfo",
159 title => "Map Info",
160 reply => undef,
161 tooltip => "Information about the map",
162};
163
143cf::register_command mapinfo => sub { 164cf::register_command mapinfo => sub {
144 my ($ob) = @_; 165 my ($ob) = @_;
145 166
146 my $observe = $ob->contr->observe; 167 my $observe = $ob->contr->observe;
147 168
150 171
151 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname; 172 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname;
152 $msg .= sprintf "\n\nplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", 173 $msg .= sprintf "\n\nplayers: %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 174 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout
154 if $ob->flag (cf::FLAG_WIZ); 175 if $ob->flag (cf::FLAG_WIZ);
155 $ob->send_msg (log => $msg, cf::NDI_REPLY); 176
177 $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
156}; 178};
157 179
158cf::register_command whereami => sub { 180cf::register_command whereami => sub {
159 my ($ob) = @_; 181 my ($ob) = @_;
160 182
161 my $reg = $ob->contr->observe->region; 183 my $reg = $ob->contr->observe->region;
162 $ob->reply (undef, (sprintf "You are %s.\n%s", $reg->longname, $reg->msg)); 184 $ob->send_msg ($MAPINFO_CHANNEL => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR);
163}; 185};
164 186
165cf::register_command whereabouts => sub { 187cf::register_command whereabouts => sub {
166 my ($ob, $arg) = @_; 188 my ($ob, $arg) = @_;
167 189
172 } 194 }
173 195
174 my $msg = "In the world currently there are:\n\n" 196 my $msg = "In the world currently there are:\n\n"
175 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; 197 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count;
176 198
177 $ob->send_msg (log => $msg, cf::NDI_REPLY); 199 $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
178}; 200};
179 201
180cf::register_command hiscore => sub { 202cf::register_command hiscore => sub {
181 my ($ob, $arg) = @_; 203 my ($ob, $arg) = @_;
182 204
369cf::register_command uptime => sub { 391cf::register_command uptime => sub {
370 my ($ob, $arg) = @_; 392 my ($ob, $arg) = @_;
371 393
372 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; 394 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME;
373 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; 395 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
374 $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); 396 $ob->send_msg (log => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY);
375}; 397};
376 398
377my %IN_MEMORY = ( 399my %IN_MEMORY = (
378 cf::MAP_IN_MEMORY => "I", 400 cf::MAP_IN_MEMORY => "I",
379 cf::MAP_SWAPPED => "S", 401 cf::MAP_SWAPPED => "S",
385 407
386 no re 'eval'; $arg = qr<$arg>; 408 no re 'eval'; $arg = qr<$arg>;
387 409
388 my $format = "%2s %1s %3s %5s %.60s\n"; 410 my $format = "%2s %1s %3s %5s %.60s\n";
389 411
390 $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); 412 $ob->send_msg ($MAPINFO_CHANNEL => (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_REPLY | cf::NDI_CLEAR);
391 413
392 for (sort keys %cf::MAP) { 414 for (sort keys %cf::MAP) {
393 my $map = $cf::MAP{$_} 415 my $map = $cf::MAP{$_}
394 or next; 416 or next;
395 417
397 next if $map->{deny_list}; 419 next if $map->{deny_list};
398 420
399 my $svd = int $cf::RUNTIME - $map->{last_save}; 421 my $svd = int $cf::RUNTIME - $map->{last_save};
400 $svd = "++" if $svd > 99; 422 $svd = "++" if $svd > 99;
401 423
402 $ob->reply (undef, 424 $ob->send_msg ($MAPINFO_CHANNEL =>
403 (sprintf $format, 425 (sprintf $format,
404 (scalar $map->players), 426 (scalar $map->players),
405 $IN_MEMORY{$map->in_memory} || "?", 427 $IN_MEMORY{$map->in_memory} || "?",
406 $svd, 428 $svd,
407 (int $map->reset_at - $cf::RUNTIME), 429 (int $map->reset_at - $cf::RUNTIME),
408 $map->visible_name), 430 $map->visible_name)
409 cf::NDI_BLACK | cf::NDI_UNIQUE); 431 );
410 } 432 }
411}; 433};
412 434

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines