chaoswar4u Posted August 11, 2008 Share Posted August 11, 2008 Ive been working on the following formula. This works but I require it do 1 more thing but having trouble making it do what I require. $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/100*bankpercent) WHERE bankmoney > 0 AND laston>unix_timestamp()-86400"); I require for the above to credit only interest where bankmoney is above > 0 but below the users bankmax amount. I tried this but it dosent work. $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/100*bankpercent) WHERE bankmoney > 0 AND bankmoney < bankmax AND laston>unix_timestamp()-86400"); This is required to stop members getting continued interest which will make them exceed there bank capacity limit. Any help would be greatful. Many thx in advance. Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted August 11, 2008 Share Posted August 11, 2008 Re: Formula Trouble! <?php $sql = sprintf ( "UPDATE `users` ". "SET `bankmoney` = LEAST(`bankmax`, `bankmoney` * (1 + (100 / `bankpercent`))) ". "WHERE ((`bankmoney` > 0) AND (`laston` > (UNIX_TIMESTAMP() - %u)))", 1 * 86400 /* 1 day */ ); ?> (untested) Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted August 12, 2008 Author Share Posted August 12, 2008 Re: Formula Trouble! Id like to thank you nyna for your reply. Your code did have an issue but I changed a little to make it work ok with my game however on testing it as it would cause me an issue. The feature im adding is being put in a game already established. Many people will be over the banks capacity. What I require is for the cron to detect people over the bankmax and not issue any interest. This will get members to upgrade there banks etc. The code you provide works but in my example would reset members banks to the bankmax limit would result in members losing money. As this will take time for members to upgarde and take on the new system iI dont wish to have there money removed just interest stop as a say punishment for being over limit. Can this be done? Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted August 12, 2008 Share Posted August 12, 2008 Re: Formula Trouble! <?php $sql = sprintf ( "UPDATE `users` ". "SET `bankmoney` = LEAST(`bankmax`, `bankmoney` * (1 + (100 / `bankpercent`))) ". "WHERE ((`bankmoney` > 0) AND (`laston` > (UNIX_TIMESTAMP() - %u)) AND (`bankmoney` < `bankmax`))", 1 * 86400 /* 1 day */ ); ?> (untested) Quote Link to comment Share on other sites More sharing options...
chaoswar4u Posted August 12, 2008 Author Share Posted August 12, 2008 Re: Formula Trouble! Hi. Thx again for the reply. Ive messed around with it abit as it wasnt calculating correctly for my environment. However with your help ive modified it to the following below. This provides interest up to capacity and anything over result in no interest. Woot! db->query("UPDATE `users` "."SET `bankmoney` = LEAST(`bankmax`, `bankmoney` / 100 * `bankpercent` + `bankmoney`) "."WHERE ((`bankmoney` > 0) AND (`laston` > (UNIX_TIMESTAMP() - 86400)) AND (`bankmoney` < `bankmax`))"); Many thx Nyna Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.