Announcement

Collapse
No announcement yet.

Finding items

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Finding items

    does anyone know what is wrong with ,when a item is found it does not to the user inventry
    Code:
     //-- Finding items query
    $fia=(int) rand(10000,50000);
    $fib=(int) rand(10000,50000);
    if($fia == $fib)
    {
    $iq=mysql_query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c);
    $r=mysql_fetch_array($iq);
    $item=$r['itmid'];
    $userid=$ir['userid'];
    mysql_query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c);
    event_add($userid,"You found a {$r['itmname']} While Walking Around the city.",$c);
    }
    
     }

  • #2
    Re: Finding items

    theres a } at the very bottem try to delete that maybe? :?
    [img width=468 height=59]http://i780.photobucket.com/albums/yy83/ZyzamicNetworkGraffix/EpicFuseSigneture.jpg[/img]
    ...Graphic Designer always looking for work...

    Comment


    • #3
      Re: Finding items

      thats not the problem the problem is that the item dosent get sent to user inventry

      Comment


      • #4
        Re: Finding items

        Change the mysql query to $db->query(then the rest

        See if that works

        +1 me if it works
        Made by me
        [img width=160 height=60]http://i568.photobucket.com/albums/ss129/eido_2009/eidosiggy.jpg[/img]

        Comment


        • #5
          Re: Finding items

          Code:
           //-- Finding items query
          $fia=(int) rand(10000,50000);
          $fib=(int) rand(10000,50000);
          if($fia == $fib)
          {
          $iq=$db->query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c);
          $r=mysql_fetch_array($iq);
          $item=$r['itmid'];
          $userid=$ir['userid'];
          $db->query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c);
          event_add($userid,"You found a {$r['itmname']} While Walking Around the city.",$c);
          }
          
           }
          Try that.
          Made by me
          [img width=160 height=60]http://i568.photobucket.com/albums/ss129/eido_2009/eidosiggy.jpg[/img]

          Comment


          • #6
            Re: Finding items

            for some reason i get this error

            QUERY ERROR: Column count doesn't match value count at row 1
            Query was INSERT INTO inventory VALUES ('', 59, 1, 1)

            Comment


            • #7
              Re: Finding items

              Originally posted by Feky
              for some reason i get this error

              QUERY ERROR: Column count doesn't match value count at row 1
              Query was INSERT INTO inventory VALUES ('', 59, 1, 1)
              Check the column's that are in inventory, you may have one for damage to the item or somthing of the following.
              if so just ad another value to that query e.g:
              Code:
              $db->query("INSERT INTO inventory VALUES (' ', $item, $userid, 1,' ')",$c);
              You should also start to think about securing them.

              Comment


              • #8
                Re: Finding items

                Ok could i ask what was so hard about this?..
                Code:
                <?php //for colors of course :D
                $a = (int) rand(10000, 50000);
                $b = (int) rand(10000, 50000);
                if($a == $b) {
                  $row = $db->fetch_row($db->query('SELECT `itmid`, `itmname` FROM `items` WHERE `itmbuyable` = 1 ORDER BY RAND() LIMIT 1'));
                  item_add($ir['userid'], $row['itmid'], 1);
                  event_add($ir['userid'], 'You found a '. $row['itmname'] .' While Walking Around the city.', $c);
                }
                There that should work.

                Comment


                • #9
                  Re: Finding items

                  why not just modify explore.php right under
                  <?php
                  include "globals.php";
                  $tresder=(int) rand(100,999);

                  add:

                  $num=rand(1, 100);
                  switch($num)
                  {
                  case 10:
                  Print "you see someone getting beaten down better move on!
                  ";
                  break;
                  case 40:
                  $hospital=(int) rand(1,10);
                  $loseruser = $ir['userid'];
                  $hospreason = 'Beaten down in a back alley.';
                  $db->query("UPDATE users SET hospital=$hospital WHERE userid=$userid",$c);
                  $db->query("UPDATE users SET hospreason='$hospreason' WHERE userid=$userid",$c);
                  die ("!Random Event! turn down one street and get beat down!

                  ");
                  break;
                  case 60:
                  $gainer = rand(1,5);
                  print "While looking around you find some cash and gained $gainer dollars!";
                  $db->query("update users set money=money+$gainer where userid=$userid",$c);
                  break;
                  }

                  just a thought,

                  Comment

                  Working...
                  X