… | |
… | |
53 | }; |
53 | }; |
54 | |
54 | |
55 | cf::register_command seen => sub { |
55 | cf::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 | |
78 | cf::register_command body => sub { |
80 | cf::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.\n\n"; |
88 | . "The third column is how many slots in that location are available.\r" |
|
|
89 | . "The last column shows the items currently using the slot\n\n"; |
87 | |
90 | |
|
|
91 | # first process all applied items and hash them into their slots |
|
|
92 | my @slot; |
|
|
93 | |
|
|
94 | for my $item (grep $_->flag (cf::FLAG_APPLIED), $ob->inv) { |
|
|
95 | $item->slot_info ($_) |
|
|
96 | and push @{ $slot[$_] }, $item |
|
|
97 | for 0 .. cf::NUM_BODY_LOCATIONS-1; |
|
|
98 | } |
|
|
99 | |
88 | $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; |
100 | $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What"; |
89 | for (0 .. cf::NUM_BODY_LOCATIONS - 1) { |
101 | for (0 .. cf::NUM_BODY_LOCATIONS - 1) { |
90 | my $msg = cf::object::slot_nonuse_name $_; |
102 | my $msg = cf::object::slot_nonuse_name $_; |
91 | $msg =~ s/^.*? a //; |
103 | $msg =~ s/^.*? a //; |
92 | $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) |
104 | $reply .= sprintf " %-20s %3d %5d %s\n", |
|
|
105 | $msg, |
|
|
106 | $ob->slot_info ($_), |
|
|
107 | $ob->slot_used ($_), |
|
|
108 | join ", ", map $_->query_short_name, @{ $slot[$_] } |
93 | if $ob->slot_info ($_) or $ob->slot_used ($_); |
109 | if $ob->slot_info ($_) || $ob->slot_used ($_); |
94 | } |
110 | } |
95 | |
111 | |
96 | $reply .= "You are not allowed to wear armor\r" |
112 | $reply .= "You are not allowed to wear armor\r" |
97 | unless $ob->flag (cf::FLAG_USE_ARMOUR); |
113 | unless $ob->flag (cf::FLAG_USE_ARMOUR); |
98 | $reply .= "You are not allowed to use weapons\r" |
114 | $reply .= "You are not allowed to use weapons\r" |