PDA

View Full Version : Click X adoptables to receive a special adoptable


PokePets
12-23-2011, 12:20 PM
// I know, I have terrible loooong coding, but it works anyway ;D

Demo:
http://pokepets.comlu.com/index.php (levelup).

1) We gone edit the database, go to adopts_settings, insert 3 new rows:
Name: clickevent
Value: Yes
Name: eventneeded
Value: What you want, example: 100
Name: eventprize
Value: The type of adoptable users get when they clicked X adopables, example: PikachuNow change also your _users table!
Add a new field;
eventclicks (varchar 5) default: 02) Now we gone edit our levelup.php
Search for this:

// Show a thank you message along with the adoptable's information to the user...
$image = getcurrentimage($id); // Get the current image of the adoptable...

$article_title = $lang_gave."{$owned_adoptable['name']} one ".$lang_unit;
$article_content = "<img src='{$image}'><br>{$lang_gave}{$owned_adoptable['name']} one {$lang_unit}.<br>".$lang_levelup_encourage;


} // Adoptable is not frozen, end isfrozen else checkAnd add this under;

$query = "SELECT * FROM ".$prefix."settings WHERE name='clickevent'";
$result = mysql_query($query);
$num = mysql_numrows($result);


$clickevent=@mysql_result($result,$i,"value");

$query2 = "SELECT * FROM ".$prefix."users WHERE username='{$loggedinname}'";
$result2 = mysql_query($query2);
$num2 = mysql_numrows($result2);

$eventclicks=@mysql_result($result2,$i,"eventclicks");

$query3 = "SELECT * FROM ".$prefix."settings WHERE name='eventneeded'";
$result3 = mysql_query($query3);
$num3 = mysql_numrows($result3);

$eventneeded=@mysql_result($result3,$i,"value");

$query4 = "SELECT * FROM ".$prefix."settings WHERE name='eventprize'";
$result4 = mysql_query($query4);
$num4 = mysql_numrows($result4);

$eventprize=@mysql_result($result4,$i,"value");
$newevent = $eventclicks + 1;
$eventstillneeded = $eventneeded - $newevent;

if($clickevent == "yes" and $newevent < $eventneeded){

runquery("UPDATE {$GLOBALS['prefix']}users SET `eventclicks` = '{$newevent}' WHERE `username` = '{$loggedinname}'");
$event = "There is a click event! You have clicked {$newevent} adoptables, you need to click {$eventstillneeded} adoptables more to
receive a {$eventprize}.";
}

elseif($newevent == $eventneeded){
runquery("UPDATE {$GLOBALS['prefix']}users SET `eventclicks` = '{$newevent}' WHERE `username` = '{$loggedinname}'");
runquery("INSERT INTO {$prefix}owned_adoptables VALUES ('', '{$eventprize}', 'Congratz','$loggedinname','0','0', '$code', '','$alts','fortrade','no', 'None','0')");
$event = "There is a click event! You have clicked {$newevent} adoptables, that's enaugh to receive a {$eventprize}. It's automatic
added to your account.'";

}

elseif($newevent > $eventneeded){
runquery("UPDATE {$GLOBALS['prefix']}users SET `eventclicks` = '{$newevent}' WHERE `username` = '{$loggedinname}'");
$event = "You already received a click promo, you can't get another one.";

}
else{

$event = "";
}3) Now change your levelup content, find
$article_content = $article_content . "<div align='center'><br /><br><br>You have earned {$reward} ".grabanysetting('cost')." for leveling up this adoptable. <br />You now have {$newamount} ".grabanysetting('cost')."</div>";And change it to;

$article_content = $article_content . "<div align='center'><br />{$event}<br><br>You have earned {$reward} ".grabanysetting('cost')." for leveling up this adoptable. <br />You now have {$newamount} ".grabanysetting('cost')."</div>";Now it should work :D



FIX THAT GUESTS CAN'T GET IT WILL COME ;)

Hall of Famer
12-24-2011, 03:52 AM
Well I am afraid it will not work unless you modify a line at register.php since the structure of table prefix_users has changed:


Now change also your _users table!
Add a new field;


Unless this happened to be a typo...

PokePets
12-24-2011, 05:09 AM
Well I am afraid it will not work unless you modify a line at register.php since the structure of table prefix_users has changed:


Now change also your _users table!
Add a new field;


Unless this happened to be a typo...
Indeed *changing* ;)