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
  #21  
Old 01-15-2017, 07:05 PM
ffsharriet ffsharriet is offline
Member
 
Join Date: Jan 2017
Posts: 22
Gender: Female
Credits: 4,867
ffsharriet is on a distinguished road
Default

Can items be used to increase health or mood?
Reply With Quote
  #22  
Old 01-15-2017, 07:20 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

It's definitely possible, but I've never attempted it so I don't know the code.
__________________
Reply With Quote
  #23  
Old 01-21-2017, 03:17 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

Still need help with scheduled tasks to make the bars go down, since I'm still lost on what to do.
__________________
Reply With Quote
  #24  
Old 01-21-2017, 06:03 PM
IntoRain's Avatar
IntoRain IntoRain is offline
Moderator
 
Join Date: Jul 2013
Location: Portugal
Posts: 461
Gender: Female
Credits: 21,220
IntoRain is on a distinguished road
Default

If your host allows cronjobs, you can just have a page with the tasks you want to perform and set it up through the cpanel ("I want this function from this file to run every day").

All the automatic tasks I've set up are basically like this:

PHP Code:
class CronController extends AppController{

    public function 
__construct(){

    }
    
    public function 
index(){

    }
    
    public function 
resetNotifs() {
        
$mysidia Registry::get("mysidia");
        
$mysidia->db->delete("notifications""Isread = '1'");
    }
    
    public function 
resetClicks() {
        
$mysidia Registry::get("mysidia");
        
$now = new DateTime();
        
$mysidia->db->delete("vote_voters""date != '{$now->format('Y-m-d')}'");
    }
    
    public function 
resetBiomes() {
        
$mysidia Registry::get("mysidia");
        
$mysidia->db->delete("generatedadoptables""1");
    }
    

But this depends on if your host allows cronjobs.

To do it like HoF is saying, you can create a class file for each task you want. For example ResetClicksTask, LowerMoodTask, ... (which can extend a class Task, if you want inheritance)
Each task class has a function like executeTask() that does what you want. In this case it would be like

PHP Code:
class ResetClicksTask extends Model//or extends Task
    
       
public function __construct(){
       }

    public function 
executeTask() {
        
$mysidia Registry::get("mysidia");
        
$now = new DateTime();
        
$mysidia->db->delete("vote_voters""date != '{$now->format('Y-m-d')}'");
    }
    

Then from the index.php file, you can create a function that checks if any task from the database can run, like

PHP Code:
$mysidia Registry::get("mysidia");
$tasks $mysidia->db->select("tasks", array("id""name""executiontime""waittime"), "...");

while(
$task $tasks->fetchObject()) {
        if(
$currenttime >= $task->executiontime) {
              
$taskName $task->name "Task"//so it looks like ResetClicksTask
              
$taskToRun = new $taskName();
              
$taskToRun->executeTask();//run the execute function
              //update the next exe time
              
$newexetime $task->executiontime $task->waittime;
              
$mysidia->db->update("tasks", array("executiontime" => $newexetime), "id = '{$task->id}'");
        }


So when anyone visits the index, the function calls all the tasks that need to run.
__________________


asp.net stole my soul.
Reply With Quote
  #25  
Old 01-21-2017, 06:10 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

Thank you! I'll have to try it out right now. I'm using mysidiahost, so it allows cronjobs.
__________________
Reply With Quote
  #26  
Old 01-21-2017, 06:57 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

Okay, so this is what I have in cron.php within the root folder:
PHP Code:
class CronController extends AppController{

    public function 
__construct(){

    }
    
    public function 
index(){

    }
    
    public function 
lowerMood() {
        
$mysidia Registry::get("mysidia");
        
$mysidia->db->update("owned_adoptables", array("mood" => -10));
    }
    
    public function 
lowerHealth() {
        
$mysidia Registry::get("mysidia");
        
$mysidia->db->update("owned_adoptables", array("health" => -10));
    }
    

And this is what my cronjob command is:
Quote:
php -f /home/adopttes/public_html/cron.php
I'm not sure if my command or setup is correct though, since it doesn't work.
__________________

Last edited by Dinocanid; 01-22-2017 at 02:53 PM.
Reply With Quote
  #27  
Old 04-02-2017, 04:50 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

I added a section for having the needs to go down every day.
__________________
Reply With Quote
  #28  
Old 04-15-2017, 10:43 AM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 81,135
Dinocanid is on a distinguished road
Default

As a better alternative to my method above, would it be possible to have something like mySQL events? They're said to be able to be an alternative to cronjobs and I have seen options for this in phpMyAdmin, but I've never touched them. I'll try it and see how it works out.

EDIT: Nevermind, you would need super privileges in mySQL to make schedules (basically add permission), which I can't find a way to do.
__________________

Last edited by Dinocanid; 04-19-2017 at 04:59 PM.
Reply With Quote
  #29  
Old 04-28-2017, 05:16 AM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 9,811
KatFennec is on a distinguished road
Default

Just a heads up, if you haven't already done it for another mod et cetera, you'll need to define $adopt in public function manage. Copying it from the function above it seems to be enough.
__________________
Reply With Quote
  #30  
Old 05-03-2017, 12:54 AM
KatFennec's Avatar
KatFennec KatFennec is offline
Member
 
Join Date: Apr 2017
Posts: 57
Gender: Female
Credits: 9,811
KatFennec is on a distinguished road
Default

I can't seem to get the provided method for changing the health to work. It's all set in class_ownedadoptables, although I'm trying to do this outside the manage page.
EDIT: Never mind. I dug through my files and it turned out to be a typo in what I was using to track health.
__________________

Last edited by KatFennec; 05-03-2017 at 01:34 AM.
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


All times are GMT -5. The time now is 11:46 AM.

Currently Active Users: 644 (0 members and 644 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 - 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