--- deliantra/server/ext/login.ext 2006/12/26 04:46:06 1.6 +++ deliantra/server/ext/login.ext 2006/12/27 15:04:38 1.8 @@ -62,7 +62,7 @@ . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; } -sub on_addme { +sub addme { my ($ns) = @_; $ns->destroy if $ns->pl; @@ -258,14 +258,36 @@ $ob->contr->save (1); $ob->contr->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { - $ob->contr->enable_save (1); if ($_[0] !~ /^[yY]/) { - $ob->contr->save (1); + $ob->contr->invoke (cf::EVENT_PLAYER_LOGOUT, 1); $ob->contr->ns->destroy; + } else { + $ob->contr->enable_save (1); } }); }, ); -cf::client->attach (package => __PACKAGE__); +cf::player->attach ( + on_login => sub { + my ($pl) = @_; + my $name = $pl->ob->name; + + $_->ob->message ("$name has entered the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; + }, + on_logout => sub { + my ($pl, $cleanly) = @_; + my $name = $pl->ob->name; + + if ($cleanly) { + $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; + } else { + $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; + } + }, +); + +cf::client->attach ( + on_addme => \&addme, +);