public function __construct($name, $maxrooms, $default_price)
 {
     $id = Houses::MakeID($name);
     parent::__construct($id, $name, $maxrooms, $default_price, new Position(2485, -1690), new Position(2505, -1710), 20, new Position(2496.05, -1692.9301, 1014.7422, 180), 3);
     /* Interior ID */
     parent::AddHouseEntrance('street', new Position(893.5016000000001, -1637.2668, 14.9297, 180));
 }
Beispiel #2
0
 /**
  ** Init
  ** Initialize all factions.
  **/
 public static function Init()
 {
     $factions = DB::GetAllFactions();
     foreach ($factions as $name) {
         /* Load the faction source code */
         $fixed_name = str_replace(' ', '_', $name);
         require_once "gamemodes/factions/{$fixed_name}.php";
         $factiondata = DB::GetFactionData($name);
         $classname = 'Faction_' . $fixed_name;
         $newfaction = new $classname($name, $factiondata['color'], $factiondata['bank'], $factiondata['maxvehicles'], $factiondata['maxmembers'], $factiondata['membercount']);
         if ($factiondata['HQ'] != null) {
             $room = Houses::FindByDBID($factiondata['HQ']);
             if ($room) {
                 $newfaction->SetHQ($room);
             }
         }
         if ($factiondata['bankfreezed'] == 1) {
             $newfaction->FreezeBank();
         }
         Factions::Register($newfaction, $newfaction->GetHQ());
         echo ">>>>> Loaded faction '{$name}'\n";
     }
     /* Register common faction commands */
     CommandHandler::Register('invite', 1, null, array('Factions', 'cmdInvite'), '[ID]', 1);
     CommandHandler::Register('uninvite', 1, null, array('Factions', 'cmdUninvite'), '[ID]', 1);
     CommandHandler::Register('rankup', 1, null, array('Factions', 'cmdRankup'), '[ID]', 1);
     CommandHandler::Register('rankdown', 1, null, array('Factions', 'cmdRankdown'), '[ID]', 1);
     CommandHandler::Register('duty', 1, null, array('Factions', 'cmdDuty'), '[on/off]', 1, -1000);
     CommandHandler::Register('open', 0, null, array('Factions', 'cmdOpen'), '', 1);
     CommandHandler::Register('close', 0, null, array('Factions', 'cmdClose'), '', 1);
 }
Beispiel #3
0
 public function __construct($name, $maxrooms, $default_price)
 {
     $id = Houses::MakeID($name);
     parent::__construct($id, $name, $maxrooms, $default_price, new Position(1220, -730), new Position(1320, -830), 100, new Position(1258.2936, -838.6871, 1084.0078, 0), 5);
     /* Interior ID */
     $this->AddHouseEntrance('main', new Position(1298.5369, -798.8372000000001, 83.8, 180));
     $this->AddHouseEntrance('roof', new Position(1287.4863, -788.7426, 92.0313, 90), new Position(1261.4065, -785.6282, 1091.9063, 270));
     $this->SetKitchen(new Position(1276.972, -813.8871, 1085.6328));
     $this->SetFridgePos(new Position(1275.4027, -822.4887, 1085.6328));
     $this->LoadObjectsFromFile('Madd_House.txt');
 }
Beispiel #4
0
 /**
  ** FreezeBank
  ** Sets this faction bank frozen or not frozen.
  **
  ** Parameters:
  ** - state: The new state of the bank account
  **/
 public function FreezeBank($state = true)
 {
     $this->bankfreezed = $state;
     if ($this->bankfreezed) {
         /* Unsell faction sellable properties */
         Houses::UnsellFactionRooms($this);
     }
 }
Beispiel #5
0
 public function FreezeBank($status)
 {
     $this->bankfreezed = $status;
     if ($this->bankfreezed) {
         /* Unsell all this player properties */
         Houses::UnsellPlayerRooms($this);
     }
 }
Beispiel #6
0
 public static function SaveData()
 {
     static $numsaves = 0;
     //      echo "*** Starting data save ...\n";
     DB::StartTransaction();
     Accounts::Save();
     Factions::Save();
     Houses::Save();
     DB::Commit();
     //      echo "*** Data saved sucessfully!\n";
     $numsaves++;
     if ($numsaves == 12) {
         //        echo "*** Doing manteinance...\n";
         /* Make manteinance */
         Factions::UpdateMembercount();
         $numsaves = 0;
         //        echo "*** Manteinance complete!\n";
     }
 }
Beispiel #7
0
        foreach ($this->input as $char) {
            $this->step($char);
        }
        return count($this->visited);
    }
    public function step2($dir)
    {
        $xField = 'x' . $this->turn;
        $yField = 'y' . $this->turn;
        $this->{$xField} += $this->dir[$dir][0];
        $this->{$yField} += $this->dir[$dir][1];
        $key = $this->{$xField} . 'x' . $this->{$yField};
        if (!isset($this->visited[$key])) {
            $this->visited[$key] = 0;
        }
        $this->visited[$key]++;
    }
    public function part2()
    {
        $this->read();
        $this->visited = ['0x0' => 2];
        foreach ($this->input as $index => $char) {
            $this->turn = $index % 2 === 0 ? 'Santa' : 'Robo';
            $this->step2($char);
        }
        return count($this->visited);
    }
}
$houses = new Houses();
echo "part1: " . $houses->countVisited() . "\n\n";
echo "part2: " . $houses->part2();
Beispiel #8
0
 public static function SaveRoom($data)
 {
     $query = 'UPDATE room SET ';
     foreach ($data as $key_ => $value_) {
         $key = mysql_real_escape_string($key_, DB::$handler);
         $value = mysql_real_escape_string($value_, DB::$handler);
         if ($key != 'house' && $key != 'id' && $key != 'number') {
             if ($value == null) {
                 $query .= "{$key}=NULL, ";
             } else {
                 $query .= "{$key}='{$value}', ";
             }
         }
     }
     $id = mysql_real_escape_string($data['id'], DB::$handler);
     $house = mysql_real_escape_string($data['house'], DB::$handler);
     $number = mysql_real_escape_string($data['number'], DB::$handler);
     $tmpquery = $query . "house='{$house}' WHERE id='{$id}'";
     if (!mysql_query($tmpquery, DB::$handler)) {
         if (mysql_errno() != 1452) {
             DB::DBdie("Error saving room '{$room}' of house '{$house}': " . mysql_error() . "\n");
         }
         $tmpquery = substr($query, 0, strlen($query) - 2) . " WHERE id='{$id}'";
         if (mysql_query($tmpquery, DB::$handler)) {
             echo "WARNING: House '{$house}' seems to have been deleted from database, removing from gamemode\n";
             Houses::DestroyHouse($data['house']);
             return false;
         } else {
             if (mysql_errno() != 1452) {
                 DB::DBdie("Error when checking house '{$house}' integrity in room '{$number}' saving: " . mysql_error() . "\n");
             }
             echo "WARNING: House '{$house}' room number '{$number}' fails integrity for owner, setting nobody\n";
             $house = Houses::Find($data['house']);
             if ($house) {
                 $room = $house->GetRoom($data['number']);
                 if ($room) {
                     $house->UpdateOwnership($room, new Ownership(null, null));
                 }
             }
         }
     }
     return true;
 }
Beispiel #9
0
function drophouse(Player $player, $numparams, $params)
{
    Houses::DestroyHouse(-1439014222);
    return COMMAND_OK;
}
Beispiel #10
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;
 }