Jump to content
MakeWebGames

New inventory system


Canjucks

Recommended Posts

I have been working on the new item system in creating items - new equip items, effects etc that's all cool made it through that. The next phase is re-doing the way the black market is presented which I am now almost done which if not for @ags_cs4 may not have made it that far... Now that I have my layout I need to exclude an item from the list on display. What is throwing me is how to do that using the item types via settings with the new hooks etc on doing this. Using the image below say I want to exclude Melee Weapon. How do I best do this? 

            $item = new Items();
            $types = $item->types;
            
            foreach ($types as $typeKey => $type) {

                $type["items"] = $this->db->selectAll("SELECT `I_id` FROM `items` WHERE `I_type` = :type", array(
                    ":type" => $type["id"]
                ));

                foreach ($type["items"] as $itemKey => $itemID) {
                    $type["items"][$itemKey] = $item->getItem($itemID["I_id"]);
                }

                $types[$typeKey] = $type;
            }

The next bit of the code is about the new hook and publishing the page. I'm not 100% on what can happen in a foreach so if someone was about that can help guide me I really want to learn this as well. Does an If statement like if types[id] != id then continue with sql?

image.png.a6d765ef733b6db4a4098a5d9ff27f99.png

Link to comment
Share on other sites

3 hours ago, ags_cs4 said:

if only you want only one key from the array then use this  after the foreach

unset($types[3]); // 3 is the melee item type id

unset($types[3]); // 3 is the melee item type id

 

Thanks bud did the trick at first didn't see that it had. 🙂

The next thing is that I made the item type disappear but if you manually put it in the url the items will then load. What's the best way to stop that?

Edited by Canjucks
wrong info
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...