Ankündigung

Einklappen
Keine Ankündigung bisher.

Problem mit Server -Response/Request

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem mit Server -Response/Request

    Habe folgende PHP Klasse:

    PHP-Code:
    class BFBC2{
        
        function 
    BFBC2(){
            
    $this->seqNum 0;
            
    $this->stopError false;
        }

        function 
    unpack($data){
            
    $decode unpack('I'$data);
            return 
    $decode[1];
        }
        
        
    //Send Request to Server
        
    function Request($sequence$words){
            
    $words explode(' '$words);
            
    $header pack('I'$sequence 0x3fffffff);
            
    $numWords pack('I'count($words));
            
            
    //Encode Words
            
    $size 0;
            
    $encodedWords '';
            foreach(
    $words as $word){
                
    $encodedWords .= pack('I'strlen($word));
                
    $encodedWords .= $word;
                
    $encodedWords .= "\x00";
                
    $size += strlen($word) + 5;
            }
            
    $words = array($size$encodedWords);
                
            list(
    $wordsSize$eWords) = $words;
            
    $eSize pack('I', ($wordsSize 12));
            return 
    $header $eSize $numWords $eWords;
        }
        
        
    //Response from Server
        
    function Response($data){
            
    $header unpack('I'$data);
            list(
    $fromServer$isResponse$sequence) = array($header 0x80000000$header 0x40000000$header 0x3fffffff);
            
    $wordSize $this->unpack(substr($data44)) - 12;
                
            
    //Decode Words
            
    $data2 substr($data12);
            
    $numWords $this->unpack($data2);
            
    $offset 0;
            while(
    $offset $wordSize){
                
    $wordLen $this->unpack(substr($data2$offset4));
                
    $word substr($data2$offset+4$wordLen);
                
    $words[] = $word;
                
    $offset += $wordLen 5;
            }
            
            return array(
    $fromServer$isResponse$sequence$words);
        }
        
        
    //Connect to Server
        
    function Connect($host$port$pw=''){
            
    $this->host $host;
            
    $this->socket = @fsockopen('tcp://'.$host$port$errno$errstr1);
            if(
    $this->socket != false){
                
    socket_set_timeout($this->socket0500000);
                
                
    //Connect Admin
                
    if($pw){
                    
    $response $this->Command('login.plainText '.$pw);
                    
                    if(
    $response[0] == 'InvalidPassword'){$this->stopError 'Invalid Password Specified';}
                    elseif(
    $response[0] == 'OK'){}
                }
            }else{
                
    $this->stopError 'Unable to Connect to Server';
            }
        }
        
        
    //Disconnect from Server
        
    function Disconnect(){
            
    $this->Command('quit');
            @
    fclose($this->socket);
        }
        
        
    // Send Command
        
    function Command($cmd){
            if(
    $this->stopError){return false;}

            
    fwrite($this->socket$this->Request($this->seqNum$cmd));
            
    $this->seqNum++;
            
    //list($fromServer, $isResponse, $seq, $words) = $this->Response(fread($this->socket, 4096));
            
    $response $this->Response(fread($this->socket4096));
            
            if(
    $response[3] == 'LogInRequired'){return 'RCON Password Required';}
            else{return 
    $response[3];}
        }
        

    Hier das passende RCon Protocol:
    http://www.filedealer.com/freeupload...c05b64a7ba.pdf


    Klasse anlegen, Verbindung aufbauen und auch Commandos zu senden bekomme ich hin.
    Bloß habe ich Probleme damit Server-Informationen (gespielte Map, Anzahl der Spieler etc.) auszulesen.
    Hat jm. vll. einen Tipp was ich hier:
    PHP-Code:
    function Response($data){ 
    für $data einsetzen muss???

    Vll. hat jm. einen passenden Tipp für mich!

    Vielen Dank schonmal!

  • #2
    Gibt es nicht ein Forum für den Gameserver, der da angesprochen wird oder ein RFC für das genannte Protokoll? Dort sollte die Information besser zu finden sein als hier.
    Viele Grüße,
    Dr.E.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1. Think about software design [B]before[/B] you start to write code!
    2. Discuss and review it together with [B]experts[/B]!
    3. Choose [B]good[/B] tools (-> [URL="http://adventure-php-framework.org/Seite/088-Why-APF"]Adventure PHP Framework (APF)[/URL][URL="http://adventure-php-framework.org"][/URL])!
    4. Write [I][B]clean and reusable[/B][/I] software only!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Kommentar


    • #3
      Nein ein Forum dazu gibt es leider nicht.

      Habe das Protokoll dafür nun nochmal drangehangen. Vll. hilft es ja?!?!

      Kommentar


      • #4
        Das hier wird dir eine große Hilfe sein: BC2Conn - PHP class for communicating with a Battlefield Bad Company 2 gameserver

        Es handelt sich hierbei um eine öffentliche Battlefield Bad Company 2 Gameserver PHP Klasse, welche von mir entwickelt wird. Mit dieser kannst du einen Gameserver administrieren und verwalten.

        // JLNNN

        Kommentar


        • #5
          Für die Interessierten: Ich habe soeben Version 1.41b veröffentlicht.

          Changelog:

          v1.41b
          * fixed kicking or banning players with names containing whitespaces doesn't work
          (reported by Thomas from Blut und Stahl | Deutscher Multigaming Fun-Clan - THX!)

          * changed default ban time from 'round' to 'perm'

          * changed syntax of adminYellMesage()

          * fixed sending adminYellMessage() to players works fine now
          minor improvements

          - JLNNN

          Kommentar


          • #6
            Update auf v1.5b.

            Changelog:

            v1.5b
            * added functions to get player specific data (playername, clantag, squadid, teamid)
            * added some more functions
            * fixed listing player subset of a given player
            * fixed minor bugs
            * improved some comments
            * YES - we did the 200 downloads! THANK YOU ALL

            Kommentar


            • #7
              Ich glaube nicht, dass das einsteigerforum das richtige medium ist um Werbung für Dein Script zu machen. Auch nicht für Dein Versions-Update...

              Kommentar


              • #8
                Alles klar, ich halte mich zurück.

                Kommentar

                Lädt...
                X