Jump to content

making a game.


mandukar

Recommended Posts

hi I'm very new with php but understand most of the basics..

i'm in abit of a headace mode atm, and was wondering if someone could help me..

I am trying to enable players to tranfer money from there bank to another players bank.

I have been able to get it so that it'll take money from the player but the other player doesn't get it.

heres a copy of the script..
any help will be most greatful from mandukar.

<?
<ul>
<li><a href=donate.php?view=donate>Donations</a>
</ul>
<?
if ($view == donate) {
print "Please donate to a player, and help it out financially.";
print "<form method=post action=donate.php?view=donate&step2=donate>";
print "Donate <input type=text size=5 name=amount value=0> <select name=type><option value=credits>Credits</option><option value=platinum>Platinum</option></select>
<input type=text name=aid> as an <select name=donate>

to player. <input type=submit value=Donate>";
print "</form>";
if ($step2 == donate) {
if ($amount > $stat[$type]) {
print "You don't have enough $type.";
} else {
mysql_query("update players set $type=$type-$amount where id=$stat[id]");
print "You donated <b>$amount $type</b> to the player.";
mysql_query("update players set credits='$bank' where id=$aid");
}
}
}
?>
Link to comment
Share on other sites

[code]

        <ul>
        <li><a href=donate.php?view=donate>Donations[/url]
        </ul>


<?php
        if ($view == donate) {
        print "Please donate to a player, and help it out financially.";
        print "<form method=post action=donate.php?view=donate&step2=donate>";
        print "Donate <input type=text size=5 name=amount value=0> <select name=type><option value=credits>Credits</option><option value=platinum>Platinum</option></select>
        <input type=text name=aid> as an <select name=donate>
       
        to player. <input name =donate_to type=submit value=Donate>";
        print "</form>";
        if ($step2 == donate) {
            if ($amount > $stat[$type]) {
              print "You don't have enough $type.";
            } else {

              $donate_to = $_POST['donate_to'];

              mysql_query("update players set $type=$type-$amount where id=$stat[id]");
              print "You donated $amount $type to the player.";

              mysql_query("update players set credits=$bank-$amount where id=$aid");
              mysql_query("update players set credits=$bank+$amount where id=$donate_to");

            }
        }
      }
?>

[/code]

You only had a mysql query updating ONE persons item amount when the item was transferred. You also didn't do your query right...you were updating the persons type with whatever amount was sent/given. You need to update it by adding/subtacting to what they have.

For example: If they have $1000 you want to do a query that says update money 1000+amount transferred for the person recieving the money.
Link to comment
Share on other sites

ok, would that go somthing like...

[quote]<?
if ($view == Give) {
print "tgive some members some money.";
print "<form method=post action=admin.php?view=give&step2=give>";
print "Donate <input type=text size=5 name=amount value=0> <select name=type><option value=credits>Credits</option></select>
<input type=text name=aid>
to player. <input type=submit value=give>";
print "</form>";
if ($step2 == give) {
if ($amount > $stat[$type]) {
print "You don't have enough $type.";
} else {
  mysql_query("update players set $type=$type-$amount where id=$stat[id]");
              print "You donated $amount $type to the player.";
$give = mysql_query("UPDATE MEMBERS SET CASH=CASH+$amount WHERE USERNAME='$username'");

            }
        }
      }
?>[/quote]
Link to comment
Share on other sites

I am assuming admin.php is just a feature where you can add money to anyones accounts...so this is what you would do.

[code]

<?php

if ($_POST['give']){

$id = $_POST['id'];
$amount = $_POST['amount'];

mysql_query("UPDATE users SET money=money+$amount WHERE playerID='$id'");

echo "Successfully gave money to player #$id.<p>";

}

print<<<HERE

<form action="admin.php" action="post">

Player ID: <input type="text" name="id"><p>
Amount to give: $<input type="text" name="amount">

<input type="submit" name="give" value="Give Money">

</form>

HERE;

?>

[/code]

You might have to set the values in the UPDATE query to match your DB rows. Other then that, I hope this is what you are looking for ^^
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.