ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/ipo.ext
(Generate patch)

Comparing deliantra/server/ext/ipo.ext (file contents):
Revision 1.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.4 by root, Sun Jan 7 02:39:14 2007 UTC

52sub notify_players { 52sub notify_players {
53 my (%sent_targets) = @_; 53 my (%sent_targets) = @_;
54 54
55 # lets message player ingame: this is a NEW feature from the perl IPO :-) 55 # lets message player ingame: this is a NEW feature from the perl IPO :-)
56 for (keys %sent_targets) { 56 for (keys %sent_targets) {
57 if (my $player = cf::player::find $_) { 57 if (my $player = cf::player::find_active $_) {
58 my $cnt = $sent_targets{$_}; 58 my $cnt = $sent_targets{$_};
59 59
60 if ($cnt == 1) { 60 if ($cnt == 1) {
61 $player->ob->message ("You've got new mail."); 61 $player->ob->message ("You've got new mail.");
62 } else { 62 } else {
72 my $r = $cb->($o, @a); 72 my $r = $cb->($o, @a);
73 $map->insert_object ($o, $x, $y); 73 $map->insert_object ($o, $x, $y);
74 $r 74 $r
75} 75}
76 76
77# this handler handles to notice the player that he has got mail 77# this handler notifies the player of new mail
78cf::attach_to_players 78cf::player->attach (
79 on_login => sub { 79 on_login => sub {
80 my ($pl) = @_; 80 my ($pl) = @_;
81 81
82 my $mails = CFMail::get_mail ($pl->ob->name); 82 my $mails = CFMail::get_mail ($pl->ob->name);
83 83
89 $pl->ob->message ("You got $cnt mails."); 89 $pl->ob->message ("You got $cnt mails.");
90 } else { 90 } else {
91 $pl->ob->message ("You haven't got any mail."); 91 $pl->ob->message ("You haven't got any mail.");
92 } 92 }
93 }, 93 },
94; 94);
95 95
96# this event handler handles receiving of mails 96# this event handler handles receiving of mails
97cf::register_attachment ipo_mailbox => 97cf::object::attachment ipo_mailbox =>
98 on_apply => sub { 98 on_apply => sub {
99 my ($box, $pl) = @_; 99 my ($box, $pl) = @_;
100 100
101 my $cnt; 101 my $cnt;
102 my $mails = CFMail::get_mail ($pl->name) || []; 102 my $mails = CFMail::get_mail ($pl->name) || [];
167cf::register_script_function "ipo::command" => sub { 167cf::register_script_function "ipo::command" => sub {
168 my ($who, $msg, $npc) = @_; 168 my ($who, $msg, $npc) = @_;
169 my ($cmd, $arguments) = split /\s+/, $msg, 2; 169 my ($cmd, $arguments) = split /\s+/, $msg, 2;
170 $cmd = lc $cmd; 170 $cmd = lc $cmd;
171 171
172 my $pl = cf::player::find $who->name; 172 my $pl = cf::player::find_active $who->name;
173 my ($x, $y) = ($pl->ob->x, $pl->ob->y); 173 my ($x, $y) = ($pl->ob->x, $pl->ob->y);
174 174
175 if (my $pr = $prices{$cmd}) { 175 if (my $pr = $prices{$cmd}) {
176 if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) { 176 if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) {
177 return 1; 177 return 1;
258package CFMail; 258package CFMail;
259 259
260use POSIX qw/strftime/; 260use POSIX qw/strftime/;
261use CFDB; 261use CFDB;
262 262
263my $MAILDB = CFDB->new (db_file => cf::localdir . "/crossfiremail.perl"); 263my $MAILDB = CFDB->new (db_file => cf::localdir . "/crossfiremail");
264 264
265sub get_mail { 265sub get_mail {
266 my ($toname) = @_; 266 my ($toname) = @_;
267 $MAILDB->get ($toname); 267 $MAILDB->get ($toname);
268} 268}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines