ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/rent.ext
(Generate patch)

Comparing deliantra/server/ext/rent.ext (file contents):
Revision 1.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.5 by root, Fri Jan 5 01:06:27 2007 UTC

12 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], 12 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"],
13 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"], 13 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"],
14 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"], 14 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"],
15); 15);
16 16
17sub teleport {
18 my ($pl, $map, $x, $y) = @_;
19
20 my $portal = cf::object::new "exit";
21
22 $portal->slaying ($map);
23 $portal->stats->hp ($x);
24 $portal->stats->sp ($y);
25 $portal->apply ($pl->ob);
26 $portal->destroy;
27}
28
29# we have to special case some special cases :) 17# we have to special case some special cases :)
30sub reject_entry { 18sub reject_entry {
31 my ($pl) = @_; 19 my ($pl) = @_;
32 20
33 cf::override; 21 cf::override;
34 22
35 teleport $pl, "/world/world_105_115", 2, 34 23 $pl->goto ("/world/world_105_115", 2, 34)
36 unless 24 unless
37 $pl->ob->map 25 $pl->ob->map
38 && $pl->ob->map->path !~ /nimbus/ 26 && !$pl->ob->map->{path}{user_rel};
39 && $pl->ob->map->path !~ m%/var/crossfire/players/%;
40} 27}
41 28
42sub update_balance { 29sub update_balance {
43 my ($pl) = @_; 30 my ($pl) = @_;
44 31
148 delete $pl->{rent}{apartment}{$apartment}; 135 delete $pl->{rent}{apartment}{$apartment};
149 136
150 $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course."); 137 $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course.");
151}; 138};
152 139
153cf::attach_to_players prio => 100, 140cf::player->attach (
141 prio => 100,
154 on_login => sub { 142 on_login => sub {
155 my ($pl) = @_; 143 my ($pl) = @_;
156 144
157 $pl->{rent}{last_offline_check} ||= time; 145 $pl->{rent}{last_offline_check} ||= time;
158 146
163 } else { 151 } else {
164 $pl->{rent}{last_online_check} = time; 152 $pl->{rent}{last_online_check} = time;
165 } 153 }
166 154
167 update_balance $pl; 155 update_balance $pl;
168 }; 156 },
157);
169 158
170cf::register_map_attachment rent => 159cf::map::attachment rent =>
171 on_enter => sub { 160 on_enter => sub {
172 my ($map, $pl, $x, $y) = @_; 161 my ($map, $pl, $x, $y) = @_;
173 162
174 # can freely enter homes of other people 163 # can freely enter homes of other people
175 { 164 {
199 $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); 188 $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!");
200 reject_entry $pl; 189 reject_entry $pl;
201 }, 190 },
202; 191;
203 192
204Event->timer (after => 60, interval => 3600, data => cf::WF_AUTOCANCEL, cb => sub { 193our $RENT_TIMER = Event->timer (after => 60, interval => 3600, data => cf::WF_AUTOCANCEL, cb => sub {
205 pay_balance $_ for cf::player::list; 194 pay_balance $_ for cf::player::list;
206}); 195});
207 196

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines