Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-05-2016, 02:38 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 129,412
Kyttias is on a distinguished road
Default

Okay that code is from a much, much older version of Mysidia and shouldn't be referenced and use cannot be made of it. Some of those include files don't even exist anymore.

You should read this guide on making custom pages and it should cover everything you need. Please do read through it all before continuing down this post, or at least reread this post after you've read everything there.

To be specific, and this is covered, you'll need to add a column to a table in your database. Now, depending on the amount of things like this you want to, I'd suggest making a table just to hold data on this. But if it's only going to be a few things, you can always just add a column to the end of the 'adopts_users' table in your database to hold a time reference.

In the examples in the link I gave, we add a column 'lastday' and use it to check time. (Logically, if you're going to have more than one sort of time-based event, you'll need many more intuitively-named columns because they can't all share one.)

Say your page is "/awesomepage".

You will need to make awesomepage.php -
PHP Code:
<?php
class AwesomePageController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
    }
    
}
?>
And then view/awesomepageview.php (so that's inside the view folder) -
PHP Code:
<?php
class AwesomePage extends View{

    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;        
        
$document->setTitle("Super Awesome Page");    
        if (
strtotime($mysidia->user->lastday) < strtotime("-30 days")) {
            
$document->add(new Comment("It has been at least 30 days since your last visit!"FALSE));
            
// Give User Item
            
$item "Cupcake";
            
$qty 1;
            
$newitem = new StockItem($item);
            
$newitem->append($qty$mysidia->user->username);  
            
// Reset Timestamp
            
$now = new DateTime();
            
$today $now->format('Y-m-d');
            
$mysidia->db->update("users", array("lastday" => $today), "username = '{$mysidia->user->username}'");
        } else {
            
$daysleft strtotime($mysidia->user->lastday);
            
$document->add(new Comment("We're sorry, 30 days have not yet passed! Please wait {$daysleft} more days!"FALSE));
        }  
    }
    
}
?>
So long as you've added the column to the database, this should just automatically work. However, it leaves very little room for testing since it will automatically attempt to give the item "Cupcake" and then any visits for the next 30 days should be prevented. You can "comment out" php code to temporarily disable it by wrapping it in /* These */, starting a line with //, and/or starting a line with #.

I super recommend you obtain a nice text editor with syntax highlighting such as Notepad++ or Sublime Text, as it makes coding much easier on the eyes and you can easily see at a glance where things are breaking because the colors will mess up.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-05-2016 at 02:54 AM.
Reply With Quote
 


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


All times are GMT -5. The time now is 04:47 PM.

Currently Active Users: 3690 (0 members and 3690 guests)
Threads: 4,081, Posts: 32,032, 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 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636