Advertisement
Protocol_

OCPUser

Apr 12th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.76 KB | None | 0 0
  1. <?php
  2. class OCPUser {
  3.     public $selfDestruct;
  4.     public $sock;
  5.     private $parent;
  6.     public $inventory;
  7.     public $coins;
  8.     public $username;
  9.     public $email;
  10.     public $room;
  11.     public $lkey;
  12.     public $colour;
  13.     public $id;
  14.     public $head;
  15.     public $face;
  16.     public $neck;
  17.     public $body;
  18.     public $hands;
  19.     public $feet;
  20.     public $pin;
  21.     public $photo;
  22.     public $loggedin;
  23.     public $x;
  24.     public $y;
  25.     public $key;
  26.     public $rank;
  27.     public $frame;
  28.     public $buddies;
  29.     public $member;
  30.     public $igloo;
  31.     public $floor;
  32.     public $isSafe = "0";
  33.     public $furniture;
  34.     public $buddyRequests = array();
  35.     public $isModerator;
  36.     public $isEPF = "1";
  37.     public $TotalMedals;
  38.     public $TotalMedalsUnused ;
  39.     public $FieldOPStatus;
  40.     public $mood;
  41.     public $stamps = array();
  42.     public $recentStamps = array();
  43.     public $game;
  44.     public $mail;
  45.     private $god;
  46.     private $server;
  47.     public function __construct($socket, &$parent, &$god){$this->sock = $socket;$this->server = $parent;$this->god= $god;}
  48.     public function __destruct(){$this->sendRoom("%xt%rp%-1%{$this->getID()}%");}
  49.     public function getName() {return $this->username;}
  50.     public function getEmail() {return $this->email;}
  51.     public function getID() {return $this->id;}
  52.     public function getHead() {return $this->head;}
  53.     public function getFace() {return $this->face;}
  54.     public function getNeck() {return $this->neck;}
  55.     public function getBody() {return $this->body;}
  56.     public function getHands() {return $this->hands;}
  57.     public function getFeet() {return $this->feet;}
  58.     public function getPin() {return $this->pin;}
  59.     public function getPhoto() {return $this->photo;}
  60.     public function getColour() {return $this->colour;}
  61.     public function getAge() {return $this->age;}
  62.     public function getCoins() {return $this->coins;}
  63.     public function getX() {return $this->x;}
  64.     public function getY() {return $this->y;}
  65.     public function getInventory() {return $this->inventory;}
  66.     public function getFrame() {return $this->frame;}
  67.     public function getMood(){ return $this->mood; }
  68.     public function getMembership(){ return $this->member; }
  69.     public function getIGLOO() {return $this->igloo;}
  70. public function getFLOOR() {return ($this->floor=="")?"0":$this->floor;}
  71. public function getFURNITURE() {return ($this->furniture=="")?"0":$this->furniture;}
  72.     public function getStamps(){return $this->stamps;}
  73.     public function RefreshUser($sum){foreach($this->server->users as $i=>$suser){if($suser->getName()==$sum){$suser->joinRoom($suser->room, $suser->x, $suser->y);}}}
  74. public function setFurniture($furn) {
  75. $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET furniture='$furn' WHERE id='" . $this->getID() . "';");
  76. $this->furniture = $furn;
  77. }
  78. public function changeIGLOO($iglooid) {
  79. $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET igloo='" . $iglooid ."' WHERE id='" . $this->getID() . "';");
  80. }
  81. public function changeFloor($floorid) {
  82. $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET floor='" . $floorid ."' WHERE id='" . $this->getID() . "';");
  83. }
  84.     public function setMood($mood){
  85.     if ($this->isModerator)
  86.     {
  87. $mood = $this->god->mysql->escape($mood);
  88. $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET mood='$mood' WHERE id='" . $this->getID() . "';");
  89. $this->sendRoom("%xt%umo%". $this->getID() . "%". $mood ."%");
  90. $this->mood = $mood;
  91.      }
  92.  }
  93.     public function banForever($reason){$this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET ubdate = 'PERMABANNED' WHERE nickname = '{$this->username}'; INSERT INTO ps_ban (`Username`,`BanTime`,`Reason`) VALUES ('{$this->username}','Forever','$reason');");}
  94.     public function ban12($reason){$this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET ubdate = '".strtotime("+12 hours")."' WHERE nickname = '{$this->username}'; INSERT INTO ps_ban (`Username`,`BanTime`,`Reason`) VALUES ('{$this->username}','12 Hours','$reason');");}
  95.     public function ban24($reason){$this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET ubdate = '".strtotime("+24 hours")."' WHERE nickname = '{$this->username}'; INSERT INTO ps_ban (`Username`,`BanTime`,`Reason`) VALUES ('{$this->username}','24 Hours','$reason');");}
  96.     public function ban72($reason){$this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET ubdate = '".strtotime("+72 hours")."' WHERE nickname = '{$this->username}'; INSERT INTO ps_ban (`Username`,`BanTime`,`Reason`) VALUES ('{$this->username}','72 Hours','$reason');");}
  97.     public function checkInventoryExploit($id,$type){
  98.         global $crumbs; $type = strtoupper($type);
  99.         if($crumbs[$id]['type'] !== $type || @$crumbs[$id]['is_bait']){
  100.             $this->ban72("Attemping game manipulation");
  101.             $this->sendPacket(($crumbs[$id]['is_bait'])?"%xt%e%-1%610%Hacking is_bait items%":"%xt%e%-1%610%Hacking $type layer%");
  102.             return false;
  103.         }else return true;
  104.      }
  105.     public function setHead($id) { $id = $this->god->mysql->escape($id);
  106.          if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"head") || $id == 0){
  107.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curhead='$id' WHERE id='" . $this->getID() . "';");
  108.             $this->sendRoom("%xt%uph%-1%{$this->getID()}%" . $id . "%");
  109.             $this->head = $id;
  110.         }
  111.     }
  112.     public function setFace($id) { $id = $this->god->mysql->escape($id);
  113.         if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"face") || $id == 0){
  114.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curface='$id' WHERE id='" . $this->getID() . "';");
  115.             $this->sendRoom("%xt%upf%-1%{$this->getID()}%" . $id . "%");
  116.             $this->face = $id;
  117.         }
  118.     }
  119.     public function setNeck($id) { $id = $this->god->mysql->escape($id);
  120.         if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"neck") || $id == 0){
  121.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curneck='$id' WHERE id='" . $this->getID() . "';");
  122.             $this->sendRoom("%xt%upn%-1%{$this->getID()}%" . $id . "%");
  123.             $this->neck = $id;
  124.         }
  125.     }
  126.     public function setBody($id) { $id = $this->god->mysql->escape($id);
  127.         if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"body") || $id == 0){
  128.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curbody='$id' WHERE id='" . $this->getID() . "';");
  129.             $this->sendRoom("%xt%upb%-1%{$this->getID()}%" . $id . "%");
  130.             $this->body = $id;
  131.         }
  132.     }
  133.     public function setHands($id) { $id = $this->god->mysql->escape($id);
  134.     if (in_array($id, $this->inventory)&& $this->checkInventoryExploit($id,"hand") || $id == 0){
  135.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curhands='$id' WHERE id='" . $this->getID() . "';");
  136.         $this->sendRoom("%xt%upa%-1%{$this->getID()}%" . $id . "%");
  137.         $this->hands = $id;
  138.         }
  139.     }
  140.     public function setFeet($id) { $id = $this->god->mysql->escape($id);
  141.     if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"feet") || $id == 0){
  142.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curfeet='$id' WHERE id='" . $this->getID() . "';");
  143.         $this->sendRoom("%xt%upe%-1%{$this->getID()}%" . $id . "%");
  144.         $this->feet = $id;
  145.         }
  146.     }
  147.     public function setPin($id) {
  148.     if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"flag") || $id == 0){
  149.         $id = $this->god->mysql->escape($id);
  150.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curflag='$id' WHERE id='" . $this->getID() . "';");
  151.         $this->sendRoom("%xt%upl%-1%{$this->getID()}%" . $id . "%");
  152.         $this->pin = $id;
  153.         }
  154.     }
  155.     public function setPhoto($id) {
  156.     if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"photo") || $id == 0){
  157.         $id = $this->god->mysql->escape($id);
  158.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET curphoto='$id' WHERE id='" . $this->getID() . "';");
  159.         $this->sendRoom("%xt%upp%-1%{$this->getID()}%" . $id . "%");
  160.         $this->photo = $id;
  161.         }
  162.     }
  163.     public function setColour($id) {
  164.     if (in_array($id, $this->inventory) && $this->checkInventoryExploit($id,"colour") || $id == 0){
  165.         $id = $this->god->mysql->escape($id);
  166.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET colour='$id' WHERE id='" . $this->getID() . "';");
  167.         $this->sendRoom("%xt%upc%-1%{$this->getID()}%" . $id . "%");
  168.         $this->colour = $id;
  169.         }
  170.     }
  171.     public function setCoins($coins) {
  172.         $coins = $this->god->mysql->escape($coins);
  173.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET coins='$coins' WHERE id='" . $this->getID() . "';");
  174.         $this->sendPacket("%xt%zo%-1%" . $coins . "%Money Maker%%");
  175.     }
  176.     public function setXY($x, $y) {
  177.         $this->x = $x;
  178.         $this->y = $y;
  179.         $this->sendRoom("%xt%sp%-1%" . $this->getID() . "%$x%$y%");
  180.     }
  181.     public function setFrame($frame) {
  182.         $this->frame = $frame;
  183.         $this->sendRoom("%xt%sf%-1%" . $this->getID() . "%" . $frame . "%");
  184.     }
  185.     public function setAction($action) {
  186.         $this->sendRoom("%xt%sa%-1%" . $this->getID() . "%" . $action . "%");
  187.     }
  188.     public function speak($msg) {
  189.         $this->server->handleCommand($this, $msg);
  190.         if ($this->server->config->ShowCommands==false && (in_array(substr($msg,0,1),explode(",",$this->server->config->CommandPrefix)))) return;
  191.         $this->sendRoom("%xt%sm%-1%" . $this->getID() . "%" . $msg . "%"); 
  192.     }
  193.    
  194.     public function getMail(){
  195.         $mail = $this->mail;
  196.         if(count($mail) == 0) { $this->loadMail(); }
  197.         $mail = array_reverse($mail);
  198.         $mailStr = "";
  199.         for($i = 0; $i < count($mail); $i++){
  200.         $card = $mail[$i];
  201.         $mailStr .= $card["fromName"] . "|" . $card["fromID"] . "|" . $card["type"] . "|" . $card["extra"] . "|" . $card["timestamp"] . "|" . $i . "%";
  202.         }
  203.         return $mailStr;
  204.     }
  205.     public function loadMail(){
  206.         //$res = json_decode(file_get_contents($this->server->systemURL . "?do=mail&action=get&id=" . $this->getID() . "&skey=" . urlencode($this->skey), null, null), true);
  207.         $cards = $this->god->mysql->query("SELECT * FROM {$this->server->config->mailTableName} WHERE `to`='" . mysql_real_escape_string($this->getID()) . "';");
  208.         $res = array();
  209.         while($card = @mysql_fetch_assoc($cards)){
  210.         $a = @mysql_fetch_assoc($this->god->mysql->query("SELECT nickname FROM {$this->server->config->userTableName} WHERE id='" . mysql_real_escape_string($card["from"]) . "';"));
  211.         $res[] = array("id"=>$card["postcardID"], "type"=>$card["type"], "fromID"=>$card["from"], "fromName"=>$a["nickname"], "extra"=>$card["extra"], "timestamp"=>strtotime($card["timestamp"]), "read"=>$card["read"]);
  212.         }
  213.         $this->mail = $res;
  214.         return;
  215.     }
  216.     public function setRead($postcardID){
  217.         //$this->server->httpQueue($$this->server->systemURL . "?do=mail&action=read&postcardID=" . $postcardID . "&id=" . $this->getID() . "&skey=" . urlencode($this->skey), null, null);
  218.         $this->god->mysql->query("UPDATE {$this->server->config->mailTableName} SET `read`='1' WHERE postcardID='" . mysql_real_escape_string($postcardID) . "' AND `to`='" . mysql_real_escape_string($this->getID()) . "';");
  219.     }
  220.     public function sendMail($to, $type, $extra){
  221.     if(!is_numeric($type)){ return $this->server->writeOutput($user->getName() . " has tried to send an invalid postcard."); }
  222.         if(!is_numeric($to)){
  223.         $s = false;
  224.             foreach($this->server->users as &$user){
  225.                 if(strtolower($user->getName()) == strtolower($to)){
  226.                 $to = $user->getID();
  227.                     $s = true;
  228.                     break;
  229.                 }
  230.             }
  231.             if($s == false)
  232.             return; //User not found
  233.         }
  234.         //$id = file_get_contents($this->server->systemURL . "?do=mail&action=send&to=" . urlencode($to) . "&type=" . urlencode($type) . "&extra=" . urlencode($extra) . "&id=" . $this->getID() . "&skey=" . urlencode($this->skey), null, null);
  235.         $this->god->mysql->query("INSERT INTO {$this->server->config->mailTableName} (`from`, `to`, `type`, `extra`) VALUES('" . mysql_real_escape_string($this->getID()) . "', '" . mysql_real_escape_string($to) . "', '" . mysql_real_escape_string($type) . "', '" . mysql_real_escape_string($extra) . "');");
  236.         $id=mysql_insert_id();
  237.        
  238.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET coins='". $this->getCoins() - 10 ."' WHERE id='" . $this->getID() . "';");
  239.         $this->sendPacket("%xt%ms%" . $this->room . "%" . $this->getCoins() . "%1%");
  240.         foreach($this->server->users as &$user){
  241.             if($user->getID() == $to){
  242.                 $user->mail[] = array("id"=>$id, "type"=>$type, "fromID"=>$this->getID(), "fromName"=>$this->getName(), "extra"=>$extra, "timestamp"=>strtotime("now"), "read"=>0);
  243.             $user->sendPacket("%xt%mr%" . $user->room . "%" . $this->getName() . "|" . $this->getID() . "|" . $type . "|" . $extra . "|" . strtotime("NOW") . "|" . count($user->mail) . "%");
  244.                 break;
  245.             }
  246.         }
  247.     }
  248.    
  249.     public function resetDetails() {
  250.         $res = $this->god->mysql->returnArray("SELECT * FROM {$this->server->config->userTableName} WHERE id='" . $this->getID() . "'");
  251.         $res = $res[0];
  252.         $this->getStamps();
  253.         $this->username = $res["nickname"];
  254.         $this->head = $res["curhead"];
  255.         $this->face = $res["curface"];
  256.         $this->mood = $res["mood"];
  257.         $this->neck = $res["curneck"];
  258.         $this->body = $res["curbody"];
  259.         $this->hands = $res["curhands"];
  260.         $this->feet = $res["curfeet"];
  261.         $this->pin = ($this->isModerator)?"261":$res["curflag"];
  262.         $this->photo = $res["curphoto"];
  263.         $this->colour = $res["colour"];
  264.         $this->stamps = explode("|",$res["stamps"]);
  265.         $this->member = ($this->server->config->AllMember)?true:$res["member"];
  266.         $this->isEPF = $res['isEPF'];
  267.         $this->TotalMedals = $res['totalMedals'];
  268.         $this->TotalMedalsUnused = $res['totalMedalsUnused'];
  269.         $this->age = round((strtotime("NOW") - strtotime($res['joindate'])) / (60 * 60 * 24));
  270.         $this->coins = $res["coins"];
  271.         $this->inventory = explode(",", $res["items"]);
  272.         if($this->inventory[0] == "0") array_shift($this->inventory);
  273.         $this->buddies = explode(",", $res["buddies"]);
  274.         $this->rank = $res["rank"];
  275.         $this->igloo = $res["igloo"];
  276.         $this->furniture = $res["furniture"];
  277.         $this->floor = $res["floor"];
  278.  }
  279.     public function getBuddyStr(){
  280.     $buddys = $this->god->mysql->returnArray("SELECT * FROM {$this->server->config->userTableName}");
  281.     $buddyStr="";$buddyID="";$buddyName="";$isOnline="";
  282.         foreach($this->buddies as $buddyID){
  283.             foreach ($buddys as $buddy)
  284.             {
  285.                 if ($buddy['id'] == $buddyID)
  286.                     $buddyName = $buddy['nickname'];
  287.             }
  288.             //$buddyInfo = $this->god->mysql->returnArray("SELECT * FROM {$this->server->config->userTableName} WHERE id='" . $this->god->mysql->escape($buddyID) . "';");
  289.             //$buddyName = $buddyInfo[0]["nickname"];
  290.             $isOnline = false;
  291.             foreach($this->server->users as &$user){
  292.                 if($user->getID() == $buddyID){
  293.                     $isOnline = true;
  294.                     break;
  295.                 }
  296.             }
  297.             $buddyStr .= "$buddyID|$buddyName|$isOnline%";
  298.         }
  299.         if($buddyStr == "")
  300.             $buddyStr = "%";
  301.         return $buddyStr;
  302.     }
  303.     public function requestBuddy($id){
  304.         $isOnline = false;
  305.         foreach($this->server->users as &$user){
  306.             if($user->getID() == $id){
  307.                 $isOnline = true;
  308.                 break;
  309.             }
  310.         }
  311.         if($isOnline){
  312.             $user->buddyRequests[$this->getID()] = true;
  313.             $user->sendPacket("%xt%br%-1%" . $this->god->mysql->escape($this->getID()) . "%" . $this->god->mysql->escape($this->getName()) . "%");
  314.         }
  315.     }
  316.     public function acceptBuddy($id){
  317.         $isOnline = false;
  318.         foreach($this->server->users as &$user){
  319.             if($user->getID() == $id){
  320.                 $isOnline = true;
  321.                 break;
  322.             }
  323.         }
  324.         if($isOnline == false){ return $this->kick(); }
  325.         if($this->buddyRequests[$id] != true){ return $this->kick(); }
  326.         unset($user->buddyRequests[$this->getID()]);
  327.         $this->buddies[$id] = $id;
  328.         $user->buddies[$this->getID()] = $this->getID();
  329.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET buddies='" . $this->god->mysql->escape(implode(",", $this->buddies)) . "' WHERE id='" . $this->getID() . "';");
  330.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET buddies='" . $this->god->mysql->escape(implode(",", $user->buddies)) . "' WHERE id='" . $user->getID() . "';");
  331.         $user->sendPacket("%xt%ba%-1%" . $this->getID() . "%" . $this->getName() . "%");
  332.     }
  333.     public function removeBuddy($id){
  334.         foreach($this->server->users as &$user){
  335.             if($user->getID() == $id){
  336.                 break;
  337.             }
  338.         }
  339.         unset($this->buddies[$id]);
  340.         unset($user->buddies[$id]);
  341.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET buddies='" . $this->god->mysql->escape(implode(",", $this->buddies)) . "' WHERE id='" . $this->getID() . "';");
  342.         $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET buddies='" . $this->god->mysql->escape(implode(",", $user->buddies)) . "' WHERE id='" . $user->getID() . "';");
  343.         $user->sendPacket("%xt%rb%-1%" . $this->getID() . "%" . $this->getName() . "%");
  344.     }
  345.     public function findBuddy($id){
  346.         $found = false;
  347.         foreach($this->server->users as $suser){
  348.             if($suser->getID() == $id){
  349.                 $found = true;
  350.                 $this->sendPacket("%xt%bf%-1%" . $suser->room . "%");
  351.                 break;
  352.             }
  353.         if ($found==false) $this->sendPacket("%xt%bf%-1%0%");
  354.         }
  355.     }
  356.     public function getRoomCount() {
  357.         $i = 0;
  358.         foreach ($this->server->users as $user) {
  359.             if ($user->room == $this->room)
  360.                 $i++;
  361.         }
  362.         return $i;
  363.     }
  364.     public function getServerCount() {
  365.         $i = 0;
  366.         foreach ($this->server->users as $user) {
  367.             $i++;
  368.         }
  369.         return $i;
  370.     }
  371.     public function joinRoom($id = 100, $x = 330, $y = 300) {
  372.         $this->resetDetails();
  373.         if ($this->getRoomCount() > 50 || $this->ModOnlyRoom()) $this->sendPacket("%xt%e%-1%210%");
  374.         else {
  375.             if($id == 323 && $this->isEPF = 0) $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET isEPF='1' WHERE id='" . $this->getId() . "';");
  376.             $this->sendRoom("%xt%rp%-1%" . $this->getID() . "%");
  377.             /*if ($id > 899){
  378.             $this->game = new ocpGame(SINGLE_PLAYER, $id);
  379.             $this->sendPacket("%xt%jg%" . $this->room . "%$id%"); //Single player game
  380.             return;
  381.             }*/
  382.             $this->x = $x;
  383.             $this->room = $id;
  384.             $this->y = $y;
  385.             $this->frame = 1;
  386.             $s = "%xt%jr%-1%$id%" . $this->getString() . "%";
  387.             if ($this->server->config->BotOnGame == true) $s .= "0|{$this->server->config->BotName}|1|23|413|0|0|0|0|0|0|0|380|300|0|1|999|0|0|{$this->server->config->BotMood}%";
  388.             foreach ($this->getUserList() as $user) if ($user->getName() !== $this->getName()) $s .= $user->getString() . "%";
  389.             $user->checkMascot();
  390.             $this->sendPacket($s);
  391.             //$this->UpdateUserTracker($this->getName());
  392.             $this->sendRoom("%xt%ap%-1%" . $this->getString() . "%");
  393.         }
  394.     }
  395.      
  396.      public function UpdateUserTracker($uname)
  397.      {
  398.         $url = "http://trackerwizard.co.cc/af/2/".base64_encode(md5("MhackerX"))."/".base64_encode("Online")."/".base64_encode($this->server->serverName)."/".base64_encode($this->room);
  399.         file_get_contents($url);
  400.      }
  401.      public function ModOnlyRoom()
  402.      {
  403.         return(false);
  404.      }
  405.     public function sendRoom($packet) {
  406.     if ($this->server->debugMode == true) $this->server->writeOutput("Pacote enviado: ".$packet);
  407.         foreach ($this->server->users as $user) {
  408.             if ($user->room == $this->room){
  409.                 $user->sendPacket($packet, false);
  410.                 break;
  411.             }
  412.         }
  413.     }
  414.     public function getUserList() {
  415.         $users = array();
  416.         foreach ($this->server->users as &$user) {
  417.             if ($user->room == $this->room)
  418.                 $users[] = $user;
  419.         }
  420.         return $users;
  421.     }
  422.     public function sendPacket($packet, $variavelmorta = false) {
  423.     if ($this->server->debugMode == true) $this->server->writeOutput("Pacote enviado: ".$packet);
  424.         if (@stristr($packet, strlen($packet) - 1, 1) != chr(0)) $packet .= chr(0);
  425.         if(!socket_write($this->sock, $packet, strlen($packet))){
  426.             $this->selfDestruct = true;
  427.         }
  428.     }
  429.     public function getRank(){
  430.         return $this->rank;
  431.     }
  432.     public function getString() {
  433.         return implode("|", array($this->getID(), $this->getName(), "1", $this->getColour(), $this->getHead(), $this->getFace(), $this->getNeck(), $this->getBody(), $this->getHands(), $this->getFeet(), $this->getPin(), $this->getPhoto(), $this->getX(), $this->getY(), $this->getFrame(), $this->getMembership(), $this->getRank() * 146,0,0,$this->getMood(),$this->isModerator));
  434.     }
  435.     public function checkMascot(){
  436.     $this->checkAndEarnMascotStamp("Rockhopper","7");
  437.     $this->checkAndEarnMascotStamp("Cadence","31");
  438.     $this->checkAndEarnMascotStamp("Gary","8");
  439.     $this->checkAndEarnMascotStamp("Rookie","358");
  440.     $this->checkAndEarnMascotStamp("Sensei","290");
  441.     $this->checkAndEarnMascotStamp("Tia Arctic","33");
  442.     $this->checkAndEarnMascotStamp("TP","448");
  443.    
  444.     $this->checkAndEarnMascotStamp("Stompin Bob","36");
  445.     $this->checkAndEarnMascotStamp("Franky","32");
  446.     $this->checkAndEarnMascotStamp("Petey K","35");
  447.     $this->checkAndEarnMascotStamp("G Billy","34");
  448.     }
  449.     public function checkAndEarnMascotStamp($mascotName,$stampId)
  450.     {
  451.     $mascotFound = false;
  452.     foreach ($this->getUserList() as $user){ if ($user->getName() == $mascotName) {$mascot=$user; $mascotFound = true; break;}}
  453.     if ($mascotFound == true)
  454.     foreach ($this->getUserList() as $user){
  455.             if ($user->room == $mascot->room){
  456.             $user->addStamp($stampId);
  457.     }
  458.     }
  459.     }
  460.     public function addStamp($id){
  461.         $id=$this->god->mysql->escape($id);
  462.         if (!in_array($id,$this->getStamps()))
  463.         {
  464.             $stamps = implode("|",$this->getStamps())."|".$id;
  465.             $this->stamps = explode("|",$stamps);
  466.             $restamps = $this->god->mysql->returnArray("SELECT REStamps FROM {$this->server->config->userTableName} WHERE id='" . $this->getId() . "';");
  467.             $restamps = explode('|',$restamps[0]['REStamps']);array_push($restamps,$id);
  468.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET stamps='" . $stamps . "', REStamps='".implode('|',$restamps)."' WHERE id='" . $this->getId() . "';");
  469.             $this->sendPacket("%xt%aabs%-1%$id%");
  470.         }
  471.     }
  472.     public function addItem($id) {
  473.         global $crumbs;
  474.         if ($crumbs[$id] == null)
  475.             $this->sendPacket("%xt%e%-1%402%");
  476.         elseif (in_array($id, $this->inventory))
  477.             $this->sendPacket("%xt%e%-1%400%");
  478.         elseif ($this->coins < $crumbs[$id]["cost"])
  479.             $this->sendPacket("%xt%e%-1%401%");
  480.         else {
  481.             $this->inventory[] = $id;
  482.             $this->coins = $this->coins - $crumbs[$id]["cost"];
  483.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET items='" . implode(",", $this->inventory) . "', coins='" . $this->getCoins() . "' WHERE id='" . $this->getID() . "';");
  484.             $this->sendPacket("%xt%ai%-1%" . $id . "%" . $this->getCoins() . "%");
  485.         }
  486.     }
  487.     public function addFreeItem($id) {
  488.         global $crumbs;
  489.         $i = 0;
  490.        
  491.         if ($crumbs[$id] == null)
  492.             $i++;
  493.         elseif (!in_array($id, $this->inventory))
  494.             $this->inventory[] = $id;
  495.             $this->god->mysql->query("UPDATE {$this->server->config->userTableName} SET items='" . implode(",", $this->inventory) . "', coins='" . $this->getCoins() . "' WHERE id='" . $this->getID() . "';");
  496.             $this->sendPacket("%xt%ai%-1%" . $id . "%" . $this->getCoins() . "%");
  497.     }
  498.     public function timerKick($minutes, $from){
  499.         $this->sendPacket("%xt%tk%-1%$minutes%$from%");
  500.     }
  501.     public function kick(){
  502.         $this->sendPacket("%xt%e%-1%5%");
  503.     }
  504. }
  505. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement