Thread: Mys 1.3.4 Simple NPC Battle
View Single Post
  #20  
Old 12-10-2016, 08:10 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 113,602
Abronsyth is on a distinguished road
Default

1. In the battleview.php file find this:
PHP Code:
 /*Random Opponent Stats*/ 
        
$opsense rand(1,100); 
        
$opstamina rand(1,100); 
        
$opstrength rand(1,100); 
        
$opspeed rand(1,100); 
Insert the image code right below that, so it looks like this:
PHP Code:
 /*Random Opponent Stats*/ 
$opsense rand(1,100); 
$opstamina rand(1,100); 
$opstrength rand(1,100); 
$opspeed rand(1,100); 
$images rand(1,3);  
if(
$images 1) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 2) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 3) {
$opimage "<img src='IMAGE URL'/>";

The image url needs to start with http:// and end in .jpg, .jpeg, .png, or .gif

2. You put the calling code wherever you want to display the trophies. So if you want to display it for the owner of a pet when they go to manage it, you can go to myadoptsview.php and add it within the manage function. This works best if you already have "profiles" set up. But for a quick example, here is the manage function with it added in:
PHP Code:
    public function manage(){
        
$mysidia Registry::get("mysidia");
        
$aid $this->getField("aid")->getValue();
        
$name $this->getField("name")->getValue();
        
$image $this->getField("image");

        
$trophies $mysidia->db->select("owned_adoptables", array("trophies"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();

        
$document $this->document;        
        
$document->setTitle("Managing {$name}");
        
$document->add($image);
        
$document->add(new Comment("<br><br>This page allows you to manage {$name}.  Click on an option below to change settings.<br>
<center>
{$name} has {$trophies} trophies!</center><br>"));
        
        
$document->add(new Image("templates/icons/add.gif"));
        
$document->add(new Link("levelup/click/{$aid}"" Level Up {$name}"TRUE));
        
$document->add(new Image("templates/icons/stats.gif"));
        
$document->add(new Link("myadopts/stats/{$aid}"" Get Stats for {$name}"TRUE));
        
$document->add(new Image("templates/icons/bbcodes.gif"));
        
$document->add(new Link("myadopts/bbcode/{$aid}"" Get BBCodes / HTML Codes for {$name}"TRUE));
           
$document->add(new Image("templates/icons/title.gif"));
        
$document->add(new Link("myadopts/rename/{$aid}"" Rename {$name}"TRUE)); 
        
$document->add(new Image("templates/icons/trade.gif"));
        
$document->add(new Link("myadopts/trade/{$aid}"" Change Trade status for {$name}"TRUE)); 
        
$document->add(new Image("templates/icons/freeze.gif"));
        
$document->add(new Link("myadopts/freeze/{$aid}"" Freeze or Unfreeze {$name}"TRUE)); 
        
$document->add(new Image("templates/icons/delete.gif"));
        
$document->add(new Link("pound/pound/{$aid}"" Pound {$name}"TRUE)); 
    } 
3. The base code for displaying it is this:
PHP Code:
<img src='{$favpet->getImage()}'/> 
But you also need to include this information to make it callable:
PHP Code:
$profile $mysidia->user->getprofile();
$favpet = new OwnedAdoptable($profile->getFavpetID()); 
As for flipping, not sure, I googled it and apparently this works (I have not tested it):
PHP Code:
$opimage "<img src='IMAGE URL' style='-moz-transform: scale(-1, 1);-webkit-transform: scale(-1, 1);-o-transform: scale(-1, 1);transform: scale(-1, 1);filter: FlipH;' />"
4. To directly insert an item into a user's inventory you use this string:
PHP Code:
$item "ItemName"
PHP Code:
$newitem = new StockItem($item);  
$newitem->append(1$mysidia->user->username); 
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote