Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.00 KB | None | 0 0
  1. ICPPS:
  2. Open up xmlServBase.php in includes:
  3. Go to the function parseRawdata.
  4. Add at the end, before the closing } of the function:
  5. if($called) {
  6. $this->callCustomXtHandlers($data, $client);
  7. }
  8.  
  9. Open ClubPenguin.php and add this function anywhere:
  10.     public function callCustomXtHandlers($data, $client) {
  11. foreach(glob("Plugins/*.php") as $file) {
  12. require_once $file;
  13. $basename = basename($file, ".php");
  14. if(class_exists($basename)) {
  15. $this->plugin = new $basename($this, $client);
  16. if($this->plugin->pluginOnGame) {
  17. $this->plugin->init($data);
  18. }
  19. }
  20. }
  21. }
  22. Make a new folder called Plugins where lake.php(the game-servers starter) is, and add this in it:
  23. Attached File  snowball.php   2.59KB   14 downloads
  24. Now make a new php file and name it whatever you want, make sure it's in the place where you run your lake.php and login.php.
  25. In the php file add:
  26. <?php
  27. date_default_timezone_set(@date_default_timezone_get());
  28.  
  29. error_reporting(E_ALL | E_STRICT);
  30. function __autoload ($className){
  31.     $fileName = 'INCLUDES/'.str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
  32.     $status = require($fileName);
  33.     if ($status === false) {
  34.         eval(sprintf('class %s {function __construct(){die("Class %s could not be found in the SERVICE directory}', $className, $className));
  35.     }
  36. }
  37. require "INCLUDES/general.php";
  38. (@include "LANG/en_config.php") || halt("Failed to open config");
  39. set_time_limit (0);
  40. foreach($config as $key =>  $c){
  41.     if($c === null){
  42.         halt("Option <$key> has not been set, shutting down.\n");
  43.     }
  44. }
  45. eval("php makeErrorArray.php");
  46. $server = new ClubPenguin($config);
  47. $config['PORT'] = 6114;
  48. $server->serverID = 102;
  49. $server->run();
  50. ?>
  51. And you're done, now add a new server in loader.as:
  52. Go to
  53. SHELL.world_crumbs[101] = {id: 101, name: "localhost", ip: "localhost", port: "6113", population: "1"};
  54. and add under it this :
  55. SHELL.world_crumbs[102] = {id: 102, name: "Snowball Server", ip: "localhost", port: "6113", population: "1"};
  56.  
  57. Now, in the icpps, you may come across the problem that the user who killed the other user is going to room 100 instead of vise versa, I am trying my best to fix this problem,  but I don't know why nothing is working, if you can, help please.
  58. That's it, your welcome.
  59. If you want to use this, I recommend adding some action script work into it...
  60. I know the script could be cleaner, but I didn't really work on cleaning it.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. snowball.php:
  69.  
  70.  
  71.  
  72. <?php
  73. class snowball {
  74.     public $pluginOnGame = true;
  75.     public $user;
  76.     public $server;
  77.  
  78.     public function __construct($serv, $client) {
  79.         $this->user = $client;
  80.         $this->server = $serv;
  81.     }
  82.     public function getStuff($u, $row) { // new
  83.         $dbi = mysqli_connect("localhost", "root", "", "database");
  84.         $sql = "SELECT * FROM `accs` WHERE name = '" . $u->name . "';";
  85.         $query1 = mysqli_query($dbi, $sql);
  86.         while ($rows = mysqli_fetch_assoc($query1)) {
  87.             return $rows[$row];
  88.         }
  89.     }
  90.     public function checkPoints($who) {
  91.         if($this->getStuff($who, "sbpoints") >= 5) {
  92.             return true;
  93.         } else {
  94.             return false;
  95.         }
  96.     }
  97.     public function kill($k) {
  98.         $dbi = mysqli_connect("localhost", "root", "", "database");
  99.         mysqli_query($dbi, 'UPDATE `accs` SET lives=lives-1 WHERE id =' . $k->ID . '');
  100.         $lives = $this->getStuff($k, "lives");
  101.         echo 'NEW LIVES: ' . $lives . '';
  102.         if( $lives == 0) {
  103.             foreach($this->server->clients as $u) {
  104.             $u->write(MakeXt("sm", $this->user->intRoom, 0, "" . $this->user->name . " Killed " . $k->name . "."));
  105.             }
  106.             $this->joinNew($k);
  107.             mysqli_query($dbi,'UPDATE accs SET sbpoints=sbpoints + 1 WHERE id =' . $this->user->ID . '');
  108.             mysqli_query($dbi,'UPDATE accs SET totalpoints=totalpoints + 1 WHERE id =' . $this->user->ID . '');                        
  109.             mysqli_query($dbi,'UPDATE accs SET lives=10 WHERE id =' . $k->ID . '');
  110.             $k->write(MakeXt("cm", -1, $this->user->name . " Killed you"));
  111.         }
  112.         if($this->checkPoints($this->user) == true) {
  113.             foreach($this->server->clients as $u) {
  114.             $u->write(MakeXt("sm", -1, 0, $this->user->name . " won"));
  115.             }
  116.             $this->restartAll();
  117.         }
  118.     }
  119.     function joinNew($u){
  120.     $id = $u->ID;
  121. $this->server->handleJoinRoom(array(4 => 100,0,0 ), "", $id);
  122. }  
  123. public function restartAll() {
  124.         foreach($this->server->clients as $u) {
  125.             $dbi = mysqli_connect("localhost", "root", "", "database");
  126.             mysqli_query($dbi, 'UPDATE accs SET sbpoints= 0 WHERE id =' . $u->ID . '');
  127.             $this->joinNew($u);
  128.         }
  129.     }
  130.     public function init($packet) {
  131.         $packet = explode("%", $packet);
  132.         if($packet[3] == 'u#sb') {
  133.             if($this->server->port == 6114) {
  134.                 foreach($this->server->clients as $u) {
  135.                     $x = $packet[5] + 20;
  136.                     if($this->user->extRoomID == $u->extRoomID and $this->user->ID != $u->ID) {
  137.                         if($u->xpos <= round($packet[5]) or $u->xpos >= round($packet[5]) and $u->xpos < $x ) {
  138.                             $y = $packet[6] + 20;
  139.                             if($u->ypos <= round($packet[6]) or $u->ypos >= round($packet[6]) and $u->ypos < $y ) {
  140.                                 if($u->extRoomID != 100) {
  141.                                     $this->kill($u);
  142.                                 }
  143.                             }
  144.                         }
  145.                     }
  146.                 }
  147.             }
  148.         }
  149.     }
  150. }
  151.  
  152. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement