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)
-   -   Random Adoption Process ? (http://www.mysidiaadoptables.com/forum/showthread.php?t=5368)

Silver_Brick 02-12-2017 01:11 PM

Random Adoption Process ?
 
I want to do random adoption process so 4 random egg will appear horizontally and user can click them to adopt them and there will be no submit button or naming option and they have chances to adopt rare egg very less...

kristhasirah 02-13-2017 12:13 PM

there's an old thread here with a code doing what you want, but you will need to edit it so it can work with the new script:
http://mysidiaadoptables.com/forum/s...ead.php?t=3527

I manage to make it work, so is not that hard ^^ you just need to add a new row in the database in the adopt_adoptables called rarity and made the changes to the code so it can appear

PHP Code:

   $adoptform "<form name='form1' method='post' action='$adopt'><table id='adoptdark' name='adopt' class='adopt'>";
    
$common 0
    
$uncommon rand(1,50);   
    
$rare rand(1,100);   
    
$ultrarare rand(1,200);
    
$legendary rand(1,300);   

    if (
$uncommon==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }   
    else if (
$rare==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }       
    else if (
$ultrarare==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }  
    else if (
$legendary==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }     
    else{   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";   
    }   
    
$stmt $mysidia->db->query($query);  
    
        while(
$row $stmt->fetchObject()) {

            
$adoptform .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></td>";
        
        }
    
    
    
$common 0
    
$uncommon rand(1,50);   
    
$rare rand(1,100);   
    
$ultrarare rand(1,200);
    
$legendary rand(1,300);   

    if (
$uncommon==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }   
    else if (
$rare==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }       
    else if (
$ultrarare==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }  
    else if (
$legendary==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }     
    else{   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";   
    }   
    
$stmt $mysidia->db->query($query);  

    while(
$row $stmt->fetchObject()) {

            
$adoptform2 .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></div></td>";

            
   } 
   
    
$common 0
    
$uncommon rand(1,50);   
    
$rare rand(1,100);   
    
$ultrarare rand(1,200);
    
$legendary rand(1,300);   

    if (
$uncommon==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }   
    else if (
$rare==&& $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }       
    else if (
$ultrarare==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }  
    else if (
$legendary==1  && $onlyone==0){   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='4' ORDER BY RAND() LIMIT 1"
$onlyone 1;   
    }     
    else{   
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";   
    }   
    
$stmt $mysidia->db->query($query);  

    while(
$row $stmt->fetchObject()) {

            
$adoptform3 .= "<td width='25%' VALIGN='center'><div align=center><img src='http://127.0.0.1/pokeupdate/picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center><strong>{$row->description}</strong></div></td>";
    }
  
   
        
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}")); 

probably is not the best way of doing it, but it works for me ^^
I have mine below the lines:
PHP Code:

            $document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);          
            
$adoptForm = new Form("form""adopt""post");
            
$adoptTitle = new Comment("Available Adoptables");
            
$adoptTitle->setHeading(3);
            
$adoptForm->add($adoptTitle);
            
$adoptTable = new Table("table"""FALSE); 

and above the lines:
PHP Code:

            $adoptForm->add($adoptTable);        
            
$adoptForm->add(new Button("Adopt Me""submit""submit"));
            
$document->add($adoptForm);
        }
    }
}
?> 

this part of the code:
PHP Code:

$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}")); 

replaces the
PHP Code:

$document->add(new Comment($adoptform)); 

cant post my full adoptview.php file because is very modified.
hope this can be use full for you^^

this code shows 3 eggs at the same time.

Silver_Brick 02-13-2017 12:42 PM

Thanks for the help :)

Chaos77777 02-19-2017 11:25 AM

Hey guys. I started using this too. But there's a big problem I can't seem to figure out. If someone were to get a really rare adopt, all they would have to do is keep refreshing to get the same one over and over again. Any way around that?

Silver_Brick 02-19-2017 12:06 PM

i thinks its random So it won't happen :)

Chaos77777 02-19-2017 01:10 PM

Doesn't seem random to me. I keep getting the same thing over and over when I refresh after I adopt one. I have it set up to cost money, so the money does reduce. But it does give me the same adopt

Abronsyth 02-19-2017 01:39 PM

You could probably work around this by setting it up so that once they adopt you quickly redirect them, which would mostly disable them from being able to refresh to just keep getting the same pet.

kristhasirah 02-19-2017 02:55 PM

you can change the value in (1,300); 1 means one adopt and 300 the amount of clicks so is 1 adopt every 300 clicks, if i remember correctly from the original thread, maybe you can change it to a bigger number?
I dint make any more changes, but i think theres was a solution for that in the original thread... you just need to edit it to make it work in the new script

no need to edit the code just paste this:
http://mysidiaadoptables.com/forum/s...5&postcount=36 in the functions.php

and $clicked = 0; in the adopt.php

i pasted mine below
$total = ($ids)?count($ids):0;

Nevermind... Dont work on a cellphone :/
But it seems to work on a computer/laptop i used firefox to test it

Chaos77777 02-19-2017 04:50 PM

I don't really know how to make a gif pic to show you what I mean. A redirect would work, but wouldn't show them the "Congrats you got this adopt" unless there's a way to show the same page in like a fake page type thing, which I don't know how to go about doing (Plus, "back" would still give them a loophole). Or a way to unset post, but I'm not really sure where to put that or how to set that up. But to recreate this (glitch):
1. Click which adopt you want.
2. Click the "Adopt me" button
3. When it shows you which adopt you got, just keep refreshing. In Chrome, it'll ask you if you want to submit form resubmission. You'll get the same one every time

kristhasirah 02-19-2017 05:47 PM

It seems the glitch is part of mysidia script..i have the default one and got that problem too... Unless i forgot and edited something... But i thik the only thing i edited was ti add kytias female male images code... Rigth now i cant test that, using my phone...still even if the glitch is caused by the code i posted i have no idea in how to fix it... Maybe theres a fix somewhere in the forum...

Chaos77777 02-19-2017 05:58 PM

I'm looking on StackExchange for different methods to kill posts. None are working for me so far though. Almost had one with using cookies, but it wouldn't let me go back to the page at all again lol

kristhasirah 02-20-2017 10:19 AM

tried on a fresh install of mysidia, and the glitch is there, for some reason is ignoring the Session and just send a confirmation code, and keeps giving you adopts, so the glitch is not part of the random code i posted

Chaos77777 02-20-2017 04:35 PM

I spent hours trying different methods to fix that. Someone who actually knows what they're doing will have to step in. But at least people will be aware of the glitch

Chaos77777 04-03-2017 11:45 PM

Bump O_o I'm really hoping someone knows how to fix this one

kristhasirah 04-04-2017 08:36 AM

add this
PHP Code:

                        $mysidia->session->terminate("adopt"); 

to the adoptsview.php before the first return;

if I dont make sense this is how it should look:
PHP Code:

            $document->addLangvar("{$name} with clicks so that they grow!");
                        
$mysidia->session->terminate("adopt");
            return;
        } 

for me this is working and trow an error if the user refresh the page =) hope this will help you too

Chaos77777 04-06-2017 01:53 PM

You are awesome, lol and such a simple code too..

kristhasirah 04-06-2017 02:24 PM

glad is woking for you too ^^

Chaos77777 04-06-2017 07:54 PM

Perhaps you can help me with one more thing. I can't see what I did wrong. I have it set up to cost 500 every time someone guesses at an adopt (with the chance to get a cheap adopt up to a rare one) It works fine up to a certain point. It'll deduct the 500 if the user has it and give the adopt. However, if the user doesn't have the 500, it'll pop up saying "Not enough money"..... but still give them the adopt lmao. I'm assuming it's a simple fix, but I can only try different ways of setting it up on my own for so many hours before I cave in and decide I need help.

PHP Code:

<?php

class AdoptView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
        if(
$mysidia->input->post("submit")){
            
            if(
$mysidia->user->money 499){
            
$aid $this->getField("aid")->getValue();
            
$name $this->getField("name")->getValue();
            
$eggImage $this->getField("eggImage")->getValue();
            
$image = new Image($eggImage);
            
$image->setLineBreak(TRUE);    
            
$mysidia->user->changecash(-500); 
            
            
$document->setTitle("{$name} adopted successfully");            
            
$document->add($image);
            
$document->addLangvar("Congratulations!  You just adopted {$name}. You can now manage {$name} on the ");
            
$document->add(new Link("myadopts""Myadopts Page."));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/manage/{$aid}""Click Here to Manage {$name}"));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/bbcode/{$aid}""Click Here to get BBCodes/HTML Codes for {$name}"));
            
$document->add(new Comment(""));
            
$document->addLangvar("Be sure and");
            
$document->add(new Link("levelup/{$aid}""feed "));
            
$document->addLangvar("{$name} with clicks so that they grow!");
            
$mysidia->session->terminate("adopt");  
            return;
            
            }
            else{
            echo 
"<script type='text/javascript'>alert('You do not have enough money!')</script>";
            }}
        
        
        
$document->setTitle($mysidia->lang->title);
        
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);          
        
$adoptForm = new Form("form""adopt""post");
        
$adoptTitle = new Comment("Available Species");
        
$adoptTitle->setHeading(3);
        
$adoptForm->add($adoptTitle);
        
$adoptTable = new Table("table"""FALSE);
         
        
        
         
     
   
    
$adoptform "<form name='form1' method='post' action='$adopt'> <table id='adoptdark' name='adopt' class='adopt'>"
    
$common 0;  
    
$uncommon rand(1,50);    
    
$rare rand(1,100);    
    
$veryrare rand(1,200); 
    
$endangered rand(1,300);    

    if (
$uncommon==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }    
    else if (
$rare==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }        
    else if (
$veryrare==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }   
    else if (
$endangered==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }      
    else{    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";    
    }    
    
$stmt $mysidia->db->query($query);   
     
        while(
$row $stmt->fetchObject()) { 

            
$adoptform .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center></td>"
         
        } 
     
     
    
$common 0;  
    
$uncommon rand(1,50);    
    
$rare rand(1,100);    
    
$veryrare rand(1,200); 
    
$endangered rand(1,300);    

    if (
$uncommon==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }    
    else if (
$rare==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }        
    else if (
$veryrare==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }   
    else if (
$endangered==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }      
    else{    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";    
    }    
    
$stmt $mysidia->db->query($query);   

    while(
$row $stmt->fetchObject()) { 

            
$adoptform2 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>"

             
   }  
    
    
$common 0;  
    
$uncommon rand(1,50);    
    
$rare rand(1,100);    
    
$veryrare rand(1,200); 
    
$endangered rand(1,300);    

    if (
$uncommon==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }    
    else if (
$rare==&& $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }        
    else if (
$veryrare==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }   
    else if (
$endangered==1  && $onlyone==0){    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";  
$onlyone 1;    
    }      
    else{    
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";    
    }    
    
$stmt $mysidia->db->query($query);   

    while(
$row $stmt->fetchObject()) { 

            
$adoptform3 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>"
        }
        
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}"));  
        
        
        
$adoptForm->add($adoptTable);        
        
$adoptSubtitle = new Comment("Adopt");
        
$adoptSubtitle->setHeading(3);
        
$adoptForm->add($adoptSubtitle);
        
$adoptForm->add(new Comment("Adoptable Name: "FALSE));
        
$adoptForm->add(new TextField("name"));
        
$adoptForm->add(new Comment(""));
        
$adoptForm->add(new Button("Adopt Me""submit""submit"));
        
$document->add($adoptForm); 
        }
}
?>


kristhasirah 04-06-2017 08:35 PM

I cant test the code rigth now but maybe this post by kyttias can help you:
http://www.mysidiaadoptables.com/for...51&postcount=6

The post is for limiting the owned eggs but i know it can help you ^^ if you move your code like the one in the post the user wont see the adopts, if you still want to show the eggs but make the user unable to adopt, you need to copy the random code and paste it in the else you dont have money, but removefrom radio to value and the newbutton adopt me, submit.
If i dont make sense and you can wait a little tomorrow i will post how i did it :)

Chaos77777 04-06-2017 08:57 PM

Yeah, I see how that works, unfortunately there's a bug around that. (I like to find odd problems with coding) If you have enough money, then open that page, it'll show the eggs. Then, in another tab, spend that money. In the first tab, you can still see the eggs, even though you don't have enough money lol then back to square one :(

kristhasirah 04-06-2017 09:43 PM

Will test the code tomorrow and see if i can help you find a way to make it work ^^ if not lets hope one of the most experienced members can help you, sadly i dont have too much experience in coding and cant help you much.

I think i found a way to make it work, dont know if you have tried this:

PHP Code:

<?php 

class AdoptView extends View
     
    public function 
index(){ 
        
$mysidia Registry::get("mysidia"); 
        
$document $this->document
        if(
$mysidia->user->money 499){ 
        echo 
"<script type='text/javascript'>alert('You do not have enough money!')</script>";
        
$mysidia->session->terminate("adopt");
        }
        else{          
        if(
$mysidia->input->post("submit")){             
            
$aid $this->getField("aid")->getValue(); 
            
$name $this->getField("name")->getValue(); 
            
$eggImage $this->getField("eggImage")->getValue(); 
            
$image = new Image($eggImage); 
            
$image->setLineBreak(TRUE);     
            
$mysidia->user->changecash(-500);  
             
            
$document->setTitle("{$name} adopted successfully");             
            
$document->add($image); 
            
$document->addLangvar("Congratulations!  You just adopted {$name}. You can now manage {$name} on the "); 
            
$document->add(new Link("myadopts""Myadopts Page.")); 
            
$document->add(new Comment("")); 
            
$document->add(new Link("myadopts/manage/{$aid}""Click Here to Manage {$name}")); 
            
$document->add(new Comment("")); 
            
$document->add(new Link("myadopts/bbcode/{$aid}""Click Here to get BBCodes/HTML Codes for {$name}")); 
            
$document->add(new Comment("")); 
            
$document->addLangvar("Be sure and"); 
            
$document->add(new Link("levelup/{$aid}""feed ")); 
            
$document->addLangvar("{$name} with clicks so that they grow!"); 
            
$mysidia->session->terminate("adopt");   
            return;             
            } 
         } 
        
$document->setTitle($mysidia->lang->title); 
        
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);           
        
$adoptForm = new Form("form""adopt""post"); 
        
$adoptTitle = new Comment("Available Species"); 
        
$adoptTitle->setHeading(3); 
        
$adoptForm->add($adoptTitle); 
        
$adoptTable = new Table("table"""FALSE); 
          
         
         
          
      
    
    
$adoptform "<form name='form1' method='post' action='$adopt'> <table id='adoptdark' name='adopt' class='adopt'>";  
    
$common 0;   
    
$uncommon rand(1,50);     
    
$rare rand(1,100);     
    
$veryrare rand(1,200);  
    
$endangered rand(1,300);     

    if (
$uncommon==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }     
    else if (
$rare==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }         
    else if (
$veryrare==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }    
    else if (
$endangered==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }       
    else{     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";     
    }     
    
$stmt $mysidia->db->query($query);    
      
        while(
$row $stmt->fetchObject()) {  

            
$adoptform .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div><div align=center></td>";  
          
        }  
      
      
    
$common 0;   
    
$uncommon rand(1,50);     
    
$rare rand(1,100);     
    
$veryrare rand(1,200);  
    
$endangered rand(1,300);     

    if (
$uncommon==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }     
    else if (
$rare==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }         
    else if (
$veryrare==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }    
    else if (
$endangered==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }       
    else{     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";     
    }     
    
$stmt $mysidia->db->query($query);    

    while(
$row $stmt->fetchObject()) {  

            
$adoptform2 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>";  

              
   }   
     
    
$common 0;   
    
$uncommon rand(1,50);     
    
$rare rand(1,100);     
    
$veryrare rand(1,200);  
    
$endangered rand(1,300);     

    if (
$uncommon==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Uncommon' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }     
    else if (
$rare==&& $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }         
    else if (
$veryrare==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Very Rare' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }    
    else if (
$endangered==1  && $onlyone==0){     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Endangered' ORDER BY RAND() LIMIT 1";   
$onlyone 1;     
    }       
    else{     
    
$query "SELECT * FROM ".constant('PREFIX'). "adoptables WHERE rarity='Common' ORDER BY RAND() LIMIT 1";     
    }     
    
$stmt $mysidia->db->query($query);    

    while(
$row $stmt->fetchObject()) {  

            
$adoptform3 .= "<td width='25%' VALIGN='center'><div align=center><img src='../../picuploads/unknownegg.png' /></div></a><br><div align=center><input type='radio' name='id' id='id' value='{$row->id}' /></div></td>";  
        } 
        
$document->add(new Comment("{$adoptform}{$adoptform2}{$adoptform3}"));   
         
         
        
$adoptForm->add($adoptTable);         
        
$adoptSubtitle = new Comment("Adopt"); 
        
$adoptSubtitle->setHeading(3); 
        
$adoptForm->add($adoptSubtitle); 
        
$adoptForm->add(new Comment("Adoptable Name: "FALSE)); 
        
$adoptForm->add(new TextField("name")); 
        
$adoptForm->add(new Comment("")); 
        
$adoptForm->add(new Button("Adopt Me""submit""submit")); 
        
$document->add($adoptForm);  
        } 

?>

what it does is when the user clicks the adopt page the message will popup, when the user click ok they can see the eggs, but if they try to adopt any of the pets it will give them the id error... dont know if this can be usefull for you... as i really dont know how you have your site set it up when the user guess the adopt.

Chaos77777 04-07-2017 07:01 PM

It actually works! It's a bit odd when it pops up that the user doesn't have enough money when they first go to the page lol, but that's just cosmetic. I'll worry about fixing that to look better some other time. For now it works right, even tried bugging around it the ways I know of, and it still works as intended. Thanks so much!

kristhasirah 04-07-2017 08:09 PM

Glad i could help you and that is close to what you where looking for ^^

Chaos77777 04-07-2017 08:23 PM

Awww, I was able to work around it. Have the page open with 500 currency, open another page and spend that money. Click over to the adopt page and adopt normally. It says "You do not have enough money" and gives you the adopt lol... Welp, back to the drawing board

kristhasirah 04-07-2017 09:19 PM

Sorry to hear that. I Dint test it that way, having 2 pages opened at the same time, i suppose is because one page still has the session opened and thats why the user can keep adopting.

KatFennec 04-26-2017 02:13 AM

I've been trying to get this working, and while it seems to be functioning acceptably, my partner wants me to see if I can replace the radio buttons with proper buttons that, once clicked, will immediately adopt the selected creature. unfortunately, I can't seem to figure out how to convert them, or failing that, create buttons to replace them.

kristhasirah 04-26-2017 08:19 AM

yes is possible i have it like that in my site:
PHP Code:

<div align=center><img src='{$row->eggimage}'style=' margin-bottom:30px;'/></div></br><div align=center><strong>{$row->description}</strong></div></div></br><div align=center><input name='id' type='hidden' id='id' value='{$row->id}'><input type='submit' name='submit' value='adopt me'></body></td

but be warned the id of the adopt can be changed with inspect element! the user can add any number and if the adopt is available they will get it
to prevent this you can add :
PHP Code:

<body oncontextmenu='return false' onkeydown=\"return false;\" onmousedown=\"return false;\"> 

to disable the right click and prevent that in a way.... but maybe you or your friend know a different way to hide or not allowing tho change the id of the adopt ^^ i can't help much in that area im still trying to figure out how to fix that with out having to do something like dragon cave or most of the sites where you adopt an already created egg... because i don't know how to code it

just to inform... this is also for the default adopt page, users can use inspect element and change the id of the of the radio button and put anything there... even the id of the adopts that are in shops and get them for free.

aquapyrofan 04-26-2017 01:05 PM

Quote:

Originally Posted by kristhasirah (Post 36216)
yes is possible i have it like that in my site:
PHP Code:

<div align=center><img src='{$row->eggimage}'style=' margin-bottom:30px;'/></div></br><div align=center><strong>{$row->description}</strong></div></div></br><div align=center><input name='id' type='hidden' id='id' value='{$row->id}'><input type='submit' name='submit' value='adopt me'></body></td

but be warned the id of the adopt can be changed with inspect element! the user can add any number and if the adopt is available they will get it
to prevent this you can add :
PHP Code:

<body oncontextmenu='return false' onkeydown=\"return false;\" onmousedown=\"return false;\"> 

to disable the right click and prevent that in a way.... but maybe you or your friend know a different way to hide or not allowing tho change the id of the adopt ^^ i can't help much in that area im still trying to figure out how to fix that with out having to do something like dragon cave or most of the sites where you adopt an already created egg... because i don't know how to code it

just to inform... this is also for the default adopt page, users can use inspect element and change the id of the of the radio button and put anything there... even the id of the adopts that are in shops and get them for free.

Those already show up in the page randomly by default, we have it set to not do that by setting their rarity to 5, but there's got to be a better way to fix it.

kristhasirah 04-26-2017 02:31 PM

add AND shop='none' after the rarity = '' for each row that way the adopts that are in a shop wont appear in there

kristhasirah 04-29-2017 11:50 AM

found a way to stop users from changing the ids and getting the adopts in the shop or any other adopt you don't want to be adopted in the main adopt page:
PHP Code:

            if($id == '11') throw new InvalidIDException("global_id"); 

to add more ids just add: || $id == 'id' (replace 'id' with the number you want to exclude.
for me this is working if the user change the id using inspect element to one of the defined ids it will trow the this id don't exist message
hope it works for everyone else.
i have mine below the first if statement in the public function index.

KatFennec 04-29-2017 10:51 PM

Quote:

Originally Posted by kristhasirah (Post 36246)
found a way to stop users from changing the ids and getting the adopts in the shop or any other adopt you don't want to be adopted in the main adopt page:
PHP Code:

            if($id == '11') throw new InvalidIDException("global_id"); 

to add more ids just add: || $id == 'id' (replace 'id' with the number you want to exclude.
for me this is working if the user change the id using inspect element to one of the defined ids it will trow the this id don't exist message
hope it works for everyone else.
i have mine below the first if statement in the public function index.

awesome, I'll probably work that in

KatFennec 05-31-2017 11:56 PM

Quote:

Originally Posted by kristhasirah (Post 35867)
there's an old thread here with a code doing what you want, but you will need to edit it so it can work with the new script:
http://mysidiaadoptables.com/forum/s...ead.php?t=3527

I manage to make it work, so is not that hard ^^ you just need to add a new row in the database in the adopt_adoptables called rarity and made the changes to the code so it can appear

PHP Code:

(snip

cant post my full adoptview.php file because is very modified.
hope this can be use full for you^^

this code shows 3 eggs at the same time.

Lately, some of my users have been reporting that they are receiving an adopt other than the one they selected. I set it up to use buttons, in case that matters.


All times are GMT -5. The time now is 08:43 AM.

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