… | |
… | |
47 | cf::register_command who => sub { |
47 | cf::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 | $ob->contr->ns->send_msg (log => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE); |
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); |
53 | }; |
60 | }; |
54 | |
61 | |
55 | cf::register_command seen => sub { |
62 | cf::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 | |
78 | cf::register_command body => sub { |
85 | cf::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 | |
104 | cf::register_command mark => sub { |
118 | cf::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 | |
|
|
157 | our $MAPINFO_CHANNEL = { |
|
|
158 | id => "mapinfo", |
|
|
159 | title => "Map Info", |
|
|
160 | reply => undef, |
|
|
161 | tooltip => "Information about the map", |
|
|
162 | }; |
|
|
163 | |
143 | cf::register_command mapinfo => sub { |
164 | cf::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 | |
148 | my $map = $observe->map |
169 | my $map = $observe->map |
149 | or return; |
170 | or return; |
|
|
171 | |
150 | $ob->reply (undef, (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; |
151 | $ob->reply (undef, (sprintf "players: %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", |
152 | (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 |
153 | if $ob->flag (cf::FLAG_WIZ); |
175 | if $ob->flag (cf::FLAG_WIZ); |
154 | $ob->reply (undef, $map->msg); |
176 | |
|
|
177 | $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); |
155 | }; |
178 | }; |
156 | |
179 | |
157 | cf::register_command whereami => sub { |
180 | cf::register_command whereami => sub { |
158 | my ($ob) = @_; |
181 | my ($ob) = @_; |
159 | |
182 | |
160 | my $reg = $ob->contr->observe->region; |
183 | my $reg = $ob->contr->observe->region; |
161 | $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); |
162 | }; |
185 | }; |
163 | |
186 | |
164 | cf::register_command whereabouts => sub { |
187 | cf::register_command whereabouts => sub { |
165 | my ($ob, $arg) = @_; |
188 | my ($ob, $arg) = @_; |
166 | |
189 | |
… | |
… | |
169 | for my $pl (cf::player::list) { |
192 | for my $pl (cf::player::list) { |
170 | ++$count{$pl->ob->region->longname}; |
193 | ++$count{$pl->ob->region->longname}; |
171 | } |
194 | } |
172 | |
195 | |
173 | my $msg = "In the world currently there are:\n\n" |
196 | my $msg = "In the world currently there are:\n\n" |
174 | . join "", map "$count{$_} player(s) in $_\n\n", sort keys %count; |
197 | . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; |
175 | |
198 | |
176 | $ob->contr->ns->send_msg (log => $msg, cf::NDI_REPLY); |
199 | $ob->send_msg ($MAPINFO_CHANNEL => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); |
177 | }; |
200 | }; |
178 | |
201 | |
179 | cf::register_command hiscore => sub { |
202 | cf::register_command hiscore => sub { |
180 | my ($ob, $arg) = @_; |
203 | my ($ob, $arg) = @_; |
181 | |
204 | |
182 | my $url = $cf::CFG->{hiscore_url}; |
205 | my $url = $cf::CFG{hiscore_url}; |
183 | $ob->contr->ns->send_msg (log => "See $url", cf::NDI_REPLY); |
206 | $ob->send_msg (log => "See $url", cf::NDI_REPLY); |
184 | }; |
207 | }; |
185 | |
208 | |
186 | sub _set_mode($$$@) { |
209 | sub _set_mode($$$@) { |
187 | my ($name, $ob, $arg, $slot, @choices) = @_; |
210 | my ($name, $ob, $arg, $slot, @choices) = @_; |
188 | |
211 | |
… | |
… | |
368 | cf::register_command uptime => sub { |
391 | cf::register_command uptime => sub { |
369 | my ($ob, $arg) = @_; |
392 | my ($ob, $arg) = @_; |
370 | |
393 | |
371 | 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; |
372 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
395 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
373 | $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); |
396 | $ob->send_msg (log => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY); |
374 | }; |
397 | }; |
375 | |
398 | |
376 | my %IN_MEMORY = ( |
399 | my %IN_MEMORY = ( |
377 | cf::MAP_IN_MEMORY => "I", |
400 | cf::MAP_IN_MEMORY => "I", |
378 | cf::MAP_SWAPPED => "S", |
401 | cf::MAP_SWAPPED => "S", |
… | |
… | |
384 | |
407 | |
385 | no re 'eval'; $arg = qr<$arg>; |
408 | no re 'eval'; $arg = qr<$arg>; |
386 | |
409 | |
387 | my $format = "%2s %1s %3s %5s %.60s\n"; |
410 | my $format = "%2s %1s %3s %5s %.60s\n"; |
388 | |
411 | |
389 | $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); |
390 | |
413 | |
391 | for (sort keys %cf::MAP) { |
414 | for (sort keys %cf::MAP) { |
392 | my $map = $cf::MAP{$_} |
415 | my $map = $cf::MAP{$_} |
393 | or next; |
416 | or next; |
394 | |
417 | |
… | |
… | |
396 | next if $map->{deny_list}; |
419 | next if $map->{deny_list}; |
397 | |
420 | |
398 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
421 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
399 | $svd = "++" if $svd > 99; |
422 | $svd = "++" if $svd > 99; |
400 | |
423 | |
401 | $ob->reply (undef, |
424 | $ob->send_msg ($MAPINFO_CHANNEL => |
402 | (sprintf $format, |
425 | (sprintf $format, |
403 | (scalar $map->players), |
426 | (scalar $map->players), |
404 | $IN_MEMORY{$map->in_memory} || "?", |
427 | $IN_MEMORY{$map->in_memory} || "?", |
405 | $svd, |
428 | $svd, |
406 | (int $map->reset_at - $cf::RUNTIME), |
429 | (int $map->reset_at - $cf::RUNTIME), |
407 | $map->visible_name), |
430 | $map->visible_name) |
408 | cf::NDI_BLACK | cf::NDI_UNIQUE); |
431 | ); |
409 | } |
432 | } |
410 | }; |
433 | }; |
411 | |
434 | |