Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.1.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-24-2009, 10:56 AM
bokkun bokkun is offline
Premium Member
 
Join Date: Dec 2009
Posts: 8
Gender: Male
Credits: 4,692
bokkun
Default Abandon system

Hey, I'm bokkun and...
let's me skip the introduction for now and give what you came for.
In dragon cave you can abandon your dragons and have someone else adopt it, instead of killing them, It looked me interesting to have such a system to save those poor virtual lifes ;)
I am not a great php programmer however, I tried my best, and accept critic.
The script is supposed to remove the kill ability, but it's possible to simply have both.

first of all, we need a new table in the database to save our abandoned adoptables:
Code:
CREATE TABLE IF NOT EXISTS `adopts_abandoned` (
  `aid` int(11) NOT NULL auto_increment,
  `type` varchar(40) default NULL,
  `name` varchar(40) default NULL,
  `owner` varchar(40) default NULL,
  `currentlevel` int(11) default NULL,
  `totalclicks` int(11) default NULL,
  `code` int(11) default NULL,
  `imageurl` varchar(120) default NULL,
  `usealternates` varchar(10) default NULL,
  `tradestatus` varchar(15) default NULL,
  `isfrozen` varchar(10) default NULL,
  `date` varchar(30) default NULL,
  PRIMARY KEY  (`aid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
It's pretty much a copy of the owned table, but with an additional field date

now, put the creature in there, open myadopt.php
and look for $act == "kill"
scroll a bit down till you find
PHP Code:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$isfrozen=@mysql_result($result,$i,"isfrozen"); 
since we need way more data,replace it with:
PHP Code:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$owner=@mysql_result($result,$i,"owner");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$code=@mysql_result($result,$i,"code");
$usealternates=@mysql_result($result,$i,"usealternates");
$tradestatus=@mysql_result($result,$i,"tradestatus");
$date=time('U'); 
scroll down till you find $query = "DELETE FROM ".$prefix."owned_adoptables WHERE aid='$id' and owner='$loggedinname'";
this is where it gets removed, but we don't want that, replace with
PHP Code:
mysql_query("INSERT INTO ".$prefix."abandoned VALUES ('$aid', '$type', '$name','$owner', '$currentlevel', '$totalclicks', '$code', '', '$usealternates', '$tradestatus', '$isfrozen', '$date')");
mysql_query("DELETE FROM ".$prefix."owned_adoptables WHERE aid='$id' and owner='$loggedinname'"); 
change the text a bit to fit the abandon process(as well in myadopts.php as in lang.php)
and that's it... ow wait where can we find our creatures? and don't forget you have to be able to adopt them
There are 2 attachments included, abandon.php(is like adopt.php but for the abandoned pets) and doadoptab.php(like doadopt.php to adopt our abandoned friend.)

abandon.php uses
$article_title = $ashowingtitle;
$article_content = $ashowing;
don't forget to put that in your lang.php,
and neither should you forget to add the link

another think in abandon.php is that it checks if the creature has been there for more than 2 weeks, if so it gets removed, forever!
to change that look for $decay=time() - 14 * 24 * 60 * 60;
and change 14 * 24 * 60 * 60 to fit your needs(14 is more or less how many days it are)
to remove the auto-delete thing, you can remove the
if($date < $decay){ //check if the creature is too the abandoned database
//yes it is, time to remove it
$removed="yes";
mysql_query("DELETE FROM ".$prefix."abandoned WHERE aid='$aid' and name='$name'");
}


I forgot to say abandon uses an edited function script
simply add this at the end of function.php, else you can't see the pet image
PHP Code:
function getabandonedimage($id){

// This function determines which image we should use for a given adoptable...

include("config.php"); // This is so we can use the table prefix

$image "";

// First we select the adoptable from the database and get some basic information...

$query "SELECT * FROM ".$prefix."abandoned WHERE aid='$id'";
$result mysql_query($query);
$num mysql_numrows($result);

//Loop out code
$i=0;
while (
$i 1) {

$type=@mysql_result($result,$i,"type"); 
$currentlevel=@mysql_result($result,$i,"currentlevel"); 
$imageurl=@mysql_result($result,$i,"imageurl");
$usealternates=@mysql_result($result,$i,"usealternates");


$i++;
}

if(
$imageurl != ""){

// If we are using a custom image for this adoptable, use that
$image $imageurl;

}
else{

// We have to dig this up ourselves...
// Check if we are using an egg image or a level image...

    
if($currentlevel == or $currentlevel == "0"){

    
// Let's see what the egg image is...    

    
$query "SELECT * FROM ".$prefix."adoptables WHERE type='$type'";
    
$result mysql_query($query);
    
$num mysql_numrows($result);

    
//Loop out code
    
$i=0;
    while (
$i 1) {

    
$eggimage=@mysql_result($result,$i,"eggimage"); 


    
$i++;
    }

    
$image $eggimage// Set the image URL equal to the egg image...

    
}
    else{

    
// We have to find out what level we are using...
    // Then we can choose the appropriate image for what we are using...

        
$query "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'";
        
$result mysql_query($query);
        
$num mysql_numrows($result);

        
//Loop out code
        
$i=0;
        while (
$i 1) {

        
$primaryimage=@mysql_result($result,$i,"primaryimage"); 
        
$alternateimage=@mysql_result($result,$i,"alternateimage");


        
$i++;
        }

        
// If alternate images are enabled and an alternate image exists, use it

        
if($usealternates == "yes" and $alternateimage != ""){

        
$image $alternateimage// Use the alternate image

        
}
        else{

        
$image $primaryimage// Set the image equal to the primary image for the level

        
}
    


    }

}

if(
$type == "" or $image == ""){
// We did not settle on an image, so we show an error image...

$image "http://".$domain."".$scriptpath."/templates/icons/delete.gif";

}

return 
$image;

}

function 
canadoptab($aid$cond$promocode){

include(
"config.php");

// This function determines if a user can adopt a specific adoptable...

$canadopt "yes"// The default status is that we CAN adopt, unless proven false...

// The first thing we check is that we are logged in

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

if(
$isloggedin != "yes" and $cond != "showing"){
$canadopt "no";
}

// Now we check if our usergroup has permission to adopt the adoptable...

$group getgroup();
$dbcanadpt cando($group"canadopt");

if(
$dbcanadpt != "yes" and $cond != "showing"){
$canadopt "no";
}
return 
$canadopt;


Update: the abandon.php and doadoptab.php script are reuploaded, they're edited to work correctly with the function above

This script is not compatible with a gender mod
if you use one a few additions will have to be made:
find in abandon.php
PHP Code:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$owner=@mysql_result($result,$i,"owner");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$code=@mysql_result($result,$i,"code");
$usealternates=@mysql_result($result,$i,"usealternates");
$tradestatus=@mysql_result($result,$i,"tradestatus");
$date=date('Y-m-d');
$eggimage getabandonedimage($aid); 
add at the end
$gender=@mysql_result($result,$i,"gender");

to show the gender:
go a little down till you see $article_content = $article_content."<br><img src='".$eggimage."' border='0'><br>
add between that and <form name='form1' method='get' action='doadoptab.php'> this:
<b>Gender: </b>".$gender."<br>
That shows the gender to people who will get there abandoned pet
next (more importantly) go to adoptab.php
find
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','$currentlevel','$totalcli cks', '$code', '','$usealternates','$tradestatus','$isfrozen')");
replace with
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','$currentlevel','$totalcli cks', '$code', '','$usealternates','$tradestatus','$isfrozen','$g ender')");

find a bit above $eggimage=getabandonedimage($aid);
and add again
$gender=@mysql_result($result,$i,"gender");
that should do it for that file.
but we aren't done

in the code above(in file myadopts.php) you'll see
$date=time('U');
add $gender=@mysql_result($result,$i,"gender");
then find
INSERT INTO ".$prefix."abandoned VALUES ('$aid', '$type', '$name','$owner', '$currentlevel', '$totalclicks', '$code', '', '$usealternates', '$tradestatus', '$isfrozen', '$date')");
replace with
mysql_query("INSERT INTO ".$prefix."abandoned VALUES ('$aid', '$type', '$name','$owner', '$currentlevel', '$totalclicks', '$code', '', '$usealternates', '$tradestatus', '$isfrozen', '$date','$gender')");

well that looks good, but it won't work if you don't add in the table adopts_abandoned a new field gender (with the same options as the gender field from the owned_adoptables)
Attached Files
File Type: php abandon.php (7.7 KB, 4 views)
File Type: php doadoptab.php (7.7 KB, 2 views)
Reply With Quote
  #2  
Old 12-24-2009, 11:51 AM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 26,940
Arianna will become famous soon enough
Default RE: Abandon system

That sounds nice. I might make a few edits, but I'll probably be testing this. x3
Reply With Quote
  #3  
Old 12-24-2009, 05:15 PM
SieghartZeke SieghartZeke is offline
Member
 
Join Date: Oct 2009
Posts: 149
Credits: 12,420
SieghartZeke
Default RE: Abandon system

OMG Work in my site!!!
Thank you for this great Mod!!!
And im waiting for the currency and the shop....
But a little thingy... I add the little code in my lang.php but i don't show text...
can i add in the abandone.php page???
Reply With Quote
  #4  
Old 12-25-2009, 08:30 AM
bokkun bokkun is offline
Premium Member
 
Join Date: Dec 2009
Posts: 8
Gender: Male
Credits: 4,692
bokkun
Default RE: Abandon system

You added it in $ashowing(title)?
an example of my test server:
PHP Code:
$ashowingtitle "Abandoned pets";
$ashowing "These poor pets are dumped by their master, they still are looking for a new home. If you have some extra place in your pet collection, please help these guys out.<br>"
( doadoptab.php uses the same lang as doadopt.php since there is no real need to change the text)

of course you can always add the text to the page itself, lang.php is just to make changing texts easier(for when you make a language mod for example)
Reply With Quote
  #5  
Old 12-25-2009, 02:18 PM
mapleblade mapleblade is offline
Epicness sausage
 
Join Date: May 2009
Posts: 180
Gender: Male
Credits: 24,834
mapleblade
Default RE: Abandon system

wow nice! ill test it as soon as i can :D i was waiting for this feature!!!!!! like the adoptable pound on pokeplushies! nice work!!!!
Reply With Quote
  #6  
Old 12-25-2009, 05:47 PM
Ashje Ashje is offline
Member
 
Join Date: Jan 2009
Posts: 179
Credits: 12,564
Ashje
Default RE: Abandon system

Looks great. Imma try it out soon. XD
Reply With Quote
  #7  
Old 12-26-2009, 07:55 AM
SleepWalker SleepWalker is offline
Member
 
Join Date: Jul 2009
Posts: 32
Credits: 4,483
SleepWalker
Default RE: Abandon system

I wanna to try out.
Reply With Quote
  #8  
Old 12-27-2009, 08:26 PM
Ashje Ashje is offline
Member
 
Join Date: Jan 2009
Posts: 179
Credits: 12,564
Ashje
Default RE: Abandon system

Wait, so this isn't compatible with the gender mod?
Reply With Quote
  #9  
Old 12-27-2009, 09:25 PM
anjwalker anjwalker is offline
Member
 
Join Date: Dec 2009
Posts: 1
Credits: 227
anjwalker
Default RE: Abandon system

it is but you have to add the extra stuff at the end
Quote:
This script is not compatible with a gender mod
if you use one a few additions will have to be made:
find in abandon.php

PHP Code:

Code:
$aid=@mysql_result($result,$i,"aid"); //The adoptable's ID
$currentlevel=@mysql_result($result,$i,"currentlevel");
$type=@mysql_result($result,$i,"type");
$owner=@mysql_result($result,$i,"owner");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$code=@mysql_result($result,$i,"code");
$usealternates=@mysql_result($result,$i,"usealternates");
$tradestatus=@mysql_result($result,$i,"tradestatus");
$date=date('Y-m-d');
$eggimage = getabandonedimage($aid);
add at the end
$gender=@mysql_result($result,$i,"gender");

to show the gender:
go a little down till you see $article_content = $article_content."<br><img src='".$eggimage."' border='0'><br>
add between that and <form name='form1' method='get' action='doadoptab.php'> this:
<b>Gender: </b>".$gender."<br>
That shows the gender to people who will get there abandoned pet
next (more importantly) go to adoptab.php
find
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','$currentlevel','$totalcli cks', '$code', '','$usealternates','$tradestatus','$isfrozen')");
replace with
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','$currentlevel','$totalcli cks', '$code', '','$usealternates','$tradestatus','$isfrozen','$g ender')");

find a bit above $eggimage=getabandonedimage($aid);
and add again
$gender=@mysql_result($result,$i,"gender");
that should do it for that file.
but we aren't done

in the code above(in file myadopts.php) you'll see
$date=time('U');
add $gender=@mysql_result($result,$i,"gender");
then find
INSERT INTO ".$prefix."abandoned VALUES ('$aid', '$type', '$name','$owner', '$currentlevel', '$totalclicks', '$code', '', '$usealternates', '$tradestatus', '$isfrozen', '$date')");
replace with
mysql_query("INSERT INTO ".$prefix."abandoned VALUES ('$aid', '$type', '$name','$owner', '$currentlevel', '$totalclicks', '$code', '', '$usealternates', '$tradestatus', '$isfrozen', '$date',$gender)");

well that looks good, but it won't work if you don't add in the table adopts_abandoned a new field gender (with the same options as the gender field from the owned_adoptables)
Reply With Quote
  #10  
Old 12-28-2009, 04:05 AM
SieghartZeke SieghartZeke is offline
Member
 
Join Date: Oct 2009
Posts: 149
Credits: 12,420
SieghartZeke
Default RE: Abandon system

Omg...You are from MYadopts!!!And you are so much great with coding!! *_*
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mys v1.3.3 Personality System Hwona Mys v1.3.x Mods 15 12-18-2016 10:13 PM
Trade System Kyttias Questions and Supports 4 05-29-2016 01:29 AM
Wait 4 hours to abandon? SilverDragonTears Questions and Supports 2 10-30-2011 04:11 PM
Trade System? sensacion Questions and Supports 5 08-20-2010 12:36 PM
Trade System? SieghartZeke Questions and Supports 1 12-28-2009 08:06 AM


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

Currently Active Users: 769 (0 members and 769 guests)
Threads: 4,081, Posts: 32,029, 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 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636