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-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 02:41 AM.

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