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 06:10 PM

Will pay for this....
 
I want more excitement when clicking on pets. What I want is when you pull them from the database to show to a user for adoption, that some of them don't show up as often as the others, making them rare.

I will pay for someone to help me with this (Even Hof :P)

Serious inquiries only please.

!Alive 03-22-2012 06:30 PM

Could you explain in a more clear fashion exactly what you are trying to accomplish?
If I understand in the slightest you're wanting that when a user clicks on an adoptable they have a chance of finding/adopting an adoptable for their own. And that some of the prize adoptables are more rare to find. Right.
If this is kind of what you are wanting I may be able to help. I have a similar sort of random prize/adoptable getting system that works for me. There is just a random chance of stumbling across an adoptable just by browsing. It shouldn't be too hard to make so certain adoptables are more rare than others.

SilverDragonTears 03-22-2012 06:39 PM

Well not really, lol. But your idea may work. Can you explain your process a bit more?

!Alive 03-22-2012 06:57 PM

First I added a column to the (prefix)_adoptables table. With a numeric value, I suppose a text/varchar would work too. This number decides whether or not the adotpable is available to be found randomly. You should be able to use a differnt number for a rarity system.
Then I created a random prize php page that you are redirected to if you have found something. I modified the random secure adoption mod code from the mod section to fix what I wanted. Once I had that working a added a piece of code that randomly picks a number and if the number I choose is generated it links to the page. I have an additional variable that I added to prevent people from cheating to get the prize.
I think that's it in a nutshell. X3
So, what exactly are you trying to achieve?

SilverDragonTears 03-22-2012 07:15 PM

Well that went over my head!! lol

Ever played Dragon Cave? That's what I'm trying to do.. As you refresh the adoption page the adopts show up in threes randomly, and some of them don't pop us as often as the others....

Make better sense?

!Alive 03-22-2012 07:24 PM

Hasn't played Dragon Cave, but I think I better understand.

So on the actual page where you adopt pets from.(adopt.php) Show three random adoptables, some appearing less often than others.
That more like what you mean?

SilverDragonTears 03-22-2012 07:33 PM

Exactly what I mean :) Mine already show three at a time... but randomly... simply by using "LIMIT 3 RAND()" Doesn't help me to show some fewer times than others.

!Alive 03-22-2012 07:43 PM

Well then you could set up a column in your adoptables table for rarity. You could use numbers, text, or varchar. In numbers different rarities would be numbers like 1,2,or 3. Or with text/varchar it could actually be labeled common, uncommon, rare, ect. Then you would run a random number to select a query that would pull the rarity from the adoptable table, randomize which to choose and show it to the user. Do this for each adoptable you wish to show.

Something like that should work. I think I should go play with this to see if I can make it work for me before trying to present any code.

SilverDragonTears 03-22-2012 07:53 PM

I would love to have the code if it works!!

!Alive 03-22-2012 08:33 PM

Okay so I got the rarity thing working pretty easily. But I only have it showing one adoptable. I could have it show three but with what I have it would show three of the same rarity. I'm still trying to come up with a way to run it so that it will work with 3.

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.

!Alive 03-22-2012 10:42 PM

Alright, if I think of anything I'll let you know. X3

As for your question I get what you mean, but I am not sure how I would be able to accomplish that.

SilverDragonTears 03-22-2012 10:46 PM

Cool :) I'm so happy with this so it's totally cool! :bucktard::catfish::usedusedused:

SilverDragonTears 03-22-2012 10:58 PM

Ok one more thing :) I think this may require a cron job or something... I think I'm more new to this than you.... but how can I only have the adopts available at certain times? Maybe a few minutes every hour?

!Alive 03-22-2012 10:58 PM

I'm happy I was able to help. :smile::jay:

SilverDragonTears 03-22-2012 11:02 PM

Added one more question in for you :) Sorry, lol

!Alive 03-22-2012 11:04 PM

So you want the adoptables to only show/be available for a certain period of time? I'd have to see if I can come up with any simple ways. But in theory(in my head) it doesn't seem so hard. Though i have never done something like that.

SilverDragonTears 03-22-2012 11:09 PM

I'm thinking I could just use something like I use for an adopt on my fox site. They are called twilight foxes and the sprite changes during twilight hours. So I could do something like...

Code:


        $current_time = date(G);
        if ($current_time >= 17 && $current_time < 19){
show the adopts here
}else{
There are no dragons here.
}

Something like that? That's a little of the code from my twilight foxes so those are twilight hours...

!Alive 03-22-2012 11:15 PM

Yeah, something like that should work. With the times changed to when you want dragons to be available.

SilverDragonTears 03-23-2012 12:11 AM

Not sure how to say like >=5 && <= 5:30 lol... Ideas?

!Alive 03-23-2012 02:29 PM

I played with it for a while and finally figured out a way to make it work. X3

$current_time = date('Gi');
if ($current_time >= 500 && $current_time < 530){
show adopts here
}else{
There are no dragons here.
}

SilverDragonTears 03-23-2012 10:50 PM

I'll try that a little later. The only problem with the rarity thing is that a rare will pop up all three at the same time. A user can then just open the links in different tabs and also get as many as they want. Which is why I want each egg to be unique. Then when you click one egg it can no longer be taken(adopted).

!Alive 03-24-2012 01:29 AM

You have your adopt page set up to work differently than I have mine. I may be able figure out a solution if I see your code.
I have a few vague ideas of how this might be achieved.

SilverDragonTears 03-24-2012 01:32 AM

PHP Code:

<?php

include("functions/functions.php");
include(
"functions/functions_users.php");
include(
"functions/functions_adopts.php");
include(
"inc/lang.php");

//***************//
//  START SCRIPT //
//***************//

$id $_GET["id"];
$promocode $_GET["promocode"];
$date date("M j, Y");
// $date = "Oct 23, 2001";
$_SESSION["allow"] = 1;
// Here we check if we have an ID that has been submitted or no

if($id == "") {
    
// We did not enter in an id, or it is not a number
    
$article_title $showingtitle;

    
// If we are a guest, show a message that lets them know that they cannot adopt...
    
if($isloggedin != "yes"$article_content $article_content.$showingguest;


    
// 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);

    
    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);

    
    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>";
        }
    }

 
// End the looping out of all adoptables...
    
    
$article_content .= "</tr></table>";
// This bracket ends the IF check for whether or not an ID was entered
else{
    
// We have specified an ID of an adoptable we wish to adopt

    
$query "SELECT * FROM {$prefix}adoptables, {$prefix}adoptables_conditions 
                                                  WHERE 
{$prefix}adoptables.id='{$id}
                                                        
{$prefix}adoptables_conditions.id = {$prefix}adoptables.id";
    
$result runquery($query);
    
$row mysql_fetch_array($result);

    
$aid $row['id'];
    
$type=$row['type'];
    
$description=$row['description'];
    
$eggimage=$row['eggimage'];

    if(
$aid == $id){
        
//The adoptable exists and is valid

        
$canadopt canadopt($aid"adopting"$promocode$row); 

        if(
$canadopt == "yes"){
            
$article_title "Adopting ".$type;
            
$article_content $langa1."".$type.$langa2;


            
$article_content $article_content."<br><img src='{$eggimage}' border='0'><br>
            <form name='form1' method='get' action='doadopt.php'>
              <p>Adoptable Name: 
                <input name='name' type='text' id='name'>
                <input name='id' type='hidden' id='id' value='
{$id}'>
                <input name='promocode' type='hidden' id='promocode' value='
{$promocode}'>
              </p>
              <p>
                <input type='submit' name='Submit' value='Adopt Me'>
            </p>
            </form>"
;
        }
        else{
            
$article_title $accden;
            
$article_content $adoptnoper;
        } 
// End Can Adopt ELSE
    
}
    else {
        
//The adoptable does not exist, nothing we can do...
        
$article_title $err_idnoexist;
        
$article_content $err_idnoexist_text;
    } 
// End adoptable does not exist ELSE
// This bracket ends the else statements for whether or not an ID was entered


//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title$article_content$date);

?>


!Alive 03-24-2012 03:08 PM

Okay, since my adopting is set up different than yours I don't really have the ability to easily test this. The idea behind this code it to set a variable when the page is loaded and when one of the adoptables is clicked/adopted the value of that variable changes. And if the link is clicked a second time refresh the page so that it can't be adopted more than once.

Try this
In the functions.php add this function:
PHP Code:

function canclick()
{
if (
$clicked 0;
    {
    
$clicked 1;
    }
else {
    
header'Location: adopt.php' ) ;
}


If your adopt page has another name change the php page name.

Then change your adopt.php code to this modified version:
PHP Code:

<?php 

include("functions/functions.php"); 
include(
"functions/functions_users.php"); 
include(
"functions/functions_adopts.php"); 
include(
"inc/lang.php"); 

//***************// 
//  START SCRIPT // 
//***************// 

$id $_GET["id"]; 
$promocode $_GET["promocode"]; 
$date date("M j, Y"); 
// $date = "Oct 23, 2001"; 
$_SESSION["allow"] = 1
// Here we check if we have an ID that has been submitted or no 

$clicked 0;

if(
$id == "") { 
    
// We did not enter in an id, or it is not a number 
    
$article_title $showingtitle

    
// If we are a guest, show a message that lets them know that they cannot adopt... 
    
if($isloggedin != "yes"$article_content $article_content.$showingguest


    
// 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."' onclick='canclick()'><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); 

     
    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."'onclick='canclick()'><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); 

     
    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."'onclick='canclick()'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br> 
            
{$description}</td>"
        } 
    } 

 
// End the looping out of all adoptables... 
     
    
$article_content .= "</tr></table>"
// This bracket ends the IF check for whether or not an ID was entered 
else{ 
    
// We have specified an ID of an adoptable we wish to adopt 

    
$query "SELECT * FROM {$prefix}adoptables, {$prefix}adoptables_conditions  
                                                  WHERE 
{$prefix}adoptables.id='{$id}'  
                                                        
{$prefix}adoptables_conditions.id = {$prefix}adoptables.id"
    
$result runquery($query); 
    
$row mysql_fetch_array($result); 

    
$aid $row['id']; 
    
$type=$row['type']; 
    
$description=$row['description']; 
    
$eggimage=$row['eggimage']; 

    if(
$aid == $id){ 
        
//The adoptable exists and is valid 

        
$canadopt canadopt($aid"adopting"$promocode$row);  

        if(
$canadopt == "yes"){ 
            
$article_title "Adopting ".$type
            
$article_content $langa1."".$type.$langa2


            
$article_content $article_content."<br><img src='{$eggimage}' border='0'><br> 
            <form name='form1' method='get' action='doadopt.php'> 
              <p>Adoptable Name:  
                <input name='name' type='text' id='name'> 
                <input name='id' type='hidden' id='id' value='
{$id}'> 
                <input name='promocode' type='hidden' id='promocode' value='
{$promocode}'> 
              </p> 
              <p> 
                <input type='submit' name='Submit' value='Adopt Me'> 
            </p> 
            </form>"

        } 
        else{ 
            
$article_title $accden
            
$article_content $adoptnoper
        } 
// End Can Adopt ELSE 
    

    else { 
        
//The adoptable does not exist, nothing we can do... 
        
$article_title $err_idnoexist
        
$article_content $err_idnoexist_text
    } 
// End adoptable does not exist ELSE 
// This bracket ends the else statements for whether or not an ID was entered 


//***************// 
//  OUTPUT PAGE  // 
//***************// 

echo showpage($article_title$article_content$date); 

?>

Tell me what happens. :D
*is not sure if I did it right*

SilverDragonTears 03-24-2012 03:30 PM

I tried the function part first:

Parse error: syntax error, unexpected ';' in /home/taleofdr/public_html/functions/functions.php on line 117

!Alive 03-24-2012 03:33 PM

Nevermind I figured out what was wrong. XP

Try this
PHP Code:

function canclick()
{
if (
$clicked 0)
    {
    
$clicked 1;
    }
else {
    
header'Location: adopt.php' ) ;
}



SilverDragonTears 03-24-2012 03:41 PM

Ok I think it's working :) I clicked on an egg and then tried to click it again and it said the id was invalid which means it can only be adopted once so that's good :) But... the rare and uncommon ones that I have still show up 3 at one time.

!Alive 03-24-2012 03:47 PM

Have you assigned each adoptable with a rarity number?

SilverDragonTears 03-24-2012 03:52 PM

Yes I have 5 dragon species available right now. Two are uncommon, One is uncommon, and the other two are rare.

!Alive 03-24-2012 04:00 PM

Hmm... It just seems like an odd coincidence for multiple rare and uncommon to appear with the chances of them appearing....
I have only seen three kinds of egg in the lair. The shiny black and white, the one with two layers of scales and a colorful one. The black and white and scales one occur most often.


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.