Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #31  
Old 06-29-2014, 04:13 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 49,811
Hwona is on a distinguished road
Default

Try this:
PHP Code:
<?php

use Resource\Native\Integer;
use 
Resource\Collection\ArrayList;
use 
Resource\Utility\Curl;

class 
LevelupController extends AppController{

    const 
PARAM "aid";
    private 
$adopt;
    private 
$settings;

    public function 
__construct(){
        
parent::__construct();
        
$this->settings = new LevelSetting;
        
$mysidia Registry::get("mysidia");

        if(
$mysidia->input->action() == "click" or $mysidia->input->action() == "siggy"$this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
        if(
$mysidia->user instanceof Member){
            
$status $mysidia->user->getstatus();   
            if(
$status->canlevel == "no") throw new InvalidActionException("banned");
        }    
    }
    
    public function 
index(){
        throw new 
InvalidActionException("global_action");
    }
    
    public function 
click(){
        
$mysidia Registry::get("mysidia");
        
$date = new DateTime;
        
$ip secure($_SERVER['REMOTE_ADDR']);
        
$statname rand(0,100) ;

        if(
$this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif(
$this->adopt->hasVoter($mysidia->user$date)){





            
$message "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


            throw new 
LevelupException($message);        
        }
        




        
          
$message $message .= "
<div id='stats'>
Statname: 
{$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted."
;
        elseif(
$this->adopt->isFrozen() == "yes") throw new LevelupException($message);
        elseif(
$mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif(
$this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
             throw new 
LevelupException("owner");               
        }
        else{
          
$message $message .= "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";  
            
$newClicks $this->adopt->getTotalClicks() + 1;
            
$this->adopt->setTotalClicks($newClicks"update");
            
$mysidia->db->insert("vote_voters", array("void" => NULL"date" => $date->format('Y-m-d'), "username" => $mysidia->user->username"ip" => $ip"adoptableid" => $mysidia->input->get("aid")));         
            
            if(
$this->adopt->hasNextLevel()){
                
$nextLevel $this->adopt->getNextLevel();
                
$requiredClicks $nextLevel->getRequiredClicks();
                if(
$requiredClicks and $newClicks >= $requiredClicks$this->adopt->setCurrentLevel($nextLevel->getLevel(), "update");
            }
            
            
$reward $mysidia->user->clickreward($this->settings->reward);
            
$mysidia->user->changecash($reward);            
            
$this->setField("adopt"$this->adopt);
            
$this->setField("reward", new Integer($reward));
            throw new 
LevelupException($message);
        }
    }

    public function 
siggy(){
        
$mysidia Registry::get("mysidia");
        
// The adoptable is available, let's collect its info
        
$usingimage "no";
        
$image $this->adopt->getImage(); 
      
        
$usegd $mysidia->settings->gdimages;
        
$imageinfo = @getimagesize($image);
        
$imagemime $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

        
if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
            
$usingimage "yes"//Turn the template system off
            
$type $this->adopt->getType();
            list(
$width$height$type$attr) = getimagesize($image); // The size of the original adoptable image

            // Lets create the new target image, with a size big enough for the text for the adoptable
            
$newheight $height 72;
            
$newwidth = ($newwidth 250)?250:$width;
            
$img_temp imagecreatetruecolor($newwidth$newheight); 
            
$alphablending true;  
         
            
// Lets create the image and save its transparency  
            
$img_old = @imagecreatefromgif($image);  
            
imagealphablending($img_oldtrue);  
            
imagesavealpha($img_oldtrue);
   
            
// Lets copy the old image into the new image with  
            
ImageCopyResampled($img_temp$img_old0000$width$height$width$height);    
            
$textheight $width 2;
            
$image $img_temp;
            
$bgi imagecreatetruecolor($newwidth$newheight);
            
$color imagecolorallocate($bgi515151);
         
            
// Build text for siggy
            
$str1 "Name: ".$this->adopt->getName();
            
$str2 "Owner: ".$this->adopt->getOwner();
            
$str3 "Click Here to Boost Me!";
            
$str4 "More Pets at:";
            
$str5 "www.".constant("DOMAIN");

            
// Renger Image
            
imagestring ($image120$textheight,  $str1$color);
            
imagestring ($image120$textheight 13,  $str2$color);
            
imagestring ($image120$textheight 26,  $str3$color);
            
imagestring ($image120$textheight 42,  $str4$color);
            
imagestring ($image120$textheight 55,  $str5$color);
            
$background imagecolorallocate($image000);  
            
ImageColorTransparent($image$background);  
 
            
// At the very last, let's clean up temporary files
            
header("Content-Type: image/GIF");
            
ImageGif ($image);
            
imagedestroy($image);
            
imagedestroy($img_temp);
            
imagedestroy($img_old);
            
imagedestroy($bgi);

        }
        else{      
                
// We are going to try and get this image the old fashioned way...
            
$extList = array();
            
$extList['gif'] = 'image/gif';
            
$extList['jpg'] = 'image/jpeg';
            
$extList['jpeg'] = 'image/jpeg';
            
$extList['png'] = 'image/png';

            
//Define the output file type
            
$contentType 'Content-type: '.$extList$imageinfo['extension'] ];

            if(
$imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){             
                throw new 
InvalidIDException("The file Extension is not allowed!");
            }
            else{
                
// File type is allowed, so proceed
                
$status "";
                
header($contentType);
                
$curl = new Curl($image);
                
$curl->setHeader();
                
$curl->exec();
                
$curl->close();
            } 
        }
    }
    
    public function 
daycare(){        
        
$daycare = new Daycare;
        
$adopts $daycare->getAdopts();
        
$this->setField("daycare"$daycare);
    }
}
?>
__________________
Reply With Quote
  #32  
Old 06-29-2014, 04:17 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 55,205
Missy Master is an unknown quantity at this point
Default

Not working for me still ... anyone else want to try this on a 1.3.4 site?

I really can't imagine what's wrong!
Reply With Quote
  #33  
Old 06-29-2014, 04:29 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 49,811
Hwona is on a distinguished road
Default

Does v.1.3.4 have the comment() function?
__________________
Reply With Quote
  #34  
Old 06-29-2014, 04:45 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 55,205
Missy Master is an unknown quantity at this point
Default

I'm not sure .. ah, and shop is giving the same error as adopt and breeding were.



I have uploaded the 1.3.4 shop file, if you have time you can alter that when you are able.

We're getting there, I'm anxious to get this all working because it's fantastic!!


I'm already working on a mod for the mod, to have the mother and father stats combine to be inherited!
Attached Files
File Type: php shop.php (2.7 KB, 2 views)
Reply With Quote
  #35  
Old 06-29-2014, 06:32 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 49,811
Hwona is on a distinguished road
Default

Try this code:
PHP Code:
<?php

use Resource\Native\Integer;

class 
ShopController extends AppController{

    const 
PARAM "shop";

    public function 
__construct(){
        
parent::__construct("member");    
        
$mysidia Registry::get("mysidia");        
        
$mysidia->user->getstatus();
        if(
$mysidia->user->status->canshop == "no"){
            throw new 
NoPermissionException($mysidia->lang->denied);
        }
        if(
$mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
            throw new 
InvalidIDException($mysidia->lang->global_id);
        }
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$shopList = new Shoplist($mysidia->input->post("shoptype"));
        if(
$shopList->gettotal() == 0) throw new InvalidIDException("none");
        
$this->setField("shopList"$shopList);
    }
    
    public function 
browse(){
        
$mysidia Registry::get("mysidia");        
        
$shoptype $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        
$shoplist = new Shoplist($shoptype);
        
$shop $shoplist->createshop($mysidia->input->get("shop"));
        
$this->setField("shop"$shop);
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
        
        if(
$mysidia->input->post("shoptype") == "itemshop"$this->purchaseItem();
        
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"$this->purchaseAdopt();
        
        
        
        
        
        
        
        else throw new 
InvalidActionException($mysidia->lang->global_action);
    }
    
    private function 
purchaseItem(){
        
$mysidia Registry::get("mysidia");        
        
$shop = new Itemshop($mysidia->input->get("shop"));
        
$item $shop->getitem($mysidia->input->post("itemname"));
        
$item->assign($mysidia->user->username);
        
$oldquantity $item->getoldquantity();
        
$newquantity $oldquantity $mysidia->input->post("quantity");
            
        if(!
is_numeric($mysidia->input->post("quantity"))){
            throw new 
InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif(
$newquantity $item->cap){
            throw new 
InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
            
$shop->purchase($item);
            
$this->setField("cost", new Integer($item->getcost($shop->salestax)));
        }        
    }
    
    private function 
purchaseAdopt(){
        
$mysidia Registry::get("mysidia");
        
$shop = new Adoptshop($mysidia->input->get("shop"));
        
$adopt $shop->getadopt($mysidia->input->post("adopttype"));
        
$statname rand(minimum value,maximum value) ;
        
$adopt->assign($mysidia->user->username);            
        
$shop->purchase($adopt);
        
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");  
        
$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));        
    }
}
?>
Also, the breeding sounds great, but if you're going to implement the training and award system I have on my site, you'll also have to limit the number of training items that can be used on an adopt.
__________________
Reply With Quote
  #36  
Old 06-29-2014, 07:14 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 55,205
Missy Master is an unknown quantity at this point
Default

Aww this one didn't work ... and yeah very true, I'll have to change some of the item amounts allowed.
Reply With Quote
  #37  
Old 06-29-2014, 08:01 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 49,811
Hwona is on a distinguished road
Default

Sorry about that - my mistake!
PHP Code:
<?php

use Resource\Native\Integer;

class 
ShopController extends AppController{

    const 
PARAM "shop";

    public function 
__construct(){
        
parent::__construct("member");    
        
$mysidia Registry::get("mysidia");        
        
$mysidia->user->getstatus();
        if(
$mysidia->user->status->canshop == "no"){
            throw new 
NoPermissionException($mysidia->lang->denied);
        }
        if(
$mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
            throw new 
InvalidIDException($mysidia->lang->global_id);
        }
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$shopList = new Shoplist($mysidia->input->post("shoptype"));
        if(
$shopList->gettotal() == 0) throw new InvalidIDException("none");
        
$this->setField("shopList"$shopList);
    }
    
    public function 
browse(){
        
$mysidia Registry::get("mysidia");        
        
$shoptype $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        
$shoplist = new Shoplist($shoptype);
        
$shop $shoplist->createshop($mysidia->input->get("shop"));
        
$this->setField("shop"$shop);
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
        
        if(
$mysidia->input->post("shoptype") == "itemshop"$this->purchaseItem();
        
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"$this->purchaseAdopt();
        
        
        
        
        
        
        
        else throw new 
InvalidActionException($mysidia->lang->global_action);
    }
    
    private function 
purchaseItem(){
        
$mysidia Registry::get("mysidia");        
        
$shop = new Itemshop($mysidia->input->get("shop"));
        
$item $shop->getitem($mysidia->input->post("itemname"));
        
$item->assign($mysidia->user->username);
        
$oldquantity $item->getoldquantity();
        
$newquantity $oldquantity $mysidia->input->post("quantity");
            
        if(!
is_numeric($mysidia->input->post("quantity"))){
            throw new 
InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif(
$newquantity $item->cap){
            throw new 
InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
            
$shop->purchase($item);
            
$this->setField("cost", new Integer($item->getcost($shop->salestax)));
        }        
    }
    
    private function 
purchaseAdopt(){
        
$mysidia Registry::get("mysidia");
        
$shop = new Adoptshop($mysidia->input->get("shop"));
        
$adopt $shop->getadopt($mysidia->input->post("adopttype"));
        
$statname rand(0,100) ;
        
$adoptid $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1;
        
$adopt->assign($mysidia->user->username);            
        
$shop->purchase($adopt);
        
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $adoptid");  
        
$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));        
    }
}
?>
Try this. :3
__________________
Reply With Quote
  #38  
Old 06-29-2014, 08:24 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 55,205
Missy Master is an unknown quantity at this point
Default

Heeeeey ! Looks like you got it!! YAY!! Thank you!!

If you're able to get Levelup going, I'll test that out ...just let me know. And thank you for all your work on this!
Reply With Quote
  #39  
Old 06-29-2014, 08:54 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 49,811
Hwona is on a distinguished road
Default

Hmm, all I need to know is whether or not the comment function would work... either that or, I need to check some v.1.3.4 files.
__________________
Reply With Quote
  #40  
Old 06-29-2014, 08:59 PM
Missy Master's Avatar
Missy Master Missy Master is offline
Pet-Sim.Online
 
Join Date: Jan 2010
Posts: 475
Gender: Unknown/Other
Credits: 55,205
Missy Master is an unknown quantity at this point
Default

HOF ? You know this PHP far better than I ...what say you ? :)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trade System Kyttias Questions and Supports 4 05-29-2016 12:29 AM
Making v.1.3.3 Stat Mod Compatible with V.1.3.4 Hwona Questions and Supports 0 07-08-2014 01:37 PM
Stat Inheritance Mod * thanks to Wallie! * Missy Master Mys v1.3.x Mods 0 06-30-2014 02:23 PM
Anyone Want to Have a Stat System Hwona Feedback and Suggestions 12 06-30-2014 09:30 AM
Basic Stat System Hedgen Questions and Supports 3 03-10-2013 02:47 PM


All times are GMT -5. The time now is 08:40 AM.

Currently Active Users: 821 (0 members and 821 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636