Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Secondary currency questions (http://www.mysidiaadoptables.com/forum/showthread.php?t=4719)

ilrak 11-30-2014 04:12 PM

Secondary currency questions
 
So, I think I've done pretty well with creating a secondary currency, but I'm still having a few issues.

First off, I can get the currency to display in the sidebar and drop when I level up an adoptable, but it drops at the same rate as the main currency, even though (I thought) I set it to drop at a lower rate.

I also can't get the currency to be differentiated in the shops. For example, I want a shop to only take once currency and another that takes the other.

I'm wondering where in the script I can go to edit these things (and prefferably un-link the two currencies so that they are independent of each other - When I went to test buy an item, it displayed that I only spent the one currency but both currencies decreased by the same amount).

Eventually, I'll want three currencies (one that can be purchased for RL money), but I need to fix these issues before I do anything with that.

Hopefully I'm making sense!

ilrak 12-14-2014 09:00 PM

bumping this up. ^v^;

Kyttias 12-15-2014 01:14 AM

Let me think... first, I would make a column in the shops table of the database to tell which shops which currency to use. Then, I would have to add a variable representing this new column at the top of classes/class_itemshop.php and classes/class_adoptshop.php. Next, in the same files, I would have to modify the public function purchase and check which currency the shop is using and reduce only the currency that shop is using. (It would be much harder to make a shop that utilizes both currencies at once, and even harder to have it so the same item can be bought with either. So let's just not go down that road right now, as it would involve making columns in the items table, then running running some sort of check or another when display the item buy form...)

As for the drop rate - the amount of currency dropped when visiting a pet is determined by the value column on the reward row of table levels_settings in the database. I would suggest making another row for your other currency to determine the drop rate for it. You'll need to reference to it in classes/class_levelsetting.php by creating a variable for it at the top. In the public function __construct, imitate what's going on with $this->reward with the name of your new variable. In levelup.php, at the end of public function click, imitate what's going on here for the original currency's $reward, one line at a time, each after the last. And finally, in view/levelupview.php, after $reward variable is set, do so with your second, new one as well.

I think that's all you should need to do. I hope that's enough hints. ^^

ilrak 12-15-2014 02:53 PM

Thanks so much! When adding the currency options in the shop table, is it an INT type or something else? I'm going to play around with it, but I'm excited!

Kyttias 12-15-2014 04:04 PM

INT is short for Integer values. Integer is a mathematical term and is just a fancy word for numbers. VARCHAR is short for Variable Character values, and can hold both numbers and letters. I'd go for VARCHAR with a length of 10 or so, unless your currency names are longer than 10 letters.

ilrak 12-15-2014 04:09 PM

Ok!

Also, how do I write the code to check which currency to use? I tried a couple of things that I thought would work (like a switch case) and failed (I'm a noob). Other than that, everything else seems to be working and easy!

Kyttias 12-15-2014 04:41 PM

What are:
  • the names of both your currencies? (VAR_A, VAR_B)
  • the name of the column you added to the shop table (which would be the same as the variable name you added to the top of the page)? (VAR_C)
  • the name of the column in the users table that holds the amount of the secondary currency? (VAR_D)

I was thinking it'd be something vaguely like this?
public function purchase(Item $item){
$mysidia = Registry::get("mysidia");
if($item->owner != $mysidia->user->username) Throw new NoPermissionException('Something is very very wrong, please contact an admin asap.');
else{

if ($VAR_C == "VAR_A") {
$item->quantity = $mysidia->input->post("quantity");
$cost = $item->getcost($this->salestax, $item->quantity);
$moneyleft = $mysidia->user->money - $cost;
if($moneyleft >= 0 and $item->quantity > 0){
$purchase = $item->append($item->quantity, $item->owner);
$mysidia->db->update("users", array("money" => $moneyleft), "username = '{$item->owner}'");
$status = TRUE;
}
else throw new InvalidActionException($mysidia->lang->money);
}
if ($VAR_C == "VAR_B") {
$item->quantity = $mysidia->input->post("quantity");
$cost = $item->getcost($this->salestax, $item->quantity);
$moneyleft = $mysidia->user->VAR_D - $cost;
if($moneyleft >= 0 and $item->quantity > 0){
$purchase = $item->append($item->quantity, $item->owner);
$mysidia->db->update("users", array("money" => $moneyleft), "username = '{$item->owner}'");
$status = TRUE;
}
else throw new InvalidActionException($mysidia->lang->money);
}

}
return $status;
}


All times are GMT -5. The time now is 06:15 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.