Jump to content
Sign in to follow this  
Jamie

[Kitsune] How to fix puffle over-buying (negative coins)

Recommended Posts

Hello all,

So recently I forgot to patch this up, thought I'd share it with you guys who have AS3 servers and are using Kitsune as a source.

Basically the situation is you're able to buy as many puffle wild creatures as you like - you can go into negative balance but spam buy them still.

Such a simple solution and I should of done it ages ago but forgot to, thought I'd share for any noobs

Here's how to fix it:

Go to Kitsune\ClubPenguin\Handlers\Play\Pet.php

Find the function

Quote
// Check if they exceed puffle limit (?)
  // Also check if types are valid!
  protected function handleAdoptPuffle($socket) {
  $penguin = $this->penguins[$socket];
  $puffleType = Packet::$Data[2];
  $puffleName = ucfirst(Packet::$Data[3]);
  $puffleSubtype = Packet::$Data[4];
   
  if($puffleSubtype == 0) {
  $puffleCost = 400;
  } else {
  $puffleCost = 800;
  }
   
  if(is_numeric($puffleType) && is_numeric($puffleSubtype)) {
  $puffleId = $penguin->database->adoptPuffle($penguin->id, $puffleName, $puffleType, $puffleSubtype);
  $adoptionDate = time();
   
  if($puffleSubtype == 0) {
  $puffleSubtype = "";
  }
   
  $penguin->buyPuffleCareItem(3, 0, 5, true); // Puffle O's
  $penguin->buyPuffleCareItem(76, 0, 1, true); // Apple
   
  $postcardId = $penguin->database->sendMail($penguin->id, "sys", 0, $puffleName, $adoptionDate, 111);
  $penguin->send("%xt%mr%-1%sys%0%111%$puffleName%$adoptionDate%$postcardId%");
   
  $penguin->setCoins($penguin->coins - $puffleCost);
  $penguin->send("%xt%pn%{$penguin->room->internalId}%{$penguin->coins}%$puffleId|$puffleType|$puffleSubtype|$puffleName|$adoptionDate|100|100|100|100|0|0|0|1|%");
   
  $penguin->database->updateColumnById($penguin->id, "Walking", $puffleId);
  $penguin->walkingPuffle = $penguin->database->getPuffleColumns($puffleId, array("Type", "Subtype", "Hat") );
  $penguin->walkingPuffle = array_values($penguin->walkingPuffle);
  array_unshift($penguin->walkingPuffle, $puffleId);
  }
  }

And replace it with the following

Quote

    public function handleAdoptPuffle($socket) {
        $penguin = $this->penguins[$socket];
        $puffleType = Packet::$Data[2];
        $puffleName = ucfirst(Packet::$Data[3]);
        $puffleSubtype = Packet::$Data[4];
        
        if($puffleSubtype == 0) {
            $puffleCost = 400;
        } else {
            $puffleCost = 800;
        }
        if($penguin->coins < $puffleCost) {
            return $penguin->send("%xt%e%-1%401%");
        } 
        
        if(is_numeric($puffleType) && is_numeric($puffleSubtype)) {
            $puffleId = $penguin->database->adoptPuffle($penguin->id, $puffleName, $puffleType, $puffleSubtype);
            $adoptionDate = time();
            
            if($puffleSubtype == 0) {
                $puffleSubtype = "";
            }
            
            $penguin->buyPuffleCareItem(3, 0, 5, true); // Puffle O's
            $penguin->buyPuffleCareItem(76, 0, 1, true); // Apple
            
            $postcardId = $penguin->database->sendMail($penguin->id, "sys", 0, $puffleName, $adoptionDate, 111);
            $penguin->send("%xt%mr%-1%sys%0%111%$puffleName%$adoptionDate%$postcardId%"); 
            
            $penguin->setCoins($penguin->coins - $puffleCost);
            $penguin->send("%xt%pn%{$penguin->room->internalId}%{$penguin->coins}%$puffleId|$puffleType|$puffleSubtype|$puffleName|$adoptionDate|100|100|100|100|0|0|0|1|%");
            
            $penguin->database->updateColumnById($penguin->id, "Walking", $puffleId);
            $penguin->walkingPuffle = $penguin->database->getPuffleColumns($puffleId, array("Type", "Subtype", "Hat") );
            $penguin->walkingPuffle = array_values($penguin->walkingPuffle);
            array_unshift($penguin->walkingPuffle, $puffleId);
        }
    }

Save the file and restart your World server and it should be fixed.

You're welcome

Edited by Jamie
  • Like 4

Share this post


Link to post
Share on other sites

There was no need for an else statement since you used return on the if statement. Nice work, though...

  • Like 2

Share this post


Link to post
Share on other sites
2 hours ago, Jad said:

There was no need for an else statement since you used return on the if statement. Nice work, though...

donald-trump-shrug-1024x551.jpg

Share this post


Link to post
Share on other sites
Sign in to follow this  

×