Beispiel #1
0
 public static function cmdUnsell(Player $player, $numparams, $params)
 {
     Houses::LocatePlayerRoom($player, $numparams, $params, &$house, &$room);
     if ($house == null) {
         return COMMAND_OK;
     }
     if ($room == null) {
         if ($numparams == 0) {
             /* Check if the player or his faction have a room */
             if (($room = $house->GetRoom($player)) == null) {
                 $faction = $player->GetFaction();
                 if (!$faction || ($room = $house->GetRoom($faction)) == null) {
                     $player->Send(COLOR_HOUSE_DONTOWN, '[ERROR] You dont own any apartment in this building');
                     return COMMAND_BREAK;
                 }
             }
         } else {
             return COMMAND_BREAK;
         }
     }
     $owner = $room->GetOwnership();
     if (!$owner->Allowed($player)) {
         $player->Send(COLOR_HOUSE_UNSELL_DISALLOWED, '[ERROR] You are not allowed to unsell that property');
         return COMMAND_BREAK;
     }
     $faction = $player->GetFaction();
     if ($faction && $owner->GetType() == OWNERSHIP_FACTION && !$faction->AllowedTo($player, MEMBER_ALLOWEBANK)) {
         $player->Send(COLOR_HOUSE_UNSELL_DISALLOWED, '[ERROR] You are not allowed to unsell that property');
         return COMMAND_BREAK;
     }
     $room->SetAvailable(false);
     $room->SetPrice(-1);
     $house->UpdateCheapest();
     if ($owner->GetType() == OWNERSHIP_ACCOUNT) {
         if ($house->GetMaxRooms() > 1) {
             $player->Send(COLOR_HOUSE_FORSALE, "[HOUSE] Your apartment is not anymore for sale");
         } else {
             $player->Send(COLOR_HOUSE_FORSALE, "[HOUSE] This house is not anymore for sale");
         }
     } else {
         if ($faction && $owner->GetType() == OWNERSHIP_FACTION) {
             if ($house->GetMaxRooms() > 1) {
                 $str = "[HOUSE] {$player->name} has put the faction apartment number {$room->Number()} of '{$house->GetName()}' as not for sale";
             } else {
                 $str = "[HOUSE] {$player->name} has put the faction house '{$house->GetName()}' as not for sale";
             }
             $faction->Send(COLOR_HOUSE_FORSALE, $str, MEMBER_ALLOWBANK);
         }
     }
     return COMMAND_BREAK;
 }