Jump to content
MakeWebGames

Formula Trouble!


chaoswar4u
 Share

Recommended Posts

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.

Link to comment
Share on other sites

Guest Anonymous

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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Guest Anonymous

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...