Jump to content
MakeWebGames

Recommended Posts

Posted

i am asking for some help, the itemmarket puts the money into the 'on hand'

i have seriously modded my game to were bank accounts do not cost to open

so i would like the money to go into there bank.

just to clear it up

Player 2 has 50 crystals on the market for $1,000,000

i buy it

my money leaves my money on hand and goes into there bank.

so i have to take money out of my bank to buy something but if player 2 gets mugged he will not lose any money

 

<?php
/*
//Created by raDiO acTivE ~ Free script for CE users
//Please leave this notice here as courtesy
//Free Revamp of MCcode V2
//Enjoy
*/

include "globals.php";
print "<h3>Item Market</h3>";
   switch($_GET['action'])
   {
       case "buy":
           item_buy();
           break;

       case "remove":
           itemm_remove();
            break;

       default:
           imarket_index();
           break;
   }
function imarket_index()
   {
global $db,$ir,$c,$userid,$h;
    print "Viewing all listings...
       <table width=75% cellspacing=1 class='table'> 
       <tr style='background:gray'> 
               <th>Adder</th> 
                   <th>Item</th> 
                   <th>Price</th> 
               <th>Links</th> 
       </tr>";

     $q = $db->query("SELECT 
                   im.`imID`,`imITEM`,`imADDER`,`imPRICE`,`imCURRENCY`,
                   i.`itmid`,`itmtype`,`itmname`, 
                   u.`userid`,`username`,
                   it.`itmtypeid`,`itmtypename` FROM itemmarket im 
           LEFT JOIN `items` i ON im.imITEM = i.itmid
           LEFT JOIN `users` u ON u.userid = im.imadder
           LEFT JOIN `itemtypes` it ON i.itmtype = it.itmtypeid
       ORDER BY i.itmtype, i.itmname ASC"
);

// Created by raDiO acTivE ~ Free script for CE users
     $lt="";
             while (    
               $r=$db->fetch_row($q)
                   ) 
                       {
                           if($lt!=$r['itmtypename'])
                           {
                           $lt=$r['itmtypename'];
                       echo"\n
                       <tr style='background: gray;'>
                       <th colspan=4>{$lt}</th>
                       </tr>
                       ";   
                           }

                         if($r['imCURRENCY']=="money") 
                         { 
                               $price="\$".number_format($r['imPRICE']); 
                             } 
                           else 
                         { 
                               $price = number_format($r['imPRICE'])."  crystals"; 
                             }

                  if($r['imADDER'] == $userid) 
                       {
                       $link = "[[url='itemmarket.php?action=remove&ID=".$r[']Remove[/url]]"; 
                       } 
                  else
                       { 
                       $link = "
                           [[url='itemmarket.php?action=buy&ID=".$r[']Buy[/url]] 
                         ";
                  }     
        echo "\n
        <tr> 
           <td>   [url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> 
            <td>{$r['itmname']}</td> <td>$price</td>
           <td>[[url='iteminfo.php?ID={$r[']Info[/url]] $link</td> 
        </tr>";
    }           
}
function itemm_remove()
{
global $db,$ir,$c,$userid,$h;
$r = $db->query(sprintf("
                       SELECT
                       im.`imID`,`imITEM`,`imADDER`,`imPRICE`,`imCURRENCY`,   
                       i.`itmid`,`itmtype` FROM `itemmarket` im 
                         LEFT JOIN `items` i 
                         ON im.imITEM = %d
                         WHERE `imID` = %u 
                         AND `imADDER` = %d",
                           i.itmid,   
                           (INT)$_GET['ID'],
                           $userid
                         )
                         );



      if(!$db->num_rows($q))
           {
               echo "Error, either this item does not exist, or you are not the owner.

                       [url='itemmarket.php']> Back[/url]";
                       $h->endpage();
                       exit;
      }
      $r=$db->fetch_row($q);
       item_add($userid, $r['imITEM'], 1);
       $i=($db->insert_id()) ? $db->insert_id() : 99999;

$delete = sprintf("DELETE FROM `itemmarket` WHERE imID= %u",
          (INT)$_GET['ID']);
          $db->query($delete);
$insert = sprintf("INSERT INTO `imremovelogs` 
               (imrID,imrITEM,imrADDER,imrREMOVE,imrIMID,imrINVID,imrTIME,imrCONTENT)
               VALUES
                (%d,%d,%d,%d,%d,%u,unix_timestamp(),
                   {$ir['username']} removed a {$r['itmname']} from the item market.)",
               '',
               $r['imITEM'],
               $r['imADDER'],
               $userid,
               $r['imID']  ,
               $i,
               $ir['username']
               );
       echo "  Item removed from the market. 

               [url='itemmarket.php']> Back[/url]";
       }
             // Created by raDiO acTivE ~ Free script for CE users   

function item_buy()
{
global $db,$ir,$c,$userid,$h;
$q = $db->query(sprintf("SELECT
                       `imID`,`imITEM`,`imADDER`,`imPRICE`,`imCURRENCY` 
                       FROM `itemmarket` im 
                       LEFT JOIN `items` i 
                       ON i.itmid = %d 
                       WHERE imID = %u",
                  im.imITEM,
                  (INT)$_GET['ID'] 
           )
           );

      if(!$db->num_rows($q))
       {
           echo "Error, either this item does not exist, or it has already been bought.

                   [url='itemmarket.php']> Back[/url]";
                   $h->endpage();
                   exit;
       }

       $r = $db->fetch_row($q);
       $curr = $r['imCURRENCY'];
if($r['imPRICE'] > $ir[$curr])
   {
       echo "Error, you do not have the funds to buy this item.

              [url='itemmarket.php']> Back[/url]";
              $h->endpage();
              exit;
   }

       item_add($userid, $r['imITEM'], 1);
       $i=($db->insert_id()) ? $db->insert_id() : 99999;


       $db->query(sprintf("DELETE FROM `itemmarket` 
                   WHERE `imID` = %u",
                   (INT)$_GET['ID']
                   )
                   );

       $db->query(sprintf("UPDATE`users` 
                   SET $curr = $curr-%d 
                   WHERE userid=%d",
                   $r['imPRICE'],
                   $userid
                   )
                   );

       $db->query(sprintf("UPDATE `users` 
                   SET $curr = $curr+%d    
                   WHERE userid = %u",
                   $r['imPRICE'],
                   $r['imADDER']
                   )
                   );
            if($curr=="money")
            {
               event_add($r['imADDER'],
               "[url='viewuser.php?u=$userid']{$ir['username']}[/url] 
               bought your {$r['itmname']} item from the market for 
               \$".number_format($r['imPRICE']).".
            ");

            $db->query(sprintf("INSERT INTO `imbuylogs` 
                      (imbID,imbITEM,imbADDER,imbBUYER,imbPRICE,imbIMID,imbINVID,imbTIME,imbCONTENT) 
                        VALUES     
                       (%u,%d,%d,%d,%d,%d,%u, unix_timestamp(),
                       '{$ir['username']} bought a 
                        {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']}')",
                      '',
                      $r['imITEM'],
                      $r['imADDER'],
                      $userid,
                      $r['imPRICE'],
                      $r['imID'],
                      $i)
       );  // Created by raDiO acTivE ~ Free script for CE users

       echo "You bought the {$r['itmname']} from the market for \$".number_format($r['imPRICE']).".";
   }
       else
   {
event_add(
       $r['imADDER'],
       "[url='viewuser.php?u=$userid']{$ir['username']}[/url]
        bought your {$r['itmname']} item from the market for 
       ".number_format($r['imPRICE'])." crystals.");

            $db->query(sprintf("INSERT INTO `imbuylogs` 
                      (imbID,imbITEM,imbADDER,imbBUYER,imbPRICE,imbIMID,imbINVID,imbTIME,imbCONTENT) 
                        VALUES     
                       (%u,%d,%d,%d,%d,%d,%u, unix_timestamp(),
                       '{$ir['username']} bought a 
                        {$r['itmname']} from the item market for \${$r['imPRICE']} from user ID {$r['imADDER']}')",
                      '',
                      $r['imITEM'],
                      $r['imADDER'],
                      $userid,
                      $r['imPRICE'],
                      $r['imID'],
                      $i)
       );

echo "You bought the {$r['itmname']} from the market for ".number_format($r['imPRICE'])."  crystals.";
   }
}

$h->endpage();
?>
Posted

Re: [Help] itemmarket (v2)

i have already gave everyone a free bank and changed the reg. page to put bankmoney=0

so that is all covered, and for Iamwicked what line are you referring to, i did change it and it took it from buyers bank and put it in sellers banks

it should be buyers money on hand

and put into sellers bankmoney

Posted

Re: [Help] itemmarket (v2)

 

i have already gave everyone a free bank and changed the reg. page to put bankmoney=0

so that is all covered, and for Iamwicked what line are you referring to, i did change it and it took it from buyers bank and put it in sellers banks

it should be buyers money on hand

and put into sellers bankmoney

 

Just change the query from 'money' to 'bankmoney'

 

Check the php file that deals with the purchasing and look for the db query that does what iamwicked stated. Easy change.

Sp1d3r

www.chaosrelic.com

Posted

Re: [Help] itemmarket (v2)

I'll ignore your last post as it seems you had a retard moment..

 

        $db->query(sprintf("UPDATE`users` 
                   SET $curr = $curr-%d 
                   WHERE userid=%d",
                   $r['imPRICE'],
                   $userid
                   )
                   );

       $db->query(sprintf("UPDATE `users` 
                   SET $curr = $curr+%d    
                   WHERE userid = %u",
                   $r['imPRICE'],
                   $r['imADDER']
                   )
                   );

 

Try to read your own code next time and not bs on the forums when someone tries to help you.

Sp1d3r

www.chaosrelic.com

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