![]() |
Subtract currency upon adopting
Resolved
Now a mod-- Click! OK, so I'm trying to essentially copy the files adoptview.php, adopt.php, and lang_adopt.php in order to create more adoption centers such as these because I'm able to individually customize the stores a lot more then. However I've run into a road block. I don't know how to make it, when using these files, so that when a user "adopts" a cat that has a cost set to it, it subtracts the cost from the user's amount of currency. I can see where it happens in the shop files, but I'm not sure how to convert that over to the adopt files. I think this is the function I need, but I don't know how to include/implement it in the shopname.php or shopnameview.php files (which are just versions of the adopt.php and adoptview.php files); PHP Code:
|
Still looking for some help with this :happyc:
|
Quote:
$adopt = new Adoptable($mysidia->input->post("id")); Then: $cost = $adopt->getCost(); $usermoney = $mysidia->db->select("users", array("money"), "username = {$mysidia->user->username}")->fetchColumn(); $newusermoney = $usermoney - $cost; $mysidia->db->update("users", array("money" => $newusermoney), "username='{$mysidia->user->username}'"); .... Is this what you need? |
Unfortunately it doesn't seem to be subtracting any currency :(
((showing index function in my "mao.php" file which is basically a copy of adopt.php)) PHP Code:
|
Here's how I debug some mysidia scripting I do. I add DIE's in the code to check on things. I added two DIE statements in your code.
Code:
public function index(){ |
Wait, I found a mistake in the sql syntax... try this:
PHP Code:
|
I also found this in pound.php
Code:
$poundAdopt->dopound(); $mysidia->user->changecash(-$cost); |
Huh, nothing's worked as of yet. I'll keep working on this, I'd like to pretty up the layout a bit, and then release it as a mod once I do get it working.
Trying to see if I can somehow use the purchase function now...hm. |
I'm now wondering if this has something to do with the way the adopt function itself is set up...is it just entirely designed to never subtract currency if a user is adopting a pet..?
|
The species has a cost set to it, but you need to pull up that information before you can use it. In the default shop's purchasing function, the line $adopt->getcost($this->salestax); uses $adopt, but that $adopt refers to the species, not to the pet that was just adopted. We can't use that, we already have a variable called $adopt which refers to the pet we just created, not the species as a whole.
Right after the pet is inserted into the database, try this (this should go in adopts.php, obviously): PHP Code:
PHP Code:
|
Nope, still refuses to work (though that tip does make sense, thank you!)
PHP Code:
|
Very odd... I mean... they do get the pet, right, it just doesn't take out money?
|
Yep, the pet is added to the account just fine, but it doesn't subtract any currency.
|
Okay, get this: If you delete the line that inserts the pet into the database in mao.php, it still gets added. Something tells me it's still using the original adopt.php to do it's work. This is because it's still sending the form data to it!
In view/maoview.php find: PHP Code:
PHP Code:
http://orig13.deviantart.net/90be/f/...as-d9rzrmn.gif (Still using this:) PHP Code:
|
-throws hands into the air and starts dancing-
Yes! Brilliant! It's working now! Thank you so, so much, Kyttias! You've saved Catisserie's entire economy, haha! I figured it had something to do with the form, but I was looking at the submit action, and not that part. Thank you so much! Seriously, please let me know if there's ever anything at all I can help you with because you've done so much to help! |
All times are GMT -5. The time now is 12:54 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.