public function actionaddVehicles() { $model = new Vehicles(); if (!Yii::app()->user->isGuest) { if (isset($_POST['Vehicles'])) { //$model->vehicle_type_id=$_POST['DispatchForm']['vehicle_type_id']; //$model->vehicle_id=$_POST['DispatchForm']['vehicle_id']; $model->setLicensePlateNumber($_POST['Vehicles']['licensePlateNumber']); $model->setStatus($_POST['Vehicles']['status']); $model->insertData(Yii::app()->session['vehicleTypeId']); } $this->render('addVehicles', array('model' => $model)); } else { $this->redirect(Yii::app()->user->returnUrl); } }
private static function Add($name, $price, $color, Position $position) { $modelid = Vehicles::FindModelidByName($name); if ($modelid != -1) { $v = new Vehicle(-1, VEHICLE_SHOP, -1, $modelid, $color, $position); VehicleShop::$prices[$v->ID()] = $price; } }
public static function Init() { echo ">>>> Setting SAMP globals, PHP settings and timers ...\n"; SetGameModeText('ItalyMafia RPG v3.0'); AllowInteriorWeapons(1); DisableInteriorEnterExits(); EnableStuntBonusForAll(false); AllowAdminTeleport(true); AddTimer(array('Core', 'SaveData'), 10000, 1); ini_set('max_execution_time', 300); echo ">>>> Starting logs ...\n"; Log::Init(); echo ">>>> Starting the keybinds manager ...\n"; Keybinds::Init(); echo ">>>> Starting the menus manager ...\n"; Menu::Init(); echo ">>>> Starting the skins manager ...\n"; Skins::Init(); echo ">>>> Starting the animations manager ...\n"; Animations::Init(); echo ">>>> Starting locations ...\n"; Locations::Init(); echo ">>>> Starting DB engine ...\n"; DB::Init(); echo ">>>> Starting houses ...\n"; Houses::Init(); echo ">>>> Starting factions ...\n"; Factions::Init(); echo ">>>> Starting players manager ...\n"; Players::Init(); echo ">>>> Starting vehicles manager ...\n"; Vehicles::Init(); echo ">>>> Starting accounts manager ...\n"; Accounts::Init(); echo ">>>> Starting messages manager ...\n"; Messages::Init(); echo ">>>> Creating the clock ...\n"; Core::StartClock(); echo ">>>> Starting gyms ...\n"; Gym::Init(); echo ">>>> Starting admins ...\n"; Admin::Init(); }
public function Update() { if ($this->location == null) { return; } $this->updates++; /* Update player position, speed and area sector */ GetPlayerPos($this->id, &$this->position->x, &$this->position->y, &$this->position->z); GetPlayerFacingAngle($this->id, &$this->position->angle); $this->speed = $this->last_updated_position->DistanceTo($this->position); $sector = $this->location->Locate($this->position); if ($this->sector->id != $sector->id) { $this->sector->RemovePlayer($this); $sector->AddPlayer($this); } $this->sector = $sector; $this->last_updated_position = clone $this->position; /* Save player state */ $this->state = GetPlayerState($this->id); if ($this->firstSpawn) { return; } /* Update ping */ $this->ping = GetPlayerPing($this->id); /* Check the player vehicle */ if (IsPlayerInAnyVehicle($this->id)) { if ($this->vehicle === null) { /* Show incar textdraw */ $this->incar_draw = Players::GetIncarDraw($this->id); TextDrawShowForPlayer($this->id, $this->incar_draw); TextDrawSetString($this->incar_draw, '...'); } $this->vehicle = Vehicles::FindByID(GetPlayerVehicleID($this->id)); if ($this->vehicle != null) { if ($this->state == PLAYER_STATE_DRIVER && $this->vehicle->Type() == VEHICLE_SHOP) { $this->Freeze(); } } } else { if ($this->incar_draw !== null) { /* Hide incar textdraw */ TextDrawHideForPlayer($this->id, $this->incar_draw); $this->incar_draw = null; } if ($this->vehicle != null) { if ($this->vehicle->Type() == VEHICLE_SHOP) { /* Player was freezed in a shop vehicle but left it, so allow him to move again */ $this->Freeze(false); } } $this->vehicle = null; } /* Update the incar textdraw */ if ($this->incar_draw !== null && $this->updates & 1) { if ($this->speedometer == 'mph') { $speed = $this->speed * 4.464; } else { $speed = $this->speed * 7.2; } $string = sprintf('~y~Speed~n~~w~%d %s~n~~y~Fuel~n~~w~%.1f LT', (int) $speed, $this->speedometer, $this->vehicle->Fuel()); TextDrawSetString($this->incar_draw, $string); } /** ** Update the nametag drawing **/ $sectors = $this->sector->FindSectors($this->position, 12.5); $watchplayers = array(); foreach ($sectors as $sector) { foreach ($sector->GetPlayers() as $player) { if ($player->id >= $this->id) { break; } if ($this->position->DistanceTo($player->position) < 12.5) { $watchplayers[$player->id] = $player; } } } ksort($watchplayers); $i = 0; foreach ($watchplayers as $id => $player) { for (; $i < $id; $i++) { if ($this->seeingNametags[$i] == true) { $p = Players::FindByID($i); if ($p) { $this->CanIdentify($p, false); $p->CanIdentify($this, false); } $this->seeingNametags[$i] = false; } } $i++; if ($this->vehicle == $player->vehicle) { $equalv = true; } else { $equalv = false; } if (!$player->vehicle || !$player->vehicle->HasWindows() || $this->vehicle && $equalv) { if ($this->seeingNametags[$id] == false) { $this->CanIdentify($player, true); } } else { if ($this->seeingNametags[$id] == true) { $this->CanIdentify($player, false); } } if (!$this->vehicle || !$this->vehicle->HasWindows() || $player->vehicle && $equalv) { if ($player->seeingNametags[$this->id] == false) { $player->CanIdentify($this, true); } } else { if ($player->seeingNametags[$this->id] == true) { $player->CanIdentify($this, false); } } } while ($i < $this->id) { if ($this->seeingNametags[$i] == true) { $player = Players::FindByID($i); if ($player) { $this->CanIdentify($player, false); $player->CanIdentify($this, false); } } $i++; } /** ** Update the hunger and injures health **/ if ($this->checkhealth && !$this->dead) { $cur = time(); if ($this->timedeath > 0) { if ($cur - $this->timedeath > 60) { /* If the player was 60 seconds dieing, finish him */ $this->Kill(); } else { if ($cur - $this->timedeath > 5) { /* After 5 seconds, other players are allowed to finish him */ GetPlayerHealth($this->id, &$health); if ($health + 2 < $this->hunger * 100 / MAX_HUNGER_POINTS) { $this->Kill(); } } else { $health = $this->hunger * 100 / MAX_HUNGER_POINTS; if ($health <= 0) { $this->Kill(); } else { SetPlayerHealth($this->id, $health); } } } } else { $this->hunger--; $health = $this->hunger * 100 / MAX_HUNGER_POINTS; if ($health == 0) { $this->Kill(); } else { if (!$this->lagprotection) { GetPlayerHealth($this->id, &$tmphealth); if ($tmphealth == 0) { $this->Kill(); } else { if (!($this->hunger % 20)) { /* Update health only every 10 seconds */ SetPlayerHealth($this->id, $health); } GetPlayerArmour($this->id, &$armor); if ($tmphealth + 2 < $health) { SetPlayerHealth($this->id, $health); $armor -= $health - $tmphealth; SetPlayerArmour($this->id, $armor); } if ($armor < 0) { $armor = 0; } /* The lowest possible armor points is 0 */ $injures = 100 - $armor; if ($injures < $this->injures) { /* The player has less injures than he should have */ SetPlayerArmour($this->id, 100 - $this->injures); } else { if ($injures > $this->injures) { /* The player has more injures that the last registered ones */ $this->injures = $injures; } } if ($this->injures == 100) { /* The player is dead, full injures */ if (IsPlayerInAnyVehicle($this->id)) { $this->Kill(); } else { $anim = Animations::GetDeathAnim(); $this->ClearAnimations(); $this->Animate($anim); $this->timedeath = time(); $this->Send(COLOR_YELLOW, '* You are dieing! You will be dead in one minute if you don\'t get a medic help.'); $this->Send(COLOR_YELLOW, '* You can also accept your own death after 10 seconds using /die command.'); SetPlayerArmour($this->id, 0); } } } } } } } /* If the player has lag protection, decrease one unit */ if ($this->lagprotection) { $this->lagprotection--; } if ($this->lagprotection_guns) { $this->lagprotection_guns--; } /* Update the jail time */ if ($this->jailtime != 0 && $this->updates & 1) { $this->jailtime--; if ($this->jailtime < 1) { /* Unjail the player */ $this->jailtime = 1; $this->Unjail(); } else { /* Ensure that the player is still in jail */ $bounds = PoliceDepartment::AdminCellBounds(); if (!$this->position->IsInCube($bounds['min'], $bounds['max'])) { $this->SetLocation(PoliceDepartment::Instance()); $this->SetPosition(PoliceDepartment::AdminCell()); } /* Send the time remaining message */ GameTextForPlayer($this->id, "Jail time remaining: {$this->jailtime} seconds", 1000, 4); } } /* * Update animation */ if ($this->animation && $this->updates & 1 && $this->vehicle == null && ($this->animation->forced || $this->animation->continue)) { ApplyAnimation($this->id, $this->animation->lib, $this->animation->anim, 4.0, $this->animation->loop, $this->animation->movex, $this->animation->movey, $this->animation->continue, $this->animation->time); } }
public static function cmdCreateVehicle(Player $player, $numparams, $params) { $vehicle = implode(' ', array_slice($params, 1)); $model = -1; if (!ctype_digit($vehicle)) { $model = Vehicles::FindModelidByName($vehicle); } else { if (Vehicles::IsValidModelid($vehicle)) { $model = (int) $vehicle; } else { return COMMAND_OK; } } if ($model != -1) { $pos = clone $player->Position(); $pos->x++; $pos->y++; $pos->z++; new Vehicle(-1, VEHICLE_STATIC, -1, $model, array(1, 0), $pos, 100, 1.1); } else { $player->Send(COLOR_ERROR, '.:: Enter a valid vehicle model ID or name ::.'); } return COMMAND_OK; }
/** * @param \Skonsoft\VehicleManagerBundle\Entity\Vehicle $vehicle * * @return \Skonsoft\VehicleManagerBundle\Entity\Model */ public function removeVehicle(Vehicle $vehicle) { $this->vehicles->removeElement($vehicle); // unset($vehicle); return $this; }
public function OnVehicleRespray($vehicleid, $color1, $color2) { if ($this->callbacks[cOnVehicleRespray] == null) { return 1; } $vehicle == Vehicles::FindByID($vehicleid); if ($vehicle == null) { return 1; } for ($cbk = $this->callbacks[cOnVehicleRespray]; $cbk != null; $cbk = $cbk->next) { if (call_user_func($cbk->GetFunc(), $vehicle, $color1, $color2) == 1) { return 1; } } return 0; }
public function __construct($id, $type, $dbid, $model, $color, Position $parking, $health = 100, $fuel = 1, $age = 0, Account $owner = null) { $this->type = $type; $this->color[0] = $color[0]; $this->color[1] = $color[1]; $this->dbid = $dbid; $this->health = $health; $this->fuel = $fuel; $this->age = $age; $this->model = $model; if ($this->type == VEHICLE_SHOP) { $this->respawn = 10; } else { $this->respawn = 7200; } if ($id == -1) { /* We must create the vehicle in SAMP */ if ($parking->x != 0 && $parking->y != 0 && $parking->z != 0 && $parking->angle != 0) { /* Make sure that it has a spawn position, if not the player must do /callcar */ $this->id = CreateVehicle($this->model, $parking->x, $parking->y, $parking->z, $parking->angle, $this->color[0], $this->color[1], $this->respawn); } else { $this->id = -1; } } else { $this->id = $id; } $this->attributes = Vehicles::GetAttributes($model); if ($this->age < 48 * 3600) { $this->class = 1; $this->fuelusage = $this->attributes->GetFuelUsage(); } else { if ($this->age < (48 + 40) * 3600) { $this->class = 2; $this->fuelusage = $this->attributes->GetFuelSpace() / (DEFAULT_FUELTIME - 300); /* Penalty of 5 minutes of fuel */ } else { if ($this->age < (48 + 40 + 35) * 3600) { $this->class = 3; $this->fuelusage = $this->attributes->GetFuelSpace() / (DEFAULT_FUELTIME - 600); /* Penalty of 10 minutes of fuel */ } else { $this->class = 4; $this->fuelusage = $this->attributes->GetfuelSpace() / (DEFAULT_FUELTIME - 900); /* Penalty of 15 minutes of fuel */ } } } /* Add this vehicle to the vehicles list */ Vehicles::Add($this); }
<?php /** * Created by PhpStorm. * User: Benjamin * Date: 10/01/2016 * Time: 00:31 */ require_once '../../private/classes/Auth.class.php'; require_once '../../private/classes/Player.class.php'; require_once '../../private/classes/Vehicles.class.php'; // Security if (Auth::isModo() == false && Auth::isAdmin() == false) { header('HTTP/1.0 401 Unauthorized'); exit('Grant access required !'); } // Routes switch ($_GET['op']) { case 'update_civ_licenses': $p = new Player(); $p->updateLicenses($_POST['status'], $_POST['pid'], $_POST['id']); break; case 'delete_vehicle': $v = new Vehicles(); $v->deleteVehicle($_POST['id']); break; }
/** * Serves a list of suggestions matching the term $term, in form of * a json-encoded object. * @param string $term the string to match */ public function actionSuggest($term = '') { die("Heelo!"); $this->serveJson(Vehicles::model()->findMatches($term)); }
/** * Deletes a vehicle * * @param string $id */ public function deleteAction($id) { $vehicle = Vehicles::findFirstByid($id); if (!$vehicle) { $this->flash->error("vehicle was not found"); return $this->dispatcher->forward(array("controller" => "vehicles", "action" => "index")); } if (!$vehicle->delete()) { foreach ($vehicle->getMessages() as $message) { $this->flash->error($message); } return $this->dispatcher->forward(array("controller" => "vehicles", "action" => "search")); } $this->flash->success("vehicle was deleted successfully"); return $this->dispatcher->forward(array("controller" => "vehicles", "action" => "index")); }