Bank Interest
Pre-Requirements
- Private Message System[/*]
- A Point System[/*]
- A Brain[/*]
First off you will want to make a file in:
/home/YOURUSERNAME/
This is so NO BODY can access the file and run it multiple times and what not.
You will want to name this file:
bankcron.php.
In this file type something like the following.
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require("public_html/config.php"); //get config
function pti($points){ //define the functions
if(($points >= '1') && ($points <= '49')){ //if the points is greater than 1 but less than 49
$inf = '5'; //inflation or interest is 5%
$new = '0.05'; //or decimal form is 0.05
} //end 5% interest
if(($points >= '50') && ($points <= '99')){ //or if points are 50 or more but less that 99
$inf = '4'; //interest is 4%
$new = '0.04'; //decimal is 0.03
} //end 4%
if(($points >= '100') && ($points <= '149')){ //100 but less than 149 is 3%
$inf = '3'; //the third interest rating..
$new = '0.03'; //decimal of 0.03
} //end 3%
if(($points >= '150') && ($points <= '199')){ //more than 150 but still less than 199
$inf = '2'; //is 2% interest..
$new = '0.02'; //which is 0.02 in decimal form
} //end 2%
if(($points >= '200')){ //person has more than 200+ points in bank
$inf = '1'; //or 1% interest
$new = '0.01'; //or 0.01 in decimal form
} //end it
if(($points == 0)){ //hehe if they dont have any yet they have a bank account
$inf = '0'; //0% inflation for this user :O
} //end
$m1 = ($points * $new); //do some math to calculate new points
$m1e = floor($m1); //round down
$m2 = ($m1e + $points); //total up the points..
return $m2; //return the new points
} //end the function
$getall = mysql_query("SELECT * FROM `bank` ORDER BY `id`"); //get all users from bank
while($gt = mysql_fetch_array($getall)){ //loop the results
$npts = pti($gt[points]); //new points the points in bank
$updatepts = mysql_query("UPDATE `bank` SET `points` = '$npts' WHERE `username` = '$gt[username]';") or die(mysql_error()); //update the users points or die with an error
$msg = "Hello $gt[username],
This is just a message to tell you that your bank interest has been added to your bank account.
<b>Old Balance</b>: $gt[points]
<b>New Balance</b>: $npts"; //message to be sent to the users
$date = date("l jS F Y h:i A"); //the date format
$newpm = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('$gt[username]','BOT-Interest','$date','Bank Interest','$msg');"); //Private Message the users
} //end the loop
?>
Then go into Cpanel > Cron Jobs and hit 'Simple'
Enter in the following:
that will be set at 4PM server time Every Thursday. Change it if you want :P