… | |
… | |
46 | 1 => ['scroll', 'mailscroll'], |
46 | 1 => ['scroll', 'mailscroll'], |
47 | 2 => ['note', 'newspaper'], |
47 | 2 => ['note', 'newspaper'], |
48 | 3 => ['diploma', 'mailwarning'], |
48 | 3 => ['diploma', 'mailwarning'], |
49 | ); |
49 | ); |
50 | |
50 | |
|
|
51 | sub notify_players { |
|
|
52 | my (%sent_targets) = @_; |
|
|
53 | |
|
|
54 | # lets message player ingame: this is a NEW feature from the perl IPO :-) |
|
|
55 | for (keys %sent_targets) { |
|
|
56 | if (my $player = cf::player::find $_) { |
|
|
57 | my $cnt = $sent_targets{$_}; |
|
|
58 | |
|
|
59 | if ($cnt == 1) { |
|
|
60 | $player->ob->message ("You've got new mail."); |
|
|
61 | } else { |
|
|
62 | $player->ob->message ("You've got $cnt new mails."); |
|
|
63 | } |
|
|
64 | } |
|
|
65 | } |
|
|
66 | } |
|
|
67 | |
51 | sub create_object { |
68 | sub create_object { |
52 | my ($name, $map, $x, $y, $cb, @a) = @_; |
69 | my ($name, $map, $x, $y, $cb, @a) = @_; |
53 | my $o = cf::object::new $name; |
70 | my $o = cf::object::new $name; |
54 | my $r = $cb->($o, @a); |
71 | my $r = $cb->($o, @a); |
55 | $map->insert_object ($o, $x, $y); |
72 | $map->insert_object ($o, $x, $y); |
… | |
… | |
141 | } |
158 | } |
142 | } |
159 | } |
143 | |
160 | |
144 | $_->remove for @mails; |
161 | $_->remove for @mails; |
145 | |
162 | |
146 | # lets message player ingame: this is a NEW feature from the perl IPO :-) |
163 | notify_players (%sent_targets); |
147 | for (keys %sent_targets) { |
|
|
148 | if (my $player = cf::player::find $_) { |
|
|
149 | my $cnt = $sent_targets{$_}; |
|
|
150 | |
|
|
151 | if ($cnt == 1) { |
|
|
152 | $player->ob->message ("You've got new mail."); |
|
|
153 | } else { |
|
|
154 | $player->ob->message ("You've got $cnt new mails."); |
|
|
155 | } |
|
|
156 | } |
|
|
157 | } |
|
|
158 | |
164 | |
159 | 0; |
165 | 0; |
160 | } |
166 | } |
161 | |
167 | |
162 | # this is the main command interface for the IPO NPC |
168 | # this is the main command interface for the IPO NPC |
… | |
… | |
224 | } |
230 | } |
225 | } |
231 | } |
226 | |
232 | |
227 | if ($cnt) { |
233 | if ($cnt) { |
228 | $who->reply ($npc, $cnt == 1 ? "Package sent to $arguments." : "Sent $cnt packages to $arguments\n"); |
234 | $who->reply ($npc, $cnt == 1 ? "Package sent to $arguments." : "Sent $cnt packages to $arguments\n"); |
|
|
235 | CFMail::send_mail (1, $arguments, $who->name, "You got $cnt packages from " . $who->name); |
|
|
236 | notify_players ($arguments => 1); |
229 | } else { |
237 | } else { |
230 | $who->reply ($npc, "Sorry, found no package to send to $arguments."); |
238 | $who->reply ($npc, "Sorry, found no package to send to $arguments."); |
231 | } |
239 | } |
232 | |
240 | |
233 | } else { |
241 | } else { |
… | |
… | |
238 | ."- literacy (%s platinum)\n" |
246 | ."- literacy (%s platinum)\n" |
239 | ."- mailscroll <friend> (%s platinum)\n" |
247 | ."- mailscroll <friend> (%s platinum)\n" |
240 | ."- bag <friend> (%s platinum)\n" |
248 | ."- bag <friend> (%s platinum)\n" |
241 | ."- package <friend> (%s platinum)\n" |
249 | ."- package <friend> (%s platinum)\n" |
242 | ."- carton <friend> (%s platinum)\n" |
250 | ."- carton <friend> (%s platinum)\n" |
|
|
251 | ."- send <friend> (send bags/packages/cartons)\n" |
|
|
252 | ."- receive (to receive packages for you)\n" |
243 | .($who->flag (cf::FLAG_WIZ) ? "- mailwarning <player>" : ""), |
253 | .($who->flag (cf::FLAG_WIZ) ? "- mailwarning <player>" : ""), |
244 | 40, 1000, 1, 1, 5, 10 |
254 | 40, 1000, 1, 1, 5, 10 |
245 | ); |
255 | ); |
246 | } |
256 | } |
247 | 1 |
257 | 1 |