Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Will pay for this.... (http://www.mysidiaadoptables.com/forum/showthread.php?t=3527)

SilverDragonTears 03-22-2012 08:44 PM

*waits somewhat patiently* :)

!Alive 03-22-2012 09:32 PM

I found a way to make the three adoptables have a random rarity but I am sure it is NOT the best way to do it. I just can't come up with a better way of doing it right now. :P
I can make the changes to the original adopts.php file and post it for you.
Do you know how to add a column to your adoptables table?

SilverDragonTears 03-22-2012 09:34 PM

I do :) I'll give it a try and see how it works... do you want payment for this?

!Alive 03-22-2012 09:57 PM

Okay. XD I don't need anything.

For the code below you will need to create a new column in the (prefix)_adoptables table with the name of rarity and type int(11).
Rarity values(assign to the adoptables for their rarity)
common = 0
uncommon = 1
rare = 2
ultrarare = 3

more can be added but you would have to add more statments to the code.

Find (aaround line 25):
PHP Code:

$query "SELECT * FROM ".$prefix."adoptables";
    
$result runquery($query);
    
    
$article_content .= "<form name='form1' method='get' action='doadopt.php'>
    <h3>Available Adoptables</h3><table>"
;

    while(
$row mysql_fetch_array($result)) {
        
$aid=$row['id']; //The adoptable's ID
        
$type=$row['type'];
        
$description=$row['description'];
        
$eggimage=$row['eggimage'];

        
// Call a function to check if we have the proper privledge level to adopt this pet
        
if($promocode == ""){
            
$promocode "none";
        }

        
$canadopt canadopt($aid"showing"$promocode$row); // Feed an adoptable ID and showing, to show the adopt to guests...

        
if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td><input type='radio' name='id' id='id' value='
{$aid}' /></td>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>
            <td><strong>
{$type}</strong> - {$row['cost']} {$GLOBALS['settings']['cost']}.<br />{$description}</td></tr>";
        }
    } 

Replace with:
PHP Code:

    $uncommon rand(1,50);
    
$rare rand(1,100);
    
$ultrarare rand(1,200);

    if (
$uncommon==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if (
$rare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }    
    else if (
$ultrarare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }    
    else{
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }


    
$result runquery($query);
    
    
$article_content .= "<form name='form1' method='get' action='doadopt.php'>
    <h3>Available Adoptables</h3><table>"
;

    while(
$row mysql_fetch_array($result)) {
        
$aid=$row['id']; //The adoptable's ID
        
$type=$row['type'];
        
$description=$row['description'];
        
$eggimage=$row['eggimage'];

        
// Call a function to check if we have the proper privledge level to adopt this pet
        
if($promocode == ""){
            
$promocode "none";
        }

        
$canadopt canadopt($aid"showing"$promocode$row); // Feed an adoptable ID and showing, to show the adopt to guests...

        
if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td><input type='radio' name='id' id='id' value='
{$aid}' /></td>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>
            <td><strong>
{$type}</strong> - {$row['cost']} {$GLOBALS['settings']['cost']}.<br />{$description}</td></tr>";
        }
    } 
    

    if (
$uncommon==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if (
$rare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }    
    else if (
$ultrarare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }    
    else{
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }


    
$result runquery($query);


while(
$row mysql_fetch_array($result)) {
        
$aid=$row['id']; //The adoptable's ID
        
$type=$row['type'];
        
$description=$row['description'];
        
$eggimage=$row['eggimage'];

        
// Call a function to check if we have the proper privledge level to adopt this pet
        
if($promocode == ""){
            
$promocode "none";
        }

        
$canadopt canadopt($aid"showing"$promocode$row); // Feed an adoptable ID and showing, to show the adopt to guests...

        
if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td><input type='radio' name='id' id='id' value='
{$aid}' /></td>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>
            <td><strong>
{$type}</strong> - {$row['cost']} {$GLOBALS['settings']['cost']}.<br />{$description}</td></tr>";
        }
    }

if (
$uncommon==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if (
$rare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }    
    else if (
$ultrarare==1){
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }    
    else{
    
$query "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }


    
$result runquery($query);


while(
$row mysql_fetch_array($result)) {
        
$aid=$row['id']; //The adoptable's ID
        
$type=$row['type'];
        
$description=$row['description'];
        
$eggimage=$row['eggimage'];

        
// Call a function to check if we have the proper privledge level to adopt this pet
        
if($promocode == ""){
            
$promocode "none";
        }

        
$canadopt canadopt($aid"showing"$promocode$row); // Feed an adoptable ID and showing, to show the adopt to guests...

        
if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td><input type='radio' name='id' id='id' value='
{$aid}' /></td>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>
            <td><strong>
{$type}</strong> - {$row['cost']} {$GLOBALS['settings']['cost']}.<br />{$description}</td></tr>";
        }
    } 

Oh, and if you use the admin panel to add new adoptables you will want to be sure to add the value to the insert into query when creating.

That should do it. Let me know how it works for you or if you need help. :D
*is still learning this stuff myself*

SilverDragonTears 03-22-2012 10:08 PM

Scratch that, lol... that was hard... Ok I had to pick through... is this right?

Code:


        // Begin the output of all the adoptables to the user...
    $uncommon = rand(1,50);
    $rare = rand(1,100);
    $ultrarare = rand(1,200);

    if ($uncommon==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if ($rare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }   
    else if ($ultrarare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }   
    else{
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }
        $stmt = $adopts->query($query);
       
        $article_content .= "
        <table class='adopt'><tr>";

       
        while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
                $aid=$row->id; //The adoptable's ID
                $type=$row->type;
                $description=$row->description;
                $eggimage=$row->eggimage;

                // Call a function to check if we have the proper privledge level to adopt this pet
                if($promocode == "") $promocode = "none";
                $canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...

                if($canadopt == "yes"){
                        //If we can adopt the adoptable, show the image and adoption link...
                        $article_content .= "
                        <td  VALIGN='top'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
                        {$description}</td>";
                }
        }



    if ($uncommon==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if ($rare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }   
    else if ($ultrarare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }   
    else{
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }
        $stmt = $adopts->query($query);
       
        $article_content .= "
        <table class='adopt'><tr>";

       
        while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
                $aid=$row->id; //The adoptable's ID
                $type=$row->type;
                $description=$row->description;
                $eggimage=$row->eggimage;

                // Call a function to check if we have the proper privledge level to adopt this pet
                if($promocode == "") $promocode = "none";
                $canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...

                if($canadopt == "yes"){
                        //If we can adopt the adoptable, show the image and adoption link...
                        $article_content .= "
                        <td  VALIGN='top'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
                        {$description}</td>";
                }
        }



    if ($uncommon==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
    }
    else if ($rare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
    }   
    else if ($ultrarare==1){
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
    }   
    else{
    $query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
    }
        $stmt = $adopts->query($query);
       
        $article_content .= "
        <table class='adopt'><tr>";

       
        while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
                $aid=$row->id; //The adoptable's ID
                $type=$row->type;
                $description=$row->description;
                $eggimage=$row->eggimage;

                // Call a function to check if we have the proper privledge level to adopt this pet
                if($promocode == "") $promocode = "none";
                $canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...

                if($canadopt == "yes"){
                        //If we can adopt the adoptable, show the image and adoption link...
                        $article_content .= "
                        <td  VALIGN='top'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
                        {$description}</td>";
                }
        }


SilverDragonTears 03-22-2012 10:24 PM

omg. It's working JUST like I needed it to!!! *bows to !Alive* You are amazing, my friend. How can I thank you? Seriously... I feel like I owe you... That is an amazing code.

!Alive 03-22-2012 10:25 PM

That looks like it should work with the new 1.3 version. Though I have not messed with it at all as of yet. XP But it looks like you make the changes so it should work in the 1.3 version. XD

SilverDragonTears 03-22-2012 10:26 PM

Read post above yours :)

!Alive 03-22-2012 10:29 PM

^-^ I'm glad that it works for you. *blushes* Thanks, I'm happy that I was able to help even with my limited knowledge. X3
You don't owe me anything, seriously. I don't even know what I would ask for...

SilverDragonTears 03-22-2012 10:32 PM

Ok well if you EVER need anything... please don't hesitate to ask me. On one more note, do you know how to make it so that if two users click the same adopt at the same time, only one will get it? Not sure if I explained that one clearly either.


All times are GMT -5. The time now is 07:17 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.