Jump to content
MakeWebGames

Recommended Posts

Posted

Yeah! Its quite easy actually. I'm assuming MCCV2, correct?

 

//Assuming MCCV2
$gid = 12; //Item ID to test for.
$amounttogive = 6; //Amount of item to give
$itemtogive = 1; //Item to give
//Check for item id. Make sure to set it in the config area above.
$query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = {$gid} && `inv_userid` = {$userid}");
$i=$db->fetch_row($query);
if(!$i['inv_itemid'] == $gid)
{
   print "Item required not found in your inventory. If you think this is incorrect, message an admin.";
   $h->endpage();
}
else
{
   //item_add(user,item,amount);
   //All parameters are int.

   item_add($userid,$itemtogive,$amounttogive);

   //item_remove(user,item,amount);
   //All parameters are int.
   item_remove($userid,$gid,1);
}
Posted

Yes it is v2.

I'm assuming that would go in itemuse.php? If there is more than 1 say "box of goodies" to open. i.e. box of sweets, box of bullets, etc, etc. How would the script be written then?

Posted

I've personally made a different page for my own custom item use.

Here's how I did it with multiple consumer donator packs.

if (!isset($_GET['redeem']))
{
   $_GET['redeem'] = '';
}
switch ($_GET['redeem'])
{
case 'pack1':
   pack_1();
   break;
case 'pack2':
   pack_2();
   break;
default:
   dollar_pack_home();
   break;
}
function dollar_pack_home()
{
die("404");
}
function pack_1()
{    $packid=136;            //Item ID
   $packmoney=50000;        //How much money does the user receive?
   $packddays=30;            //Donator days received
   $packcrystals=50;        //Crystals received.
   $packiq=50;                //IQ received
   global $db, $userid;
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = $packid && `inv_userid` = $userid");
   $i=$db->fetch_row($query);
   if(!$i['inv_itemid'] == $packid)
   {
   //No pack
   }
else
{
//etc
}

}
function pack_2()
{  
//Same code above, just tweaked differently.
}

 

And on inventory.php;

if ($i['itmid'] == $Item)
{
      echo " [<a href='#'>Link</a>]";
}

 

I'm sure there's cleaner ways to do it. Meh.

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