public function init() { parent::init(); $id = $_POST["id"]; // check if id is valid if (!is_numeric($id) || empty($id) || $id < 0) { $this->error('Ungültige Player-ID'); } // load player $this->selectedUser = R::findOne('user', ' id = ?', array($id)); if (!$this->selectedUser) { $this->error('Der Spieler konnte nicht gefunden werden'); } // check if player is online if (!$this->selectedUser->isOnline()) { $this->error('Der Spieler ist nicht online'); } // load pos $userPos = R::findOne('map_position', ' user_id = ?', array($this->user->getID())); $this->selectedUserPos = R::findOne('map_position', ' user_id = ?', array($this->selectedUser->getID())); // is to far away? $dist = sqrt(pow($this->selectedUserPos->x - $userPos->x, 2) + pow($this->selectedUserPos->y - $userPos->y, 2)); if ($dist > 5) { $this->error('Du bist zu weit entfehrt um mit ' . $this->selectedUser->username . ' zu interagieren'); } }
public function init() { parent::init(); $id = $_POST["id"]; // check if npc is valid if (!is_numeric($id) || $id <= 0) { $this->error('Invalid ' . $this->_type . '-ID'); } $this->npc = R::load($this->_type, $id); if ($this->npc->getID() != $id) { $this->error($this->_type . ' doesnt exist!'); } // check if npc has right type if ($this->npc->type != $this->myType) { $this->error("This " . $this->_type . " is not of " . $this->myType); } // check if user is nearby $userPos = R::findOne('map_position', ' user_id = ?', array($this->user->getID())); $dist = sqrt(pow($this->npc->x - $userPos->x, 2) + pow($this->npc->y - $userPos->y, 2)); if ($dist > 3 || $this->npc->map != $userPos->map) { $this->error('Du bist zu weit entfehrt!'); } // check if quest availible $this->myNPCQuest = R::relatedOne($this->user, 'quests_npc', ' complete_time = 0 AND (startnpc_id = ? OR stopnpc_id = ?)', array($this->npc->getID(), $this->npc->getID())); if ($this->myNPCQuest != null) { if ($this->myNPCQuest->startnpc_id == $this->npc->getID()) { if ($this->myNPCQuest->accepted == 0) { $this->myNPCQuestRole = 'startnpc'; $startnpc = $this->npc->name; $stopnpc = R::getCell('SELECT `name` FROM map_npc WHERE id = ?', array($this->myNPCQuest->stopnpc_id)); } } else { if ($this->myNPCQuest->accepted == 1) { $this->myNPCQuestRole = 'stopnpc'; $stopnpc = $this->npc->name; $startnpc = R::getCell('SELECT `name` FROM map_npc WHERE id = ?', array($this->myNPCQuest->startnpc_id)); } } if ($this->myNPCQuestRole != 'none') { $all = Config::getConfig('npc_quests'); $this->myNPCQuestData = $all[$this->myNPCQuest->quest_id][$this->myNPCQuestRole]; $this->myNPCQuestData["text"] = str_replace(array('{startnpc}', '{stopnpc}'), array($startnpc, $stopnpc), $this->myNPCQuestData["text"]); foreach ($this->myNPCQuestData["items"] as $k => $v) { $this->myNPCQuestData["items"][$k]["param"] = str_replace(array('{startnpc}', '{stopnpc}'), array($startnpc, $stopnpc), $v["param"]); } if ($this->_controllerFunc == 'Interact') { $this->output('quest', '<br /> <br /> <b>Quest:</b> ' . htmlspecialchars($this->myNPCQuestData["text"]) . ' <br /> <a href="#questing">' . ($this->myNPCQuestRole == 'startnpc' ? 'annehmen' : 'abschließen') . '</a>'); } } } }
public function init() { parent::init(); // only works if you are in casino $ct = R::getCell('SELECT map FROM map_position WHERE user_id = ?', array($this->user->getID())); if ($ct != "casino") { $this->error('Not in casino.'); } $this->_pokerPlayer = R::relatedOne($this->user, 'poker_player'); if ($this->_pokerPlayer == null) { $this->error('Invalid Poker-ID'); } }
public function init() { parent::init(); $id = $_POST["id"]; // check if npc is valid if (!is_numeric($id) || $id <= 0) { $this->error('Invalid ITEM-ID'); } $this->item = R::findOne('inventory', ' id = ? AND user_id = ?', array($id, $this->user->id)); if (!$this->item) { $this->error('Du hast das Item nicht im Inventar!'); } // check if usable if ($this->item->item->usable == 0) { $this->error('Item nicht benutzbar!'); } // check if item has the right type if ($this->item->item->type != $this->myType) { $this->error('Das Item ist nicht vom Typ ' . $this->myType); } }
public function init() { parent::init(); $this->teleportMap = Config::getConfig('teleportPoints'); $this->mapPosition = R::findOne('map_position', ' user_id = ?', array($this->user->getID())); }