PDA

View Full Version : Adoptables Shop - Working Again!


Fireballchad
12-01-2009, 03:45 PM
Ok I am 100% done with this version. I will make a new version with more features. But this one works and is running.
First you will need to install Sea's cash system.
http://www.rusnakweb.com/forum/showthread.php?tid=1333
Next follow my steps (I will try to do this so it makes since)
Around line 169 in your admin.php add this:

<input name='cba' type='radio' value='pricenum'>
Only when users pay this much BP:
<input name='price' type='text' id='price'>
<p>
<input name='shop' type='checkbox' id='shop' value='enabled'>
Sell This In Your Shop!</p>
<br>In your nadopt.php file add this around line 112:

$price = $_POST["price"];
$price = secure($price);

$shop = $_POST["shop"];
$shop = secure($shop);Still in the same file change this:
if($cba != "always" and $cba != "promo" and $cba != "conditions"){
$error = "You did not choose a valid scenario when this adoptable can be adopted. Please go back and either select the Always option, the Promo option or the Conditions option.";
}To This:
if($cba != "always" and $cba != "promo" and $cba != "pricenum" and $cba != "conditions"){
$error = "You did not choose a valid scenario when this adoptable can be adopted. Please go back and either select the Always option, the Promo option or the Conditions option.";
}Around Line 172 add this:
//If we are using money to buy this, we should have a amount in the box...
if($cba == "pricenum" and $price == ""){
$error = "You selected that this adoptable is available for adoption only with money, but you did not enter in a money amount. Please go back and either change this setting or type in a valid amount.";
}
if($shop == "enabled") $shop2 = "1"; Add $shop2 also add $price into the data base insert around line 251:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$sh op2','$price')");Insert this in doadopt.php around line 104:
$price=@mysql_result($result,$i,"price");In doadopt.php use this... Again it is done for my site so it may be wierd... and my coding isn't great lol... as in not neet

$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i = 0;
while ($i < 1) {
$money = @mysql_result($result, $i, "money");
$newbalance = $money - $price;
$i++;
}

if ($money < $price) $get ='';
else
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
//This Line Above This Comment Was Moved From Around Line 138 Delete That One!
//Prevents From getting an adopt if no money.

if ($price == 0) $get = '';
else $get = '<br> Thanks for buying your Bud! Now you have '.$newbalance.' coins!';

if ($money < $price) $get ='<br><br>There was an Error!<br>You Do Not Have Enough Coins';
else
mysql_query("UPDATE `adopts_users` SET `money`='" . $newbalance . "' WHERE `username`='$loggedinname'");
// money buying addon
//prevents from going negative money.
$article_title = "You got ".$name." successfully";
$article_content = "<img src='".$eggimage."'><br>".$congrats1." ".$name.". You can now manage ".$name." on the
<a href='myadopts.php'>My Buds</a> page.<br><br><b><a href='myadopts.php?act=manage&id=".$id."'>Click Here to Manage ".$name."</a><br>
<a href='myadopts.php?act=bbcode&id=".$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a> ".$get." </b><br><br>";Last But not least insert this into your data base under adopts_adoptables
`shop` tinyint(1) NOT NULL default 'NULL', and `price` int(10) NOT NULL default 'NULL'Ok I hope it works for you
shop.php is attached it is adopt.php but shows items that cost money instead of being free and adopt.php now should show items that do not cost money.


Credit goes to Sea and Arianna for the code to get this working
Sorry for not fixing broken links and such!

Tequila
12-01-2009, 07:11 PM
So will this be compatible with Sea's mod? If so, I'll stop working on mine. :)

Fireballchad
12-01-2009, 10:54 PM
So will this be compatible with Sea's mod? If so, I'll stop working on mine. :)


Yup it uses Sea's mod :D and the beginnings of Arianna buying pets code :D

Arianna
12-02-2009, 12:01 AM
Ooh, awesome! :D For the items, can it use my deco mod? Because that needs a shop and is already finished, so they could maybe work together, along with the cash. :)

Fireballchad
12-02-2009, 12:10 AM
Ooh, awesome! :D For the items, can it use my deco mod? Because that needs a shop and is already finished, so they could maybe work together, along with the cash. :)


Yup I can try to get it into it xD. Right now I am half way scraping what I have for the store... I realized the most easy way to do this and is way easier to put out to the public... so I am cutting my losses lol and going an easier route... I might even have it done tonight we will see :)

Fireballchad
12-02-2009, 01:54 AM
hmmm the thing doesn't turn green from edits :( so this is a bump I guess but I changed my first post so it really isnt a bump >.> :)

Arianna
12-02-2009, 10:04 AM
I already did something like this...? Apart from the else if, there's a code pretty much exactly like this on Sea's cash thread, on the last page, I think.

Fireballchad
12-02-2009, 11:29 AM
I already did something like this...? Apart from the else if, there's a code pretty much exactly like this on Sea's cash thread, on the last page, I think.


Yup you did... it didn't work lol... I made it work and added a few things like the shop page. I am sorry in that thread I put the credit for you, I forgot to on this thread I will fix it :D And I am working on adding some cool things to it. I just got it working so it separates the free from the bought. Some cool things will be setting it so an item can be set to give its clicks to one of your adopts and I am working on adding your deco mod.

Arianna
12-02-2009, 01:37 PM
Oh, that's weird. xD Why didn't it work? The users of my site seem to be able to be buying pets just fine. xD

Fireballchad
12-02-2009, 04:29 PM
Oh, that's weird. xD Why didn't it work? The users of my site seem to be able to be buying pets just fine. xD

I have no clue... I followed your guide but I had to add a few things before it worked lol...

Also has anyone tried this yet? lol I want to know if anyone can get it to install so I can make sure I did it right lol

gjac1
12-03-2009, 08:21 AM
I tried it but now i do see any of my regular adoptables on the adopt page and i dont see the 1 shop item i added in shop.php :s[hr]
It took me about 3 hours to set this up and get it working, but its def worth it, thanks for this mod :)

Here is what i had to do to get it working.

You have to change the "INSERT" code to this in nadopt.php

mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond',

'$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$sh op','$price')");

And then the next problem was caused by a small typo, this is also a part you add to nadopt.php but i have corrected it, in your original guide you told it to change the value of shop2 to 1 and it should be the value of shop

//If we are using money to buy this, we should have a amount in the box...
if($cba == "pricenum" and $price == ""){
$error = "You selected that this adoptable is available for adoption only with money, but you did not enter in a money amount. Please go back and either change this setting or type in a valid amount.";
} if($shop == "enabled") $shop = "1";

gjac1
12-03-2009, 09:33 AM
I cant seem to figure this part out.

One the shop adopt page, it doesnt tell you exactly how many credits you have, it just always says "You have -1000 Credits "

gjac1
12-03-2009, 11:56 AM
After spending most of today on this, i have finally figured it out.

After fixing the first few problems i found out that mod wasnt subtracting the cost of the shop item from the current balance, instead it was leaving the user with minus whatever the shop item cost, for example if i had 2000 credits and i bought an adoptable for 500 , it would say my balance was -500 :s , this was due to several things.

Basically all you have to do now is edit the shop.php file and tell it to use doadopt2.php for the actual adoption (search for doadopt.php in shop.php and change it to doadopt2.php) , i have attached my doadopt2.php for you to use with everything fixed.

Thanks again for this original mod, i would never have known where to start making something like this :)

EDIT : oops, it seems i cant attach the file, so i uploaded it here :)

http://www.speedyshare.com/files/19603746/doadopt2.rar

Fireballchad
12-03-2009, 02:07 PM
After spending most of today on this, i have finally figured it out.

After fixing the first few problems i found out that mod wasnt subtracting the cost of the shop item from the current balance, instead it was leaving the user with minus whatever the shop item cost, for example if i had 2000 credits and i bought an adoptable for 500 , it would say my balance was -500 :s , this was due to several things.

Basically all you have to do now is edit the shop.php file and tell it to use doadopt2.php for the actual adoption (search for doadopt.php in shop.php and change it to doadopt2.php) , i have attached my doadopt2.php for you to use with everything fixed.

Thanks again for this original mod, i would never have known where to start making something like this :)

EDIT : oops, it seems i cant attach the file, so i uploaded it here :)

http://www.speedyshare.com/files/19603746/doadopt2.rar


Sorry for the typos I will fix them. And I am glad you got it working!

PTGigi
12-08-2009, 04:29 PM
Sorry if I sound stupid but I've read through this topic a few times and it sounds like this mod is for adopting pets but the title says its an item shop mod. So which is it? I'm getting kinda confused or I'm missing something really obvious...

Arianna
12-09-2009, 12:38 AM
I really don't get it either - I wrote something totally like this on Sea's thread, and I don't know why he couldn't just expand on that. :/

gjac1
12-09-2009, 04:10 AM
Its a mod for adopting pets via a shop system using the cash mod by Sea.

Arianna
12-09-2009, 08:52 AM
However, I wrote something just like this on Sea's thread. :)

PTGigi
12-09-2009, 10:32 AM
Its a mod for adopting pets via a shop system using the cash mod by Sea.


Alright so its not an item mod? Because then I think he should change the title. That's what was confusing me.

gjac1
12-09-2009, 11:49 AM
Nope its not an item mod, its to place "items" (adoptables) into a shop page so they can be purchased with credits earned using the cash system created by Sea :)

gjac1
12-10-2009, 02:01 PM
I just found out that if someone was to replace the id in adopt.php?id=xx from the normal adoption page with an id of a shop adoptable, they will get it for free :(

Haylzee
12-10-2009, 03:36 PM
Yeah they can, when I made my shop I changed adopt.php to also link to my buy.php (the page that checks your money and removes the amount owing) instead of doadopt.php and just set the prices of the normal adopts to 0. So they still all have to go through the buy.php page but you can still keep 'free' adoptables.

gjac1
12-10-2009, 03:48 PM
Yeah they can, when I made my shop I changed adopt.php to also link to my buy.php (the page that checks your money and removes the amount owing) instead of doadopt.php and just set the prices of the normal adopts to 0. So they still all have to go through the buy.php page but you can still keep 'free' adoptables.


Could you go into this a bit more please ?? :)

I dont have a buy.php :s

Haylzee
12-10-2009, 04:17 PM
ETA: After now looking at this mod, I think it's set up differently from mine so what I've put below might not apply.

Ok this is how I set mine up, I have a shop.php which is the same as adopt.php (at the time I had free adoptables and shop adoptables which is why I made them separate, the free adoptables showed up on adopt.php and the ones that cost money showed up on the shop.php). adopt.php uses doadopt.php to put the pets into the owned adoptables table in the database. I made a copy of doadopt.php and called it buy.php, and edited shop.php so that instead of going to doadopt when adopting, it goes to buy.php instead. My buy.php page is coded to check that the user has enough money, if they don't they get told they don't have enough to buy the pet. If they do have enough, the price of the pet gets deducted from their total and the pet goes into their owned adoptables in the database.

Since promo.php still uses adopt.php and doadopt.php, I left it there as normal, but it didn't take long to realize that people could use adopt.php to get free adoptables, so I altered adopt.php to also link to buy.php (basically removing the need for doadopt.php altogether) because now even the free adoptables will still have to go through the process of the money check (which will of course go through because they are set at 0 currency anyway). So even if someone was to use a shop pet id with adopt.php, they will still get charged for it because it's going through the same system.

Of course, this can all be simplified down to just editing doadopt.php to do what buy.php does, but at the time I wanted to keep my doadopt.php unchanged. And I have simplified it a little by charging currency for all the adoptables, none are free. So they all show up on the same page now anyway.

I'm not entirely sure how you have yours set up, but as long as you make sure any adoptions have to go through the money check and money deduction process, no one can get shop adoptables for free.

gjac1
12-11-2009, 11:42 AM
I currently have my shop.php directed to use a file called doadopt2.php which i modified myself to add the money checking/deduction process, but that is on shop.php , if a member just does it using the normal adopt.php then they can still get it for free.

Arianna
12-11-2009, 01:10 PM
I just looked through your code - how do you have it so if the cash goes under 0, the adoption doesn't work? Some of my members are at -50 coins and stuff, and even though I'm using a different code, it would be greatly appreciated. :)[hr]
Sorry, I got that worked out now. It was a missing '=' in a statement. To think that I spent half an hour tearing my hair out over that...

Haylzee
12-11-2009, 06:42 PM
I currently have my shop.php directed to use a file called doadopt2.php which i modified myself to add the money checking/deduction process, but that is on shop.php , if a member just does it using the normal adopt.php then they can still get it for free.


That's because adopt.php is probably still using doadopt.php instead doadopt2.php to add the pets to the database. Your dodoadpt.php, if it hasn't been changed, won't deduct the money, so if someone uses a shop id with adopt.php, the adoption will go through without the deduction process, because that is only happening with doadopt2.php with your deduction code - does that make sense?

Your doadopt2.php is the same as my buy.php - If you edit your adopt.php to use doadopt2.php, it won't matter if people try to use adopt.php to get free adoptables, they won't be able to, because it will still go through the deduction process and deduct the set cost of the adoptable they are trying to get.

In adopt.php find

<form name='form1' method='get' action='doadopt.php'>

and just change doadopt.php to doadopt2.php - it's simple enough to change back later if you want. Just remember that promo adoptables still go through adopt.php so this will count for them too. I was using the promo page to give myself shop adoptables for free by just giving them a code, which can no longer be done with adopt.php going through the money process too.

Arianna
12-12-2009, 01:04 AM
Why don't you just make it so all adoptables have prices, even if they are 0? That way you don't need any doadopt2's or the like.

PTGigi
12-13-2009, 06:58 PM
After spending most of today on this, i have finally figured it out.

After fixing the first few problems i found out that mod wasnt subtracting the cost of the shop item from the current balance, instead it was leaving the user with minus whatever the shop item cost, for example if i had 2000 credits and i bought an adoptable for 500 , it would say my balance was -500 :s , this was due to several things.

Basically all you have to do now is edit the shop.php file and tell it to use doadopt2.php for the actual adoption (search for doadopt.php in shop.php and change it to doadopt2.php) , i have attached my doadopt2.php for you to use with everything fixed.

Thanks again for this original mod, i would never have known where to start making something like this :)

EDIT : oops, it seems i cant attach the file, so i uploaded it here :)

http://www.speedyshare.com/files/19603746/doadopt2.rar


Hey gjac1, is it possible to add that file up again? The site you put it on seems to have deleted it...

gjac1
12-14-2009, 04:45 PM
Why don't you just make it so all adoptables have prices, even if they are 0? That way you don't need any doadopt2's or the like.



This is what i ended up doing, but i have to manually change the shop value in myphpadmin to 2 so i can still keep the regular adoptable separate from the shop ones and on different pages.

Thanks for the help :)[hr]
pokemontrainergigi, Here is my doadopt2.php if you still need it :)

http://www.mediafire.com/?5i1qiyvy0mo

PTGigi
12-14-2009, 07:11 PM
pokemontrainergigi, Here is my doadopt2.php if you still need it :)

http://www.mediafire.com/?5i1qiyvy0mo

Thank you!

Ben
01-05-2010, 03:28 PM
I think the link is broken... Is there any way to get this still?

redheadturkey
02-03-2010, 12:48 AM
also cant seem to get the shop.php -- and not sure where the buy.php comes in, but can anyone attach those files again?

And the doadopt2 one?

thanks!!

I have this partially done, but can't finish w/o the shop file !

Hall of Famer
02-07-2010, 04:49 AM
the attachment is not working...

Seapyramid
02-07-2010, 09:33 PM
It.. like all attachments was lost in the server transfer.

Hall of Famer
02-08-2010, 11:55 AM
So can it be fixed?

redheadturkey
02-08-2010, 04:15 PM
shop.php has to be re-uploaded again--- as far as I can tell, that's the one that has to be attached again.

I have the other coding done for the currency.

Might need that doadopt one too .. not sure, going to re read.

Hall of Famer
02-08-2010, 07:05 PM
Yes, please hear out voices.

redheadturkey
02-09-2010, 09:31 AM
Yes, please hear out voices.



I'm sure they will re attach all we need soon :D

I know everyone here has commitments to other things, and they are going to do it as soon as they have the chance. At least it wasn't a huge amount of files, I think there are only like 5 or 6 to be re attached.

Fireballchad
02-09-2010, 02:14 PM
Yes, please hear out voices.



I'm sure they will re attach all we need soon :D

I know everyone here has commitments to other things, and they are going to do it as soon as they have the chance. At least it wasn't a huge amount of files, I think there are only like 5 or 6 to be re attached.


Ya it wasnt a hard fix, I just barely got my new laptop and have been going around to all the sites i was using. Again sorry for the down time. On another note I fixed it so You CAN NOT get a paid adopt from the doadopt.php screen by refreshing. You orignaly could go negative coins and keep getting the adopt!

Install Has Been Simplitfied Also

redheadturkey
02-09-2010, 04:37 PM
ah fantastic!!

thanks SO much!! :D :D

Fireballchad
02-09-2010, 09:08 PM
ah fantastic!!

thanks SO much!! :D :D


Please let me know if you get it installed :D

redheadturkey
02-09-2010, 11:17 PM
I did, and it works great!!

I am sure there is a lot we can do with a shop ! -- I have it where I can buy pets, and so far so good -- -ONE question -- no matter what I do, it says all pets are 1 dollar, LOL.

I tried to figure out how to change that, and so far, no luck. I'd like to make different prices --- is there a place to insert that in code I am missing?

( I did put the price when I made a new pet, where it says to, but it isn't 'taking' )

Hall of Famer
02-10-2010, 01:40 AM
Thank you for fixing the link.

Fireballchad
02-10-2010, 04:23 PM
I did, and it works great!!

I am sure there is a lot we can do with a shop ! -- I have it where I can buy pets, and so far so good -- -ONE question -- no matter what I do, it says all pets are 1 dollar, LOL.

I tried to figure out how to change that, and so far, no luck. I'd like to make different prices --- is there a place to insert that in code I am missing?

( I did put the price when I made a new pet, where it says to, but it isn't 'taking' )

hmmm there is a few spots i think you could of gone wrong, firstly check what order you put your $shop2 and $price vars into this chunk of code.
mine are at the end.

mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$sh op2','$price')");

Then check your database to see if you put the shop insert Before the price insert. These need to be in the same order that they are in the chunk of code above. Because the var $shop2 is set to 1 to single that is a shop item, but any number will work in fact thats why you didnt see anything goofy my setting the price if you crossed them
example price = 1000 is the same as shop = 1 the way i wrote the code

redheadturkey
02-11-2010, 09:51 AM
I had the price and the shop fields backwards in the SQL tables, got it, it's working!!

thanks so much for this script, it's wonderful!!

One question:

Any ideas on how this might be used to say, have an owner place an adoptable IN the shop, and carry out sales that way?

I apologize if this has been asked before! It likely has, lol, but I cannot locate the thread ....

Arianna
02-11-2010, 10:46 AM
Shops like that would be a totally different system, I think. :/

Seapyramid
02-11-2010, 01:07 PM
It would take creating a new shop with a number of features to get something like that to work. Plus you would also be giving others the ability to upload to your server & input a lot into your database which could leave you open to security issues.

Arianna
02-11-2010, 01:20 PM
I think she means an already adopted adoptable, not an actual adopt kind... correct me if I'm wrong. :)
I don't think I wanna code that - it's cool in principle, but I have other stuff to work on.

redheadturkey
02-11-2010, 03:32 PM
I think she means an already adopted adoptable, not an actual adopt kind... correct me if I'm wrong. :)
I don't think I wanna code that - it's cool in principle, but I have other stuff to work on.



yep exactly! :D

Like let's say I have Rover and Dingdong, and I own them, but I'd like to sell them in the shop too.

Seapyramid
02-11-2010, 04:55 PM
That would be more of a trade shop then where they could auction the adopt for ingame coin or trade for something else. I am aware Brandon has a simple trade system for his MyAdopts site & I have created one that allows the auctioning of up to 3 pets at a time for up to 5 pets in trade plus in-game coin and real cash credits. Such a system can be made but it takes many hours depending on the complexity and features you want your users to have. Currently there isn't a mod available for download.

Sea

Fireballchad
02-11-2010, 08:54 PM
That would be more of a trade shop then where they could auction the adopt for ingame coin or trade for something else. I am aware Brandon has a simple trade system for his MyAdopts site & I have created one that allows the auctioning of up to 3 pets at a time for up to 5 pets in trade plus in-game coin and real cash credits. Such a system can be made but it takes many hours depending on the complexity and features you want your users to have. Currently there isn't a mod available for download.

Sea


Hehe ya I am still a novice at php, the shop code is really simple but it took me a good 5 hours to figure out how to do it simpler after doing this the hardest way possible the first time. To be honest that kind of mod I am not sure if I made one would release to the general public considering it would take me forever and a half.

redheadturkey
02-12-2010, 08:25 AM
heheh I understand, I was overjoyed to get this code for a shop at all.

Thanks again for it ! ^__^

Seapyramid
02-12-2010, 09:41 AM
Hehe ya I am still a novice at php, the shop code is really simple but it took me a good 5 hours to figure out how to do it simpler after doing this the hardest way possible the first time. To be honest that kind of mod I am not sure if I made one would release to the general public considering it would take me forever and a half.


ROLF I am doing more & more advanced code, but the one I did took me about a month to code. Hence 1 of the reasons I haven't made it available.

Sea

densaugeo
03-21-2010, 10:32 PM
For the last bit you use in doadopt, are you -replacing- bits in doadopt, or just adding it? I am confused :) You just say use in in there..

fadillzzz
05-31-2010, 09:18 AM
Is it really necessary to use the attached adopt.php?
what's the different with the default one?

Ben
07-01-2010, 07:12 PM
I would really love someone to update this first post and help fix the wording of it. I've tried for a while to get this to work and I cannot get it to.

I must say that it is a great piece of work, but in the first part, it isn't explained very well, and I think it may have errors which haven't been updated in the first post.

Can someone maybe do this please or post an update of how to do this please? I'd really appreciate it, as it would really help.

Hall of Famer
09-01-2010, 04:50 PM
Well this is apparently an adoptable shop instead of item shop...