SMF Shop

SMFShop => Items => Topic started by: JRSofty on March 27, 2007, 10:19:20 pm

Title: Personal Interest Rates Item Available.
Post by: JRSofty on March 27, 2007, 10:19:20 pm
How would you like to give your users a chance to better their interest rates?

Now you can with the Personal Interest Rate project for SMFShop found here: http://intresthike.dev.dansoftaustralia.net/

Version 1.1 only adds the capability of personal interest rates and one item for buying increases.

Version 1.2 RC1 is currently out that gives two items. The original for buying an increase and the second one allows you to gamble for a better increase (administrator can set the values of both items). As well as allowing you to see your own personal interest rate bonus that it added on top of the bank interest.

I'm currently looking for people who are interested in testing the RC1 and giving me some feed back.

Enjoy
Title: Re: Personal Interest Rates Item Available.
Post by: feeble on March 28, 2007, 07:46:12 pm
nice mod
Title: Re: Personal Interest Rates Item Available.
Post by: Daniel15 on March 30, 2007, 07:14:25 pm
Nice work JRSofty :)
I've yet to try this item, but it sounds excellent. Keep up the good work! :D
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on March 30, 2007, 07:19:52 pm
If anyone wants a demo of it in action they can check it out at my homepage
Title: Re: Personal Interest Rates Item Available.
Post by: Aes-Sedai on April 28, 2007, 06:19:23 pm
Er.. how do you, once you have used the item, unuse it if you know what  I mean? Make your interest rate back to 0 again?
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on April 28, 2007, 06:27:30 pm
Hmm

Hadn't thought of that.

The idea is that your members can build up a higher interest rate, I had not intended any way for a way to lower it.

If you really really want to lower it and you have access to the database you can change the column in the smf_members table, other than that it is impossible.

I will take it as an idea for an enhancement on the next version.
Title: Re: Personal Interest Rates Item Available.
Post by: Aes-Sedai on April 28, 2007, 06:48:51 pm
Oh, okay, that's all right. It's just that I'm having a competition and after it ends I wanted the rates to go back to 0 to resume normal buying and selling.
Title: Re: Personal Interest Rates Item Available.
Post by: Aes-Sedai on May 02, 2007, 02:47:14 pm
Is there any troubleshooting pages? I added the Mod, checked the code and it seems all fine - but the interest is never added every day.

Actually, the bank isn't adding interest either (this is after a few days) despite the Cron Job I set.
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on May 16, 2007, 09:07:12 pm
I'm still working on the troubleshooting pages and I'm just back from vacation so it may be some time before they are ready.

If the CronJob is not working and interest isn't being calculated then the Mod won't work either.
Title: Re: Personal Interest Rates Item Available.
Post by: Aes-Sedai on May 17, 2007, 03:50:26 pm
Indeed, it isn't.
Title: Re: Personal Interest Rates Item Available.
Post by: sc2 on July 19, 2007, 12:52:28 pm
Hi JRSofty, this mod is a great idea, but I am having a problem I just can't seem to figure out what is wrong. I set it up and it all seems to be working fine. I gave myself the item to increase my personal interest rate to 1.5% and everyone else is on 0. Used the item, it updates my profile and also the shop pages with my new personal interest rate. I check the database and I see in the bankInterest column, I have 1.5 in my row and everyone else is on 0.

All good I thought. Until the cron job runs and EVERYBODY gets 1.5% interest, even though I should be the only one getting it and everyone else should stay the same. I checked that the dointerest.php is modified correctly and it is. I don't know what is wrong. Any help would be appreciated as I spent forever trying to work this one out!

Thank you for your time and any help you, or anyone else for that matter, can give me  :)

Oh, some extra details. I have the bank interest at 0% (with the bank enabled). When I put it on 0.2% before, and the cron job ran, everybody got an insane amount of credits... All was running well before the mod was installed. I figured I would rather have this mod and leave the bank interest at 0% because I don't mind not having it if I can get the personal interest rate working... thanks again for reading!
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 19, 2007, 01:28:56 pm
Hi Sc2 I'm on it. I'll have an answer for you within a day or so (hopefully).

[EDIT]

Good catch and I'm surprised I didn't catch this bug before.

Find
Code: [Select]
db_query("UPDATE {$db_prefix}members
  SET moneyBank = moneyBank + (moneyBank*{$interest_rate})", __FILE__, __LINE__);

Replace with:
Code: [Select]
db_query("UPDATE {$db_prefix}members
  SET moneyBank = moneyBank + (moneyBank*{$interest_rate}) WHERE ID_MEMBER = {$row['ID_MEMBER']}", __FILE__, __LINE__);

I forgot to put in the WHERE statement. so basically for each user people got extra interest. ;)

I'll be issuing a new version in the near future.
Title: Re: Personal Interest Rates Item Available.
Post by: sc2 on July 19, 2007, 01:30:59 pm
Wow, thanks for the quick reply!! Looking forward to an answer =) Many thanks !!!!!
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 19, 2007, 01:35:31 pm
Sorry Edited my original post.

Look above for the fix.
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 19, 2007, 01:37:39 pm
Forgot to mention that is suppose to be in the DoInterest.php file.
Title: Re: Personal Interest Rates Item Available.
Post by: sc2 on July 19, 2007, 01:40:12 pm
I am testing it now and will get back to you! Thanks!!!
Title: Re: Personal Interest Rates Item Available.
Post by: sc2 on July 19, 2007, 02:31:07 pm
Yep, that did it, thanks again!!glad it is finally working :D
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 19, 2007, 04:37:03 pm
Honestly I was seeing some strange interest issues on my forum as well. I just didn't know it was this causing it ;) and didn't have time to really look for it as I have tons of other projects under way as well.
Title: Re: Personal Interest Rates Item Available.
Post by: inkstains on July 31, 2007, 06:30:43 pm
excellent stuff love ya work

one question though, when the interest rate becomes negative does that mean what ever that negative percentage is, is deducted from the members bank?
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 31, 2007, 06:49:14 pm
Love the avatar ;)

Actually that is what should happen in theory but honestly I've not tested it.
Title: Re: Personal Interest Rates Item Available.
Post by: inkstains on July 31, 2007, 09:12:47 pm
cool i'll check it tommorow after the cronjob has run

one thing i noticed

when a user uses the add XXX to interest rate item the message they recieve is

Successfully added XXX to post count!

looks like this part here wasn't changed in AddToInterest.php

Code: [Select]
$result = db_query("UPDATE {$db_prefix}members
                            SET bankInterest = bankInterest + {$item_info[1]}
                            WHERE ID_MEMBER = {$ID_MEMBER}",
                            __FILE__, __LINE__);
        return "Successfully added {$item_info[1]} to post count!";
       
        //echo $item_info[1];
        die("dead");
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on July 31, 2007, 09:19:51 pm
 ::) I thought I caught all that.

thanks for the info I'll get it fixed with the rest of the bugs for that project  O0

BTW

Is anyone having problems with the script and CRONJOB?

I'm just wondering because my host says it's my code and not their CRONTAB (what they call Cronjobs) service that is the problem.

Their excuse is that if I can call the script via the browser and it works but they call it from shell and it doesn't then it is my script's fault. Although the script was running just fine until they upgraded us from PHP4 to PHP5.
Title: Re: Personal Interest Rates Item Available.
Post by: feildmaster on August 01, 2007, 12:57:09 am
The script works fine... In fact... so well I use your basic idea for some other things as well in crons... ^^

PHP5 does have some strange errors... Thats why I stayed with php4.
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on August 01, 2007, 05:08:06 pm
I had no choice my host upgraded the servers and I don't get to say anything :(

Oh well PHP4 is ending soon anyway.

I've been thinking of creating a CRON mod for SMF for people who don't know how or can't use cronjobs.

Still working out the planning for it but it might help lots of people especially those that use SMFShop.
Title: Re: Personal Interest Rates Item Available.
Post by: inkstains on August 01, 2007, 05:32:33 pm
it appears i have a boo boo every member is now "rich bitch" (chapelle kicks the llamas arse) with a bank balance of "4294967295" maybe i've missed something but i haven't had a chance to have a look anyone else had a similar problem?

i'm guessing it's something in the cronjob file that's stuffed up
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on August 01, 2007, 05:39:35 pm
You fell victim to this bug

http://www.daniel15.com/forum/index.php/topic,732.msg5848.html#msg5848

Just follow the replacement changes there and you will see that problem go away.

I have not yet updated the files to fix this in the actual download yet :blush: sorry been real busy with life right now.
Title: Re: Personal Interest Rates Item Available.
Post by: inkstains on August 01, 2007, 09:25:55 pm
You fell victim to this bug

http://www.daniel15.com/forum/index.php/topic,732.msg5848.html#msg5848

Just follow the replacement changes there and you will see that problem go away.

I have not yet updated the files to fix this in the actual download yet :blush: sorry been real busy with life right now.

that's cool cheers i shoulda read the thread, next question is can i reverse the changes and get everyone back to their original credit values? i imagine i can change the script to do a negative of the interest added? would that be right? cheers for the help man i'm still a little green when it comes to php and the sort
Title: Re: Personal Interest Rates Item Available.
Post by: JRSofty on August 01, 2007, 09:54:03 pm
You just have to be careful for three items:

1. Any new members joined since the script has run will change the outcome by removing an extra % per user extra.

2. If a member has added money to their account would have extra money removed.

3. Honestly since the increase was a % of a lower number and the now starting numbers will be higher then more money would be removed. For example if someone had 500 credits and after the script ran they now have 1000 credits. 1% of 1000  > 1% of 500.

So you would need to find some way to split up the % to remove versus the number of times the original script ran (or the total number of members at the time of the cronjob).

OR

If all this math is too much for you (it almost is for me) I would suggest that you find who has the most money. Do a rule of thumb and remove that % from everyone. Some may end up with more than they originally had and some may end up with less but at least it would be a bit fair.