/** * Get rules (cvars) from the server * * @throws SourceQueryException * * @return bool|array Returns array with rules on success, false on failure */ public function GetRules() { if (!$this->Connected) { return false; } switch ($this->GetChallenge(self::A2S_RULES, self::S2A_RULES)) { case self::GETCHALLENGE_FAILED: return false; case self::GETCHALLENGE_ALL_CLEAR: $this->Socket->Write(self::A2S_RULES, $this->Challenge); $this->Socket->Read(); $Type = $this->Buffer->GetByte(); if ($Type == 0) { return false; } else { if ($Type != self::S2A_RULES) { throw new SourceQueryException('GetRules: Packet header mismatch. (0x' . DecHex($Type) . ')'); } } break; } $Rules = array(); $Count = $this->Buffer->GetShort(); while ($Count-- > 0 && $this->Buffer->Remaining() > 0) { $Rule = $this->Buffer->GetString(); $Value = $this->Buffer->GetString(); if (!empty($Rule)) { $Rules[$Rule] = $Value; } } return $Rules; }