Player Entity preload

This commit is contained in:
Shoghi Cervantes Pueyo
2013-03-17 16:56:36 +01:00
parent 5fedf27255
commit 012c86ef00
2 changed files with 35 additions and 26 deletions

View File

@@ -188,9 +188,16 @@ class Entity extends stdClass{
}
if(($time - $this->spawntime) >= 2){
$player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true);
if(($player instanceof Entity) and $player->gamemode === SURVIVAL or $player->gamemode === ADVENTURE){
$player = $this->server->api->entity->get($player["EID"]);
if($player instanceof Entity){
$player = $player->player;
}else{
return false;
}
if(($player instanceof Player) and ($player->gamemode === SURVIVAL or $player->gamemode === ADVENTURE) and $player->spawned === true){
if($this->server->api->dhandle("player.pickup", array(
"eid" => $player["EID"],
"eid" => $player->eid,
"player" => $player,
"entity" => $this,
"block" => $this->type,
"meta" => $this->meta,
@@ -199,6 +206,7 @@ class Entity extends stdClass{
$this->close();
return false;
}
return true;
}
}
}