Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ICPPS:
- Open up xmlServBase.php in includes:
- Go to the function parseRawdata.
- Add at the end, before the closing } of the function:
- if($called) {
- $this->callCustomXtHandlers($data, $client);
- }
- Open ClubPenguin.php and add this function anywhere:
- public function callCustomXtHandlers($data, $client) {
- foreach(glob("Plugins/*.php") as $file) {
- require_once $file;
- $basename = basename($file, ".php");
- if(class_exists($basename)) {
- $this->plugin = new $basename($this, $client);
- if($this->plugin->pluginOnGame) {
- $this->plugin->init($data);
- }
- }
- }
- }
- Make a new folder called Plugins where lake.php(the game-servers starter) is, and add this in it:
- Attached File snowball.php 2.59KB 14 downloads
- 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.
- In the php file add:
- <?php
- date_default_timezone_set(@date_default_timezone_get());
- error_reporting(E_ALL | E_STRICT);
- function __autoload ($className){
- $fileName = 'INCLUDES/'.str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
- $status = require($fileName);
- if ($status === false) {
- eval(sprintf('class %s {function __construct(){die("Class %s could not be found in the SERVICE directory}', $className, $className));
- }
- }
- require "INCLUDES/general.php";
- (@include "LANG/en_config.php") || halt("Failed to open config");
- set_time_limit (0);
- foreach($config as $key => $c){
- if($c === null){
- halt("Option <$key> has not been set, shutting down.\n");
- }
- }
- eval("php makeErrorArray.php");
- $server = new ClubPenguin($config);
- $config['PORT'] = 6114;
- $server->serverID = 102;
- $server->run();
- ?>
- And you're done, now add a new server in loader.as:
- Go to
- SHELL.world_crumbs[101] = {id: 101, name: "localhost", ip: "localhost", port: "6113", population: "1"};
- and add under it this :
- SHELL.world_crumbs[102] = {id: 102, name: "Snowball Server", ip: "localhost", port: "6113", population: "1"};
- 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.
- That's it, your welcome.
- If you want to use this, I recommend adding some action script work into it...
- I know the script could be cleaner, but I didn't really work on cleaning it.
- snowball.php:
- <?php
- class snowball {
- public $pluginOnGame = true;
- public $user;
- public $server;
- public function __construct($serv, $client) {
- $this->user = $client;
- $this->server = $serv;
- }
- public function getStuff($u, $row) { // new
- $dbi = mysqli_connect("localhost", "root", "", "database");
- $sql = "SELECT * FROM `accs` WHERE name = '" . $u->name . "';";
- $query1 = mysqli_query($dbi, $sql);
- while ($rows = mysqli_fetch_assoc($query1)) {
- return $rows[$row];
- }
- }
- public function checkPoints($who) {
- if($this->getStuff($who, "sbpoints") >= 5) {
- return true;
- } else {
- return false;
- }
- }
- public function kill($k) {
- $dbi = mysqli_connect("localhost", "root", "", "database");
- mysqli_query($dbi, 'UPDATE `accs` SET lives=lives-1 WHERE id =' . $k->ID . '');
- $lives = $this->getStuff($k, "lives");
- echo 'NEW LIVES: ' . $lives . '';
- if( $lives == 0) {
- foreach($this->server->clients as $u) {
- $u->write(MakeXt("sm", $this->user->intRoom, 0, "" . $this->user->name . " Killed " . $k->name . "."));
- }
- $this->joinNew($k);
- mysqli_query($dbi,'UPDATE accs SET sbpoints=sbpoints + 1 WHERE id =' . $this->user->ID . '');
- mysqli_query($dbi,'UPDATE accs SET totalpoints=totalpoints + 1 WHERE id =' . $this->user->ID . '');
- mysqli_query($dbi,'UPDATE accs SET lives=10 WHERE id =' . $k->ID . '');
- $k->write(MakeXt("cm", -1, $this->user->name . " Killed you"));
- }
- if($this->checkPoints($this->user) == true) {
- foreach($this->server->clients as $u) {
- $u->write(MakeXt("sm", -1, 0, $this->user->name . " won"));
- }
- $this->restartAll();
- }
- }
- function joinNew($u){
- $id = $u->ID;
- $this->server->handleJoinRoom(array(4 => 100,0,0 ), "", $id);
- }
- public function restartAll() {
- foreach($this->server->clients as $u) {
- $dbi = mysqli_connect("localhost", "root", "", "database");
- mysqli_query($dbi, 'UPDATE accs SET sbpoints= 0 WHERE id =' . $u->ID . '');
- $this->joinNew($u);
- }
- }
- public function init($packet) {
- $packet = explode("%", $packet);
- if($packet[3] == 'u#sb') {
- if($this->server->port == 6114) {
- foreach($this->server->clients as $u) {
- $x = $packet[5] + 20;
- if($this->user->extRoomID == $u->extRoomID and $this->user->ID != $u->ID) {
- if($u->xpos <= round($packet[5]) or $u->xpos >= round($packet[5]) and $u->xpos < $x ) {
- $y = $packet[6] + 20;
- if($u->ypos <= round($packet[6]) or $u->ypos >= round($packet[6]) and $u->ypos < $y ) {
- if($u->extRoomID != 100) {
- $this->kill($u);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement