Log in

View Full Version : I love questions =)


SilverDragonTears
08-28-2011, 12:13 AM
I wanted to disallow leveling up adults (increasing their clicks)

so I found this:



// Now we see if the adoptable is frozen by its owner. If it is, we do not level...

if($isfrozen == "yes"){

$article_title = $lang_isfrozen_title;
$article_content = $lang_isfrozen_explain;

}

And after it added this:


// Now we see if the adoptable is an adult. If it is, we do not level...

if($currentlevel == "5"){

$article_content = "Adults can not be leveled up!";

}

It works but how do I disallow getting coins for clicking it?

Hall of Famer
08-28-2011, 12:18 AM
Well find these lines in your levelup.php:


if($isfrozen == "no"){
changecash(grabanysetting('rewardmoney'), $GLOBALS['username'], $GLOBALS['money']);
$article_content = $article_content . "<div align='center'><br />You have earned ". grabanysetting('rewardmoney') ." ". grabanysetting('cost') ." for leveling up this adoptable. <br />You now have {$GLOBALS['money']} ".grabanysetting('cost')."</div>";
}


Replace with:(assuming the maximum level on your site is 5, as inferred from your script)

if($isfrozen == "no" and $currentlevel <5){
changecash(grabanysetting('rewardmoney'), $GLOBALS['username'], $GLOBALS['money']);
$article_content = $article_content . "<div align='center'><br />You have earned ". grabanysetting('rewardmoney') ." ". grabanysetting('cost') ." for leveling up this adoptable. <br />You now have {$GLOBALS['money']} ".grabanysetting('cost')."</div>";
}


Give a try on your site and see if it works.

Hall of Famer

SilverDragonTears
08-28-2011, 12:22 AM
wonderful!!! *more cookies for you* need some milk?

Hall of Famer
08-28-2011, 12:24 AM
Well this is up to you. XD

Did you try the code on Silvadopts? Lemme know if you have more questions regarding customizing your site.

SilverDragonTears
08-28-2011, 12:29 AM
Yep, it worked perfect! That's why I gave you cookies!! I do have another question but maybe more complicated. I want to show a link that will list all the children an adopt has had. How difficult would this be?

Hall of Famer
08-28-2011, 12:34 AM
Oh I see, I am glad it works for ya.

Well its not really complicated, are you using Arianna's family tree script? As I've said before, that one is not compatible with Mys v1.2.x, but perhaps you've got it to work. If so, you will find the two columns 'father' and 'mother' in prefix.ownedadoptables table. What you should do is to make a PHP table that retrieves data from all rows of child adoptables whose father(if the gender is male) or mother(if the gender is female) is very parent adoptable you have selected.

If you do not use Arianna's family tree script, then create two columns 'father' and 'mother' in table prefix.owned_adoptables and repeat the same procedure as mentioned above.

SilverDragonTears
08-28-2011, 12:38 AM
Yes I'm using her script and it's working wonderfully(after tweaking some things) however, my coding is still not advanced so... err.. can you show me? I learn better seeing it. It's hard to follow how to do it all myself.

Hall of Famer
08-28-2011, 01:11 AM
Alright I will show you. But since I am not that familiar with Arianna's family tree script, what I provide below should NOT be directly copy/pasted to your site. It merely serves as a reference, especially since I do not know exactly what your database owned_adoptables looks like and what mysql command you uses to retrieve data.

First of all, you need to retrieve the gender of your parent adoptable. The parentid should be available to you already, and I strongly advise you to name it $parentid to avoid confusion. Write the codes below:


$result = runquery("SELECT * FROM {$prefix}owned_adoptables WHERE aid = '{$parentid}'") ;
$row = mysql_fetch_array($result);
$gender = $row['gender'];
Next, you will need to select from database prefix.owned_adoptables for all child adoptables with the very parent. This may vary depends on if the parent adoptable is male or female, as shown below:


if($gender == "f"){
$query = "SELECT * FROM {$prefix}owned_adoptables,
{$prefix}adoptables WHERE {$prefix}owned_adoptables.mother = '{$parentid}'
AND {$prefix}adoptables.type = {$prefix}owned_adoptables.type
ORDER BY {$prefix}owned_adoptables.aid";
$result = runquery($query);
}
else{
$query = "SELECT * FROM {$prefix}owned_adoptables,
{$prefix}adoptables WHERE {$prefix}owned_adoptables.father = '{$parentid}'
AND {$prefix}adoptables.type = {$prefix}owned_adoptables.type
ORDER BY {$prefix}owned_adoptables.aid";
$result = runquery($query);
}
Nicely done, you should write a table to display child adoptables info, a good example is provided below, you may modify it to suit your need:


$article_content = "<table border='1'>
<tr>
<th>Image</th><th>Species</th><th>Name</th><th>Level</th><th>TotalClicks</th><th>Owner</th><th>Gender</th>
</tr>";
while($row = mysql_fetch_array($result)){
if($row['usealternates'] =='yes')
{
$image = $row['alternateimage'];
}
else
{
$image = $row['primaryimage'];
}
if($row['currentlevel'] == 0)
{
$image = $row['eggimage'];
}
if($image=='')
{
$image = $row['primaryimage'];
}
$article_content .= "<tr>
<td><center><img src='{$image}'></center></td>
<td><center>{$row['type']}</center></td>
<td><center>{$row['name']}</center></td>
<td><center>{$row['level']}</center></td>
<td><center>{$row['totalclicks']}</center></td>
<td><center>{$row['owner']}</center></td>
<td><center><img src='picuploads/{$row['gender']}.png'></center></td>
</tr>";
}
$article_content .= "</table>";


This may look complicated, but it is the only way I can think of with Arianna's family tree script. Give a try on your site and see if you can set up a page like that.

SilverDragonTears
08-28-2011, 01:14 AM
ok the only part that confuses me is
The parentid should be available to you already, and I strongly advise you to name it $parentid to avoid confusion.

Hall of Famer
08-28-2011, 01:17 AM
That I figured. Would you mind showing your script file so I can tell you which one is supposed to be $parentid?

SilverDragonTears
08-28-2011, 01:19 AM
should i do this in the family tree script in premium area? since this was a premium mod?

Hall of Famer
08-28-2011, 01:21 AM
Well just send me a PM if you want to, I can get back to you soon.

SilverDragonTears
08-28-2011, 01:22 AM
PM sent =)

Hall of Famer
08-28-2011, 01:36 AM
Guess I understand how family tree works now. The $mother or $father is the $parentid I was referring to. You can ignore the first step and modify the second step as:


if(isset($mother)){
$query = "SELECT * FROM {$prefix}owned_adoptables,
{$prefix}adoptables WHERE {$prefix}owned_adoptables.mother = '{$mother}'
AND {$prefix}adoptables.type = {$prefix}owned_adoptables.type
ORDER BY {$prefix}owned_adoptables.aid";
$result = runquery($query);
}
if(isset($father)){
$query = "SELECT * FROM {$prefix}owned_adoptables,
{$prefix}adoptables WHERE {$prefix}owned_adoptables.father = '{$father}'
AND {$prefix}adoptables.type = {$prefix}owned_adoptables.type
ORDER BY {$prefix}owned_adoptables.aid";
$result = runquery($query);
}



It seems that you may need to either write a new script file or create a subpage for familytree.php to display an adoptables' children.

SilverDragonTears
08-28-2011, 01:39 AM
=/ how do i do that? lol!
told you my coding isn't great yet

Hall of Famer
08-28-2011, 01:46 AM
Oh I see, I will find another time(maybe next week) to rewrite the entire familytree.php for you.

SilverDragonTears
08-28-2011, 01:51 AM
alright =) and one more small thing. if i have this code

if($numpets >= 50){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='http://media.giantbomb.com/media/bomb/img/achievements/trophy-bronze.png' title='Bronze Trophy'></div>";
} else if($numpets >= 200){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/silvertrophy.png' title='Silver Trophy'></div>";
} else if($numpets >= 500){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='http://media.giantbomb.com/media/bomb/img/achievements/trophy-gold.png' title='Gold Trophy'></div>";
}

which isn't right b/c it isn't working. what i want to do is show a bronze tropy if the member has 60 or less pets
silver trophy if the have 200 or less
and gold if 500 or more

but the code i have either shows all the trophies or only if they have that exact amount =/


EDIT::
I was doing it backwards eh?
if($numpets >= 500){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/trophy-gold.png' title='Gold Trophy'></div>";
} else if($numpets <=50 && $numpets <= 200){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/silvertrophy.png' title='Silver Trophy'></div>";
} else if($numpets != 50){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/trophy-bronze.png' title='Bronze Trophy'></div>";
}else{
$article_content .= "";
}

no still not working correctly.


second EDIT::
i think this is correct...
if($numpets >= 500){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/trophy-gold.png' title='Gold Trophy'></div>";
} else if($numpets >= 200){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/silvertrophy.png' title='Silver Trophy'></div>";
} else if($numpets >= 50){
$article_content .= "<div style='width: 100%; float:left; padding:5px;'><img src='/images/trophy-bronze.png' title='Bronze Trophy'></div>";
}else{
$article_content .= "";
}