--- deliantra/server/ext/login.ext 2006/12/23 06:21:02 1.3 +++ 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; @@ -251,21 +251,43 @@ # update respawn position $ob->contr->savebed ($bed->map->path, $bed->x, $bed->y); - #TODO? - #strcpy (pl->contr->killer, "left"); - #check_score (pl); /* Always check score */ + $ob->contr->killer ("left"); + $ob->check_score; $ob->reply (undef, "In the future, you will wake up here when you die."); - $ob->contr->save (); + $ob->contr->save (1); $ob->contr->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { - if ($_[0] !~ /^[yY]/) { - $ob->contr->save (1); - $ob->contr->ns->destroy (); - } + if ($_[0] !~ /^[yY]/) { + $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, +);