PDA

View Full Version : Finding items



Feky
06-19-2009, 07:52 PM
does anyone know what is wrong with ,when a item is found it does not to the user inventry

//-- 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);
}

}

EpicFuse
06-19-2009, 08:02 PM
theres a } at the very bottem try to delete that maybe? :?

Feky
06-19-2009, 08:04 PM
thats not the problem the problem is that the item dosent get sent to user inventry

eido
06-19-2009, 08:43 PM
Change the mysql query to $db->query(then the rest

See if that works

+1 me if it works

eido
06-19-2009, 08:58 PM
//-- 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.

Feky
06-19-2009, 09:02 PM
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)

Kasabian
06-19-2009, 10:55 PM
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:

$db->query("INSERT INTO inventory VALUES (' ', $item, $userid, 1,' ')",$c);

You should also start to think about securing them.

CrazyT
06-20-2009, 02:13 AM
Ok could i ask what was so hard about this?..

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

virtualshogun
06-20-2009, 10:55 AM
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,