ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/maps/perl/schmorplog.ext
Revision: 1.20
Committed: Fri Dec 15 19:11:47 2006 UTC (17 years, 7 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +0 -0 lines
State: FILE REMOVED
Log Message:
move .ext to server

File Contents

# Content
1 #! perl
2
3 our $UPDATE_LOGINS = Event->idle (repeat => 0, min => 1, data => cf::WF_AUTOCANCEL, cb => sub {
4 my ($status, @pl) = ext::commands::who_listing;
5
6 open my $fh, ">", cf::localdir . "/usercount";
7 print $fh scalar @pl;
8
9 open my $fh, ">", cf::localdir . "/userlisting.html";
10 for ($status, @pl) {
11 s/[<&]//g;
12 print $fh "$_<br />\n";
13 }
14 });
15
16 cf::attach_to_players
17 on_login => sub {
18 my ($pl) = @_;
19 $pl->ob->set_ob_key_value (schmorplog_last_login => time);
20
21 $pl->ob->set_ob_key_value (schmorplog_login_count =>
22 1 + $pl->ob->get_ob_key_value ("schmorplog_login_count"));
23
24 (my $client = $pl->socket->client) =~ s/\n/\\n/g;
25
26 $pl->ob->set_ob_key_value (schmorplog_client => $client);
27
28 ext::schmorp_irc::do_notice (sprintf "%s logged in", $pl->ob->name);
29
30 $UPDATE_LOGINS->start;
31 },
32 on_logout => sub {
33 my ($pl) = @_;
34 $pl->ob->set_ob_key_value (schmorplog_last_logout => time);
35 ext::schmorp_irc::do_notice (sprintf "%s left", $pl->ob->name);
36
37 $UPDATE_LOGINS->start;
38 },
39 on_birth => sub {
40 my ($pl) = @_;
41 ext::schmorp_irc::do_notice (sprintf "%s was just born", $pl->ob->name);
42 $pl->ob->set_ob_key_value (schmorplog_birthdate => time);
43 },
44 on_quit => sub {
45 my ($pl) = @_;
46 ext::schmorp_irc::do_notice (sprintf "%s quit the game", $pl->ob->name);
47 },
48 on_death => sub {
49 my ($pl) = @_;
50 ext::schmorp_irc::do_notice (sprintf "%s was killed by %s", $pl->ob->name, $pl->killer);
51
52 $pl->ob->set_ob_key_value (schmorplog_death_count =>
53 1 + $pl->ob->get_ob_key_value ("schmorplog_death_count"));
54 },
55 on_load => sub {
56 my ($pl, $path) = @_;
57 $pl->ob->set_ob_key_value (schmorplog_last_load => time);
58 },
59 on_save => sub {
60 my ($pl, $path) = @_;
61 $pl->ob->set_ob_key_value (schmorplog_last_save => time);
62 },
63 ;
64