Monday, October 3, 2011

How to add a function

This tutorial is written by Garetty not me.

First thing you will need is a function.

Open up tasks.php in a text editor and find the first function. This function is called sendRawPacket.

      function sendRawPacket($packet) {    
      fwrite($this->sock, $packet . chr(0)); 
         $info = stream_get_meta_data($this->sock);   
       if ($info['timed_out']) {      
        $this->run = false;         
 }     
 } 

You can add functions before that one, but I like to add them after the second function, just for better organization.

So find this (It is near the top of tasks.php):

      function readRawPacket($length = 8192) {     
     return fread($this->sock, $length);  
    } 


The next line, after the }, copy and paste your function.
For this example, I will be using mine and GaToR's function, addCoins.

I am going to copy this function and paste it after the } in the function readRawPacket.
It should look like this (Starting with sendRawPacket):

      function sendRawPacket($packet) {
           fwrite($this->sock, $packet . chr(0)); 
          $info = stream_get_meta_data($this->sock);
           if ($info['timed_out']) { 
              $this->run = false;   
       }      }  
    function readRawPacket($length = 8192) { 
          return fread($this->sock, $length);  
    }   
 function addCoins($coins) {  
      echo "\nStarting getCoins Function by Garetty and GaToR.\nWe will now attempt to add " . $coins . " to your account.\nThis may take a while, depending on the amount of coins you would like to add.\n"; 
       $addedcoins = $coins;
         $a = 0;    
    $Loop = 0;   
     $this->joinRoom(110);
         if ($coins < 1) { 
            echo "\nCoins must be above 0\n";    
    }        if ($coins > 0 && $coins < 5001) {   
         $this->joinRoom(810);    
        $this->joinGame(912);        
    sleep(1);       
     $this->getCoins($coins);   
     } else {       
     while ($coins > 5000) {     
           $a++;          
      $low = ($coins - 5000);       
         $coins = $low;      
      }            $this->joinRoom(810);    
        $this->joinGame(912);      
      $this->getCoins($coins);       
     while ($Loop < $a) {         
       $Loop++;         
       $this->joinRoom(810);      
          $this->joinGame(912);         
       sleep(1);       
         $this->getCoins(5000);        
        sleep(1);    
        }   
     }      
  echo $addedcoins . " coins have been added to your account.\n"; 
   } 


And that's all it takes.

No comments:

Post a Comment