Jump to content
MakeWebGames

Finding items


Feky

Recommended Posts

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

}
Link to comment
Share on other sites

Re: Finding items

 

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

Link to comment
Share on other sites

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)

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.

Link to comment
Share on other sites

Re: Finding items

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.

Link to comment
Share on other sites

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,

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