Mysidia Adoptables Support Forum  

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

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2016, 10:26 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,452
SilverDragonTears is on a distinguished road
Default Choose 3 random adopts...

I want to choose 3 random adopts at a time and show them in a single row. I had this on my old site but can't quite figure it out with this new coding.
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 03-05-2016, 10:14 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,543
Kyttias is on a distinguished road
Default

I made a mod that allows for a more customizable index page (rather than using the AdminCP), and it will allow you to use PHP. In the mod I also included example code for displaying five random pets. Check it out!

The exact code snippet for the random pets is this:
PHP Code:
$document->add(new Comment("<div class='row'><h4>Random 5 Pets</h4>"FALSE));
        
$stat_rand5 $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY RAND() DESC LIMIT 5");        
        while(
$aid $stat_rand5->fetchColumn()){
            
$adopt = new OwnedAdoptable($aid);    
            
$document->add(new Comment("
                <div style='display: inline-table; text-align: center;'>
                <a href='levelup/click/
{$adopt->getAdoptID()}'><img src='{$adopt->getImage()}'></a></br>
                  <a href='levelup/click/
{$adopt->getAdoptID()}'><b>{$adopt->getName()}</b></a> the <small><b>LVL.</b> {$adopt->getCurrentLevel()}</small> {$adopt->getType()}</div>
              "
FALSE));
        }
        
$document->add(new Comment("</div>"FALSE)); 
If you want three instead of five, all you have to do is edit "1 ORDER BY RAND() DESC LIMIT 5" to "1 ORDER BY RAND() DESC LIMIT 3".
__________________
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.
Reply With Quote
  #3  
Old 03-05-2016, 01:05 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,452
SilverDragonTears is on a distinguished road
Default

I meant on the adopt a (dragon) page.
__________________

Check out SilvaTales
Reply With Quote
  #4  
Old 03-05-2016, 02:39 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 49,711
tahbikat is on a distinguished road
Default

@Kyttias I think she means something similar to Dragon Cave, where 3 random eggs are shown on the adopts page and if a user clicks it before another user they get the egg.


@Birdie I don't think there's a mod here for that yet but good luck!
Reply With Quote
  #5  
Old 03-05-2016, 03:20 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 88,543
Kyttias is on a distinguished road
Default

Oh... hmmm! That's done on Pokéfarm, too...

So let's see... three eggs, when one is taken three things should be done:
  • See if that egg is still available (by checking against timestamp), if true, continue.
  • Store a 'claimed' timestamp when the egg is successfully picked up.
  • Reshuffle the eggs (include the two unclaimed and add a random third).

The three random eggs are shuffled server-side and stored in the database. When the page loads, it'll access the database and pull up the shuffled set of eggs with the most recent 'creation' timestamp. The data will also be stored with a 'claimed' timestamp, which will be filled moments before a new row is created upon a new shuffle.

Two other things to consider:

We don't want to store an infinite number of shuffled egg sets in the database, so to save on database space will will also look for the row with the oldest 'claimed' timestamp and remove it while creating a new one.

We also don't necessary want eggs to stagnate. Considerations will have to be made about that. Ordinarily we'd want the two eggs that weren't claimed to stay there for the next refresh... but what if we want to force these eggs to change? I think a good time to do this would be test how long it's been since that egg set was created. If it took more than an hour for one of the three to be claimed, randomize all three eggs going into the next draw.

Is this all heading in the right direction?
__________________
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.
Reply With Quote
  #6  
Old 03-05-2016, 08:42 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,452
SilverDragonTears is on a distinguished road
Default

I was using a very old script from Mys/ my site was well established and I already had the code for this. But I don't know how to read this newer stuff and I taught myself php so I'm not that great with reading new code or understanding it :(
__________________

Check out SilvaTales
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 05:15 PM.

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