My problem is that so far I have been adding generic items that are all the same, but when someone cooks something the health bonus can be different based on how it was cooked, what it was cooked with, etc.
I am not sure how to approach this. I made a table called crafted_foods and when a food is made I add all its stats to that table. My plan was to draw from that like I would when someone received an item from mining or harvesting and then insert it into the inventory. My problem is that with the items not having an id number until they are created, I do not know how to put them in the inventory.
I know that probably does not make sense so let me try and describe it with code.
When an item is successfully cooked I first run this:
Code: Select all
$SQL1 = "INSERT into crafted_food(owner, name, class, energy, health, value, randid) VALUES ('$player', 'cooked food', 'crafted_food', '$stataddenergy', '$stataddhp', '$value', '$randid1')";
mysql_query($SQL1) or die("could not add to crafted foods");
My plan for getting it into the inventory was to have this right after the above query:
Code: Select all
$SQL2 = "INSERT into inventory(id, name, class, item_id, randid) VALUES ('$player','$name','crafted_food', '$item_id', '$randid2')";
mysql_query($SQL2) or die("could not add to inventory");
Does this make sense? How can I make the items distinguishable if I do not have an id? Is there a better way to do this? Is it something simple I am not seeing?
Thanks for any help.