Mysidia Adoptables Support Forum  

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

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-27-2015, 01:27 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 137,029
Kyttias is on a distinguished road
Default

I can't fully test this, but it's worth a shot. On the 'view' version of whatever explore area, we're going to create a new function that'll post an invisible form -- all you'll see is the button. It'll be easy to call, so we're doing it with a function to save time later.

PHP Code:
public function pickupPet($species){
    
$document $this->document;
    
$document->add(new Comment("
        <form id='pickup_pet' action='explore' name='pickup_pet' method='post' role='form'>
        <input id='pet_found' name='pet_found' type='hidden' value='
{$species}'>
        <button id='acquire' value='species' name='acquire' type='submit'>
        Pick up this 
{$species}?
        </button>
        </form>
    "
FALSE));
    return;

It'll be called like this (so wherever you put this line, the button will appear):
PHP Code:
$this->pickupPet("Dezh"); // one of my species is a Dezh, for example 
When the form is submitted, it'll bounce back to this page. We want the page to do something when it detects form data has been submitted!
PHP Code:
if($mysidia->input->post("pet_found")){
    
$mysidia Registry::get("mysidia");
    
$document $this->document;
    
$species $mysidia->input->post("pet_found");
    
$this->givePet($species);
    
$document->setTitle("Pet Acquired!");            
    
$document->add(new Comment("You've collected a {$species}!.    "));    

Okay, but now need to include the function that'll actually give the pet to the user.
PHP Code:
public function givePet($species){
    
$mysidia Registry::get("mysidia");
    
$newadopt = new StockAdopt($species);
    
$newadopt->append($mysidia->user->username);
    return;

Unfortunately, I'm out the door so I can't explain better. D; Hope some of this helps!
edit: Lots of bugs I fixed when I arrived home. -u- Hope you didn't find it in the hour meanwhile. Still untested.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 12-27-2015 at 03:12 PM.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:31 PM.

Currently Active Users: 2778 (0 members and 2778 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636