Uridium Posted January 23, 2023 Posted January 23, 2023 this mod will allow you to add images to your inventory items.. Let me get my edits together and i'll post the script just 2 files to edit and an sql insert for the item names goto your phpmyadmin go to your table and click on SQL and add this ALTER TABLE inventory ADD pic varchar(255); then open modules/installed/inevntory/hooks/meta.php and add new Hook("itemMetaData", function () { global $db; return array( "id" => "pic", "sort" => 11, "width" => 12, "label" => "Item Image (usually modules/installed/inventory/images/NAME OF IMAGE.jpg", "type" => "textarea", "rows" => 1, "validate" => function ($value) { return true; } ); }); now open up modules/installed/inevntory/inventory.tpl.php and find on mine its line 26-27 <div class="panel-heading"> Information </div> underneath add <div class="panel-body"> <center><img src="{pic}"></center> </div> and your done 4 Quote
Uridium Posted January 26, 2023 Author Posted January 26, 2023 2 days and no replies ???? years ago i would have had 50 - 90 replies ? Is it time to give up ? Quote
URBANZ Posted January 26, 2023 Posted January 26, 2023 nice addition but i would say there is no need to touch the database, you can just use the item id as the image name instead of adding data that isn't needed. Quote
Uridium Posted January 26, 2023 Author Posted January 26, 2023 14 hours ago, URBANZ said: nice addition but i would say there is no need to touch the database, you can just use the item id as the image name instead of adding data that isn't needed. ah wasnt aware of that im still in MCCODES mine frame Thank ya Urb.. 2 Quote
gamble Posted January 27, 2023 Posted January 27, 2023 I wouldn't say what you did was wrong by any means. I think this comes down to do you want a clean tidy database, or do you want easily maintainable files. Personally I like your way due to the maintainability of the files...I know what hammer.png is every time, not always was 42.png is. You could always find the middle ground and have null as a default representing {ID}.png or if there's a value you can pull that image instead. Best of both worlds Quote
Veramys Posted January 27, 2023 Posted January 27, 2023 On 1/25/2023 at 8:12 PM, Uridium said: 2 days and no replies ???? years ago i would have had 50 - 90 replies ? Is it time to give up ? Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you. Quote
newttster Posted January 27, 2023 Posted January 27, 2023 8 hours ago, Veramys said: Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you. Good grief. Did you put on your asshole hat today? It didn't seem to me that he was looking for validation. Lots of the older members of this site do not necessarily know it's open again, under new management. And the ones that do, are doing as they've always done; submitting content ... for free, I might add. Given how active the site used to be, it's not surprising that some will wonder if it's worth posting content or not, given how few visit here anymore. That is no ones fault, by any means. And I can certainly understand why someone would question if it's worth posting any helpers or not. And yes ... I put on my asshole hat. There was a nicer way you could have said what you did ... or better yet, since it didn't help or contribute to his helper module you could have just said nothing at all. And, again, yes ... I understand the irony of my own post. 2 Quote
Uridium Posted January 28, 2023 Author Posted January 28, 2023 23 hours ago, Veramys said: Are you seeking validation? Replies come in their own time, and this forum definitely isn't as active as it once was. If that's all it takes for you to give up that's on you. Id never give up I was however saying back in the days when MWG was Criminal Existence as soon as youd post there were about 10 replies within the hour.. Just miss all the people that were here from them days.. Quote
Veramys Posted January 28, 2023 Posted January 28, 2023 I apologize, I didn't mean it to come off as mean as I did, and that was rude of me. I also miss the community being active like it was back in the day. Quote
SRB Posted January 28, 2023 Posted January 28, 2023 13 hours ago, Veramys said: I apologize, I didn't mean it to come off as mean as I did, and that was rude of me. I also miss the community being active like it was back in the day. That was time to double down, not give up 🤣 1 Quote
kendril Posted September 28, 2023 Posted September 28, 2023 Nice modification, i just add a: width="150" height="100" because if put image different sizes this makes every item same size image <div class="panel-body"> <center><img src="{pic}" width="150" height="100"></center> </div> 1 Quote
Br3ttb Posted September 29, 2023 Posted September 29, 2023 Just a bit of advice I was always told, always make sure to check your desktop and mobile versions of your game just to make sure it all fits well. What works for mobile may not always be the case for desktop. happy game creation! Brett Quote
peterisgb Posted September 29, 2023 Posted September 29, 2023 I plan to do this with my mccodes game, Just gotta wait till i get all the items added and finished first. Quote
Magictallguy Posted October 1, 2023 Posted October 1, 2023 On 9/28/2023 at 10:13 PM, kendril said: Nice modification, i just add a: width="150" height="100" because if put image different sizes this makes every item same size image <div class="panel-body"> <center><img src="{pic}" width="150" height="100"></center> </div> Quick tip for ya; if you need to dynamically resize an image on output, but want to keep its aspect ratio, avoid using the deprecated height and width attributes. Instead, a little CSS goes a long way. .panel-image { max-width: 150px; max-height: 100px; } <img src="{pic}" alt="A basic image title" class="panel-image"> Alternatively, you can inline the styling <img src="{pic}" alt="A basic title" style="max-width: 150px; max-height: 100px;"> 1 Quote
rockwood Posted October 3, 2023 Posted October 3, 2023 (edited) global $db; personally i don't like global https://www.quora.com/Are-global-variables-considered-bad-practice-in-PHP#:~:text=Global variables are not a,you wish to use globally. Edited October 3, 2023 by rockwood Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.