View Full Version : Help altering levelup.php
xCataluna
07-01-2011, 11:17 PM
Hello. :3
I've recently been trying to add a line to the page you see when leveling an adoptable... and failing. X3
We have an adoptable with a promocode attached to each level. The rewards system sends it to the pet owner, of course, but we would like to have a link displayed on the levelup page as a thank you to the person clicking.
I need the page to check if the adoptable is type "Happy Birthday".
If yes, I need it to check the current level and retrieve the associated promocode.
And then I need to make it display a little message with the link containing the promocode.
And I can't figure how to do it. >.<
I only know as much php as I've taught myself, and I've no idea how mysql works. I think I may have developed an irrational fear of it. XD
So I come to you, and beg your help and your patience, please. :3
Chibi_Chicken
07-02-2011, 05:03 AM
Well my suggestion after looking at the levelup and reward function would be.
after the line
$rewardstatus = reward($id, $type, $nextlevel, $owner);
check if $type is the Happy Birthday type
if true then get the promocode from the adopt.
sql command:
"SELECT * FROM ".$GLOBALS['prefix']."levels WHERE adoptiename='$type' and thisislevel='$nextlevel'"
with the result grab the $promocode and build a link:
$promocode=@mysql_result($result, 0,"promocode");
<a href='promo.php?promocode=".$promocode."'>HERE IS A LINK TO PROMOCODE: $promocode</a>
where you could display that link would be
$article_content = "<img src='".$image."'><br>".$lang_gave."".$name." one ".$lang_unit.".<br>".$lang_levelup_encourage;
or at
$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>";
The problems that i can see with this is if the pet didnt level up it will still try to display a link.
xCataluna
07-02-2011, 11:03 PM
Thank you so much, it works! ^___^
And it does display a link at all times, which is good, we want that. :3
But, unsurprisingly, the link is blank if the pet doesn't level, which is bad.
Is there any way to make it always display the promocode?
Edit: I moved the code down to the bottom, as part of the OUTPUT PAGE section.
That got it to display the promocodes, and I even managed to make the link only display on "Happy Birthday" pages. :3
But I have one more wee problem. When I moved it, it stopped displaying the promocode for the current level, now its displaying the one for the next level. And changing $nextlevel to $currentlevel in the query has no affect. o_o
What am I doing wrong?
Chibi_Chicken
07-03-2011, 04:41 AM
Thank you so much, it works! ^___^
But I have one more wee problem. When I moved it, it stopped displaying the promocode for the current level, now its displaying the one for the next level. And changing $nextlevel to $currentlevel in the query has no affect. o_o
What am I doing wrong?
I am not sure why it would do that; However looking back and your first post and understanding the problem more I suggest this.
On line 165 or before "// Show a thank you message along with the adoptable's information to the user..."
Check if it is the right type of adoptable then add in this query since we dont know if the pet leveled up or not and grab the $currentlevel
sql: "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$id'";
get: $currentlevel
then query to get the $promocode
sql: "SELECT * FROM ".$prefix."levels WHERE adoptiename='$type' and thisislevel='$currentlevel'"
get: $promocode
then build the link and display it I would recomend at
$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>";
Edit: I moved the code down to the bottom, as part of the OUTPUT PAGE section.
I dont recomend putting any code outside of the error/if checking you get more bugs or possible exploits
side note:
bugs that I have notticed about leveling up,
if you are logged out and click on the pet then log in you can click again but not the other way around.
why is it showing you earned money when you are a visitor and not logged in?
You could add a hook and suggest if you had been logged in/ sign up you could have earned that money.
xCataluna
07-03-2011, 04:30 PM
Alright I've tried those queries, and it still uses the next promocode instead of the current one. I tried subtracting one from the $currentlevel before calling for the promocode, and that didn't work either. >.<
I wondered if it had something to do with the egg level having no promocode, so I added one to the database... no luck. :p
Could it be some sort of problem associated with the egg level being zero, instead of one?
I'm about ready to headdesk, but thank you for helping. X3
Chibi_Chicken
07-04-2011, 11:21 AM
echo out the sql queries and see what $currentlevel value is, maybe it is getting the wrong value somewhere.
xCataluna
07-07-2011, 02:33 AM
Alrighty~
I echoed $currentlevel and got a blank, which was weird.
So I changed the query to reference $image instead, which echoed properly.
But the displayed promocode was the same. >__<
We decided to just work around the problem by shifting the promocode entries in mySQL one. So now the displayed promocode is correct.
Not the most elegant solution, but it works now. :3
Thank you so much for all your help. <3
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.