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; }
public static function OnPlayerEnterVehicle(Player $player, $vehicle) { if ($player->timedeath != 0) { $pos = $player->Position(); SetPlayerPos($player->id, $pos->x, $pos->y, $pos->z); return CALLBACK_DISALLOW; } return CALLBACK_OK; }
/** ** IsInExit ** Checks if a player is in some of this location exits. If true, return the entrance. ** ** Parameters: ** - player: The player to check **/ public function IsInExit(Player $player) { foreach ($this->entrances as $entrance) { if ($entrance->start->IsInSphere($player->Position(), 2.5)) { return $entrance; } } return null; }
/** ** Commands **/ public static function cmdExercise(Player $player, $numparams, $params) { foreach (Gym::$machines as $machine) { if (isset(Gym::$anims[$machine->type]) && $machine->position->IsInSphere($player->Position(), 1.5)) { if ($machine->player) { $player->Send(COLOR_GYM_MACHINE_USED, '[ERROR] This exercise machine is already being used'); return COMMAND_OK; } $player->SetPosition($machine->position); $player->SetCamera($machine->camera); $player->CameraLookAt($machine->position); $player->Animate(Gym::$anims[$machine->type]); $machine->player = $player; } } return COMMAND_OK; }
function dodrivenext(Player $player, $numparams, $params) { $pos = $player->Position(); $nearest = null; $distance = 0; for ($i = 0; $i < 700; $i++) { GetVehiclePos($i, &$x, &$y, &$z); if ($x == 0 && $y == 0 && $z == 0) { continue; } $vpos = new Position($x, $y, $z); $dist = $vpos->DistanceTo($pos); if ($nearest === null || $dist < $distance) { $distance = $dist; $nearest = $i; } } if ($nearest !== null) { PutPlayerInVehicle($player->id, $nearest, 0); } return COMMAND_OK; }
public static function cmdCook(Player $player, $numparams, $params) { if ($player->location instanceof House) { $house = $player->location; if (($pos = $house->GetKitchen()) == null) { $player->Send(COLOR_HOUSE_HASNTKITCHEN, '[ERROR] This house doesn\'t have a cooker'); return COMMAND_OK; } if (!$pos->IsInSphere($player->Position(), 2.5)) { $player->Send(COLOR_HOUSE_NOTNEARKITCHEN, '[ERROR] You are not near the cooker'); return COMMAND_OK; } $player->SetMenu(Houses::$cookmenu); } return COMMAND_OK; }
private static function SendDescribe(Player $player, $text) { Log::Append(LOG_MESSAGE, "{ACTION} [{$player->id}] {$player->name} describes: {$text}"); $str = "** {$player->name} {$text}"; $sectors = $player->sector->FindSectors($player->Position(), 20); foreach ($sectors as $sector) { foreach ($sector->GetPlayers() as $target) { if ($player->vworld == $target->vworld && $player->Position()->DistanceTo($target->Position()) < 20) { $target->Send(COLOR_ACTION, $str); } } } }
public function StreamCheckpoints(Player $player) { $nearest = null; $distance = 0.0; $tmpdist = 0.0; for ($cp = $this->checkpoints; $cp != null; $cp = $cp->next) { if (($tmpdist = $cp->position->DistanceTo($player->Position())) < $distance || $nearest == null) { $nearest = $cp; $distance = $tmpdist; } } if ($player->checkpoint != $nearest) { if ($nearest != null) { SetPlayerCheckpoint($player->id, $nearest->position->x, $nearest->position->y, $nearest->position->z, $nearest->size); } else { DisablePlayerCheckpoint($player->id); } } $player->checkpoint = $nearest; }