--- deliantra/server/ext/schmorplog.ext 2008/05/03 11:14:50 1.19 +++ deliantra/server/ext/schmorplog.ext 2008/09/21 23:21:49 1.23 @@ -1,4 +1,4 @@ -#! perl # depends=irc +#! perl # depends=irc mandatory # statistics-package @@ -84,12 +84,17 @@ }, on_death => sub { my ($pl) = @_; - ext::irc::do_notice (sprintf "%s was killed by %s", $pl->ob->name, $pl->killer_name); + + my $msg = $pl->expand_cfpod (sprintf "%s was killed by %s.", $pl->ob->name, $pl->killer_name); + ext::irc::do_notice ($msg); ++$pl->ob->{stats_death}{$pl->killer_name}; $pl->ob->kv_set (schmorplog_death_count => 1 + $pl->ob->kv_get ("schmorplog_death_count")); + + $_->send_msg ("" => $msg, cf::NDI_VERBATIM) + for cf::player::list; }, on_load => sub { my ($pl, $path) = @_; @@ -116,10 +121,10 @@ my $s = $pl->ob->{stats_death} or return $who->reply ($npc, "$args didn't die even once."); - my $rep = "$args died a total of " . $pl->ob->kv_set ("schmorplog_death_count") . " times, among them:\n\n\n\n"; + my $rep = "$args died a total of " . $pl->ob->kv_get ("schmorplog_death_count") . " times, among them:\n\n"; for (sort { $s->{$b} <=> $s->{$a} } keys %$s) { - $rep .= "$s->{$_} time(s) due to $_.\n\n"; + $rep .= sprintf " C<%4d> time(s) due to %s.\n", $s->{$_}, $_; } $who->reply ($npc, $rep); @@ -132,9 +137,9 @@ my $s = $pl->ob->{stats_kill} or return $who->reply ($npc, "I don't know of I that $args has killed so far."); - my $rep = sprintf "\n\nC<%6s> %s\n\n", "Kills", "Name"; - for (sort { $s->{$a} <=> $s->{$b} } keys %$s) { - $rep .= sprintf "C<%6s> %s\n\n", $s->{$_}, $_; + my $rep = sprintf "Here is a list of all the kills I know about:\n\n"; + for (sort { $s->{$b} <=> $s->{$a} } keys %$s) { + $rep .= sprintf " C<%6s> %s\n", $s->{$_}, $_; } $who->reply ($npc, $rep); @@ -142,8 +147,8 @@ } elsif ($cmd eq "hi") { $who->reply ($npc, "Hello!\n\n" . "I am a statistician, I keep statistics about all people here.\n\n" - . "To know how often somebody died, ask C I\n\n" - . "To know how many kills somebody scored, ask C I"); + . " - To know how often somebody died, ask C I\n" + . " - To know how many kills somebody scored, ask C I"); } else { $who->reply ($npc, "No idea what you want of me, how about saying 'hi' first?"); } @@ -151,3 +156,17 @@ $cmd = lc $cmd; }; +# log "crash" messages, i.e. client exit reasons +cf::register_exticmd clientlog => sub { + my ($ns, $msg) = @_; + + my $name = $ns->pl && $ns->pl->ob ? $ns->pl->ob->name : ""; + + $msg =~ y/\x0a\x20-\x7f//cd; + $msg =~ s/\s+$//; + + warn sprintf "clientlog [%s/%s]: %s\n", $ns->host, $name, $msg; + + () +}; +