… | |
… | |
30 | sub reject_entry { |
30 | sub reject_entry { |
31 | my ($pl) = @_; |
31 | my ($pl) = @_; |
32 | |
32 | |
33 | cf::override; |
33 | cf::override; |
34 | |
34 | |
35 | teleport $pl, "/world/world_105_115", 2, 34 |
35 | $pl->goto_map ("/world/world_105_115", 2, 34) |
36 | unless |
36 | unless |
37 | $pl->ob->map |
37 | $pl->ob->map |
38 | && $pl->ob->map->path !~ /nimbus/ |
38 | && !$pl->ob->map->{path}{user_rel}; |
39 | && $pl->ob->map->path !~ m%/var/crossfire/players/%; |
|
|
40 | } |
39 | } |
41 | |
40 | |
42 | sub update_balance { |
41 | sub update_balance { |
43 | my ($pl) = @_; |
42 | my ($pl) = @_; |
44 | |
43 | |
… | |
… | |
148 | delete $pl->{rent}{apartment}{$apartment}; |
147 | delete $pl->{rent}{apartment}{$apartment}; |
149 | |
148 | |
150 | $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course."); |
149 | $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course."); |
151 | }; |
150 | }; |
152 | |
151 | |
153 | cf::attach_to_players prio => 100, |
152 | cf::player->attach ( |
|
|
153 | prio => 100, |
154 | on_login => sub { |
154 | on_login => sub { |
155 | my ($pl) = @_; |
155 | my ($pl) = @_; |
156 | |
156 | |
157 | $pl->{rent}{last_offline_check} ||= time; |
157 | $pl->{rent}{last_offline_check} ||= time; |
158 | |
158 | |
… | |
… | |
163 | } else { |
163 | } else { |
164 | $pl->{rent}{last_online_check} = time; |
164 | $pl->{rent}{last_online_check} = time; |
165 | } |
165 | } |
166 | |
166 | |
167 | update_balance $pl; |
167 | update_balance $pl; |
168 | }; |
168 | }, |
|
|
169 | ); |
169 | |
170 | |
170 | cf::register_map_attachment rent => |
171 | cf::map::attachment rent => |
171 | on_enter => sub { |
172 | on_enter => sub { |
172 | my ($map, $pl, $x, $y) = @_; |
173 | my ($map, $pl, $x, $y) = @_; |
173 | |
174 | |
174 | # can freely enter homes of other people |
175 | # can freely enter homes of other people |
175 | { |
176 | { |
… | |
… | |
199 | $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); |
200 | $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); |
200 | reject_entry $pl; |
201 | reject_entry $pl; |
201 | }, |
202 | }, |
202 | ; |
203 | ; |
203 | |
204 | |
204 | Event->timer (after => 60, interval => 3600, data => cf::WF_AUTOCANCEL, cb => sub { |
205 | our $RENT_TIMER = Event->timer (after => 60, interval => 3600, data => cf::WF_AUTOCANCEL, cb => sub { |
205 | pay_balance $_ for cf::player::list; |
206 | pay_balance $_ for cf::player::list; |
206 | }); |
207 | }); |
207 | |
208 | |