Jump to content
MakeWebGames

need help lol again


javance

Recommended Posts

<?php
include_once(DIRNAME(__FILE__) . '/globals.php');
echo "<h3>Town Bank</h3><h4>Welcome to the Bank, Here you can deposit your cash to keep it safe from other players!</h4><br />";
if ($ir['bankmoney'] > -1) {
       switch ($_GET['page']) {
               case "deposit": deposit(); break;
               case "withdraw": withdraw(); break;
               default: index(); break;
       }
} else {
       if (isset($_GET['buy'])) {
               if ($ir['money'] > 49999) {
                       echo "<b>Success:</b> You have paid <b>$50,000</b> for a bank account.<br />
                             Would you like to go to your bank account?<br /><br />
                             <a href='bank.php'>Yes</a> | <a href='explore.php'>No</a>";
                       $db->query("UPDATE users SET money=money-1000,bankmoney=0 WHERE userid=$userid");
               } else {
                       echo "<b>Error:</b> You do not have enough cash to open an account!<br /><br /> &gt <a href='explore.php'>Back</a>";
               }
       } else {
               echo "<b>Bank Manager:</b> Hey, <i>" . $ir['username'] . "</i>, Welcome to the Bank.<br />
                     Here you can deposit your cash so it doesn't get stolen by other players.<br />
                     To open a bank account it will cost <b>$50,000</b>, Would you like to open an account?<br /><br />
                     <br /><a href='bank.php?buy'>Yes please</a> | <a href='explore.php'>No thanks</a>";
       }
}
function index()
{
       global $db, $ir, $c, $userid, $h;
       echo "You currently have <b>" . money_formatter($ir['bankmoney']) . "</b> in your bank account.<br /><br />
             <table width='80%' class='table'><tr><th width='50%'>Deposit Cash</th><th>Withdraw Cash</th></tr>
             <tr><td style='text-align:center;'> <br />
             <form action='bank.php?page=deposit' method='post'>
             <input type='text' name='deposit' value='{$ir['money']}' /><br />
             <input type='submit' value='Deposit' /></form></td>

             <td style='text-align:center;'> <br /><form action='bank.php?page=withdraw' method='post'>
             <input type='text' name='withdraw' value='{$ir['bankmoney']}' /><br />
             <input type='submit' value='Withdraw' /></form></td> </tr> </table>";
}
function deposit()
{
       global $db, $ir, $c, $userid, $h;
       $_POST['deposit'] = abs((int) $_POST['deposit']);
       if ($_POST['deposit'] > $ir['money']) {
               echo "<b>Error:</b> You do not have enough cash to deposit that amount!<br /><br /> &gt <a href='bank.php'>Back</a>";
       } else {
               $fee = ceil($_POST['deposit'] * 100 / 100);
               if ($fee > 0) {
                       $fee = 0;
               }
               $gain = $_POST['deposit'] - $fee;
               $ir['bankmoney'] += $gain;
               $db->query("UPDATE users SET bankmoney=bankmoney+$gain, money=money-{$_POST['deposit']} where userid=$userid");
               echo "You hand over <b>" . money_formatter($_POST['deposit']) . "</b> to be added into your bank account.<br /><br />
                     <b>Bank Manager:</b> Okay <i>" . $ir['username'] . "</i>, The cash has been added to your bank account.<br /><br />
                     You now have <b>" . money_formatter($ir['bankmoney']) . "</b> in your bank account.<br /><br />
                     &gt <a href='bank.php'>Back</a>";
       }
}
function withdraw()
{
       global $db, $ir, $c, $userid, $h;
       $_POST['withdraw'] = abs((int) $_POST['withdraw']);
       if ($_POST['withdraw'] > $ir['bankmoney']) {
               echo "<b>Error:</b> You do not have enough banked cash to withdraw that amount!<br /><br /> &gt <a href='bank.php'>Back</a>";
       } else {
               $gain = $_POST['withdraw'];
               $ir['bankmoney'] -= $gain;
               $db->query("UPDATE users SET bankmoney=bankmoney-$gain, money=money+$gain where userid=$userid");
               echo "You ask for <b>\$" . $gain . "</b> to be taken from your account.<br /><br />
                     <b>Bank Manager:</b> Okay <i>" . $ir['username'] . "</i>, Here is your cash.<br /><br />
                     You now have <b>" . money_formatter($ir['bankmoney']) . "</b> in your bank account.<br /><br />
                     &gt <a href='bank.php'>Back</a>";
       }
}
$h->endpage();
?> 

 

tHEY DONT HAVAE IT IN THERE, ANY SUGGESTIONS

Edited by Dominion
added code tags
Link to comment
Share on other sites

INT can go as low as -2147483648 and so high as 2147483648 and BIGINT can go as low as -9223372036854775808 and so high as 9223372036854775808 which is a huge difference..

Maybe it has something to do with the INT in these lines?? (in the script you posted.. -.-")

on line 44;

        $_POST['deposit'] = abs((int) $_POST['deposit']);

on line 64;

        $_POST['withdraw'] = abs((int) $_POST['withdraw']);

:p

Edited by H4x0r666
Link to comment
Share on other sites

2147483647 is the maximum value a signed integer can hold. The issue might not be php, but mysql has troubles with this as the maximum value will never exceed 2147483647. Changing the data type in the database might help. Change this to bigint for larger numbers.

 

Otherwise php doesn't seem to make much of a problem of it. It just changes ints to floats...

$var = 2147483648;
$var = abs((int) $var);
var_dump($var);

 

output:

float(2147483648)
Link to comment
Share on other sites

how do you make it where you can make how many cash you want into the bank like the max amount 99999999999999999999999999999999999999999999999 and thats the max amount for withdraw, need help

Sorry, but why on earth would a player have more than 2 billion in a game? The game seems to have an economy worse than the eurozone, and the stats, maybe you should lower the gains from the gym, but I'm guessing you dont know how to do that.

Maybe you should either learn how to do basic problems like this, or pay someone to do it. Your game would highly benifit from either of these, as all your problems will be fixed, quickly and properly.

 

Also, you could make the integer unsigned, therefore changing its range from -2147483648 - 2147483648 to 0 - 4294967295. This helps by making sure it never goes negative, and/or increased the highest value.

Edited by Danny696
Link to comment
Share on other sites

Sorry, but why on earth would a player have more than 2 billion in a game? The game seems to have an economy worse than the eurozone, and the stats, maybe you should lower the gains from the gym, but I'm guessing you dont know how to do that.

Maybe you should either learn how to do basic problems like this, or pay someone to do it. Your game would highly benifit from either of these, as all your problems will be fixed, quickly and properly.

 

Also, you could make the integer unsigned, therefore changing its range from -2147483648 - 2147483648 to 0 - 4294967295. This helps by making sure it never goes negative, and/or increased the highest value.

I did that so players wont be bored and they can go on forever

Link to comment
Share on other sites

2147483647 is the maximum value an integer can hold. The issue might not be php, but mysql has troubles with this as the maximum value will never exceed 2147483647. Changing the data type in the database might help. Change this to bigint for larger numbers.

 

Otherwise php doesn't seem to make much of a problem of it. It just changes ints to floats...

$var = 2147483648;
$var = abs((int) $var);
var_dump($var);

 

output:

float(2147483648)

bigint with 255 (in my sql ) will go up to a really really really large number, thats what i use stats and stuff for, and where do i put that cariable code thingy and how do i change it to bigint

Link to comment
Share on other sites

I did that so players wont be bored and they can go on forever

Players do get bored when its far to easy to get money, youll have 1 or two players at the most, ive seen games where 1 or two players have 1 million in money, and they have 1000+ players online at any time, and it was nothing special.

Link to comment
Share on other sites

alphacrime.com is awesome check it out username is isay123 and pass is isay123 and it has that with alot of people and its kinda hard to get cash

IMO, not nothing special, rather it takes long to get cash or not, everything on there has been done. Nothing different then the rest of the games.

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.

×
×
  • Create New...