… | |
… | |
60 | system "cd \Q$PLAYERDIR\E " |
60 | system "cd \Q$PLAYERDIR\E " |
61 | . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " |
61 | . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " |
62 | . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; |
62 | . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; |
63 | } |
63 | } |
64 | |
64 | |
65 | sub on_addme { |
65 | sub addme { |
66 | my ($ns) = @_; |
66 | my ($ns) = @_; |
67 | |
67 | |
68 | $ns->destroy if $ns->pl; |
68 | $ns->destroy if $ns->pl; |
69 | |
69 | |
70 | $ns->coro (sub { |
70 | $ns->coro (sub { |
… | |
… | |
256 | |
256 | |
257 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
257 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
258 | $ob->contr->save (1); |
258 | $ob->contr->save (1); |
259 | |
259 | |
260 | $ob->contr->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
260 | $ob->contr->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
261 | $ob->contr->enable_save (1); |
|
|
262 | if ($_[0] !~ /^[yY]/) { |
261 | if ($_[0] !~ /^[yY]/) { |
263 | $ob->contr->save (1); |
262 | $ob->contr->invoke (cf::EVENT_PLAYER_LOGOUT, 1); |
264 | $ob->contr->ns->destroy; |
263 | $ob->contr->ns->destroy; |
|
|
264 | } else { |
|
|
265 | $ob->contr->enable_save (1); |
265 | } |
266 | } |
266 | }); |
267 | }); |
267 | }, |
268 | }, |
268 | ); |
269 | ); |
269 | |
270 | |
270 | cf::client->attach (package => __PACKAGE__); |
271 | cf::player->attach ( |
|
|
272 | on_login => sub { |
|
|
273 | my ($pl) = @_; |
|
|
274 | my $name = $pl->ob->name; |
271 | |
275 | |
|
|
276 | $_->ob->message ("$name has entered the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
|
|
277 | }, |
|
|
278 | on_logout => sub { |
|
|
279 | my ($pl, $cleanly) = @_; |
|
|
280 | my $name = $pl->ob->name; |
|
|
281 | |
|
|
282 | if ($cleanly) { |
|
|
283 | $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
|
|
284 | } else { |
|
|
285 | $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; |
|
|
286 | } |
|
|
287 | }, |
|
|
288 | ); |
|
|
289 | |
|
|
290 | cf::client->attach ( |
|
|
291 | on_addme => \&addme, |
|
|
292 | ); |
|
|
293 | |