• InventoryAddon 2
    26 replies, posted
[B]This won't work with any items from the first release![/B] Well, rewrote the whole thing to make sure I did everything right and hopefully it won't be any bugs. This is basically a revised version. Made new inventory layout though. This is just a light, basic inventory with item system. I know there is ItemForge. I have provided some items for examples. [U]- Inventory items saves on disconnect.[/U] [U]- Place in addons folder.[/U] [B][U]Commands[/U][/B] ia_spawnitem <item> - Spawns a item, admins and people with their steamid in the [B]ia.allowSpawning[/B] table in [B]ia_init.lua[/B] can run this command. ia_listitems - List the items that you can spawn. [B][U]Item Template[/U][/B] [lua] -- This is how you should make your item. -- When you're done, save the file to .lua and put it in the items folder. local ITEM = {}; ITEM.Name = "Name here"; ITEM.Info = "Description here"; ITEM.Model = "Model path here"; ITEM.useAble = 1/0 -- 0 makes it so you can't use it in the menu, 1 enables it. This is default set to 1, so if you don't need to put this in the item file if you don't plan on making it none-use able. ITEM.dropAble = 1/0 -- Same as useAble. if (SERVER) then -- Only used on server so we use this check. function ITEM.UseItem( ply ) -- This is the function when a player uses the item from the menu. -- Do shit here. end; function ITEM.DropItem( ply ) -- This is the function when a player drops the item from the menu. -- Do shit here. -- This should stay here if you don't plan on doing something else. ply:SpawnItem("Unique item name here"); -- Spawns the item. ply:RemoveItem("Unique item name here", 1); -- Removes 1 count from your inventory on this item. end; end; -- Puts the item in the main item table. IA.Items:RegisterItem("Unique item name here", ITEM); [/lua] [B][U]Pictures[/U][/B] [img_thumb]http://i46.tinypic.com/15ywxsp.png[/img_thumb] [img_thumb]http://i46.tinypic.com/xkrsbk.png[/img_thumb] [B][U]Download[/U][/B] [url=http://www.garrysmod.org/downloads/?a=view&id=87714][img]http://www.garrysmod.org/img/?t=dll&id=87714[/img][/url] [B]Ask me anything and report and bugs or problems![/B]
Awesome, the inventory looks very simple, and I like it! Would it not be better to load the items automatically without the need to call IA.Items.RegisterItem? Similar to how Scripted Entities work. You just have to loop through all the lua files in the items folder and for each one, set the global variable ITEM to a new table, include the file, register the item.
[QUOTE=NullPoint;19444318]Awesome, the inventory looks very simple, and I like it! Would it not be better to load the items automatically without the need to call IA.Items.RegisterItem? Similar to how Scripted Entities work. You just have to loop through all the lua files in the items folder and for each one, set the global variable ITEM to a new table, include the file, register the item.[/QUOTE] I dislike that system as it means you can only define one item per file. If you have the register function you can do more than one. With entities they can be so complex that it becomes a good idea to define it in multiple files, but an item can be simple enough that you can register five related items without it becoming a large, hard to read source file. I made a wrapper for entity registration a while back which allowed you to register entities like this: [lua]scripted_entity("entity name", function(ENT) ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Print Name" ENT.Spawnable = true ENT.AdminSpawnable = true function ENT:Think() MsgN("I'm thinking damnit, don't interrupt me!") end -- and so on end)[/lua] I prefer it as it gives you a clear marking for when one definition begins and another ends. It also collapses in Notepad++ so you can hide the contents. [lua]function scripted_entity(sName, funcDefinition, bReload) local ENT = {} funcDefinition(ENT) scripted_ents.Register(ENT, sName, bReload) end[/lua]
Il may ask stupid but how to pickup stuff for the inventory when i press e i just pick it up like normaly ? Please help me this addon is so great if i could get it to work...
When you press E on the item you pick it up, yes.
But how do i then get it in the Inventory menu ?
Do you get any errors?
Maybe you should save the clients data whenever they pick up/use an item, Level/Map Changes/Crashes would then not be a problem then.
No i doesent get any erros i just need to know... how do i pick up stuff so they get in my inventory menu ?
[QUOTE=sebastian7307;19571569]No i doesent get any erros i just need to know... how do i pick up stuff so they get in my inventory menu ?[/QUOTE] As he said you press "E".
I have a few questions, I am able to spawn the items, I just figured out how but... I don't know how to make them Shipments in DarkRP, and how to make the item menu popup opon F6 use, or F3. Could you please help me out with this? Edit: Sorry for the bump, didn't see how old the topic was T_T
[QUOTE="Gah!" Simons;19922753]I have a few questions, I am able to spawn the items, I just figured out how but... I don't know how to make them Shipments in DarkRP, and how to make the item menu popup opon F6 use, or F3. Could you please help me out with this? Edit: Sorry for the bump, didn't see how old the topic was T_T[/QUOTE] I won't get into shipments with <shit>darkrp. and since that gamemode uses F4 already, just bind a key to 'ia_inventory' eg. bind <key> ia_inventory
[QUOTE=ChewGum;19927299]I won't get into shipments with <shit>darkrp. and since that gamemode uses F4 already, just bind a key to 'ia_inventory' eg. bind <key> ia_inventory[/QUOTE] Alright, well thanks anyway. I'll have to figure it out myself, also, nice. It's sleek looking however a suggestion, When you use up all the items it keeps the icon in the inventory, I believe you should remove the icons when the items are all used up.
can you implant a trading system and maybe money involved and then maybe a shop and then maybe re-invent online marketing of today, untill mac makes the Igamodder and we all go ot of buissness through all the new servers? --i like that idea
Could this be intergrated into a DarkRP "F4 Tab"?
-snip-
Would you care if i used this for my gamemode?
Use it how you want, this is the little update one tho [url=http://www.garrysmod.org/downloads/?a=view&id=97223][img]http://www.garrysmod.org/img/?t=dll&id=97223[/img][/url]
Can this only be used on certain entitie's or can it be used on plain props in Sandbox as well? I make my own little campaign saves for my entertainment and I've been looking for something like this for quite some time. [editline]10:11AM[/editline] [QUOTE=Parlim;23176863]Can this only be used on certain entitie's or can it be used on plain props in Sandbox as well? I make my own little campaign saves for my entertainment and I've been looking for something like this for quite some time.[/QUOTE] I also try making my own items and modifying the current ones and they just came up as errors but I did nothing incorrectly.
Can you have map-specific items? Like keycards? Can these items also function as regular map entities do? I wanted to have a keycard you could find in my map, and use this to store it in your inventory so you wouldn't have to carry it around with you everywhere with +use.
K so i DLed this but the use key (e) does not pick stuff up, would it be because i already have a pickupswep script?
You do know this thread's last post was over 5 months ago, right?
That doesn't help in anyway. but now i do.
[QUOTE=ChewGum;19444253][B]This won't work with any items from the first release![/B] Well, rewrote the whole thing to make sure I did everything right and hopefully it won't be any bugs. This is basically a revised version. Made new inventory layout though. This is just a light, basic inventory with item system. I know there is ItemForge. I have provided some items for examples. [U]- Inventory items saves on disconnect.[/U] [U]- Place in addons folder.[/U] [B][U]Commands[/U][/B] ia_spawnitem <item> - Spawns a item, admins and people with their steamid in the [B]ia.allowSpawning[/B] table in [B]ia_init.lua[/B] can run this command. ia_listitems - List the items that you can spawn. [B][U]Item Template[/U][/B] [lua] -- This is how you should make your item. -- When you're done, save the file to .lua and put it in the items folder. local ITEM = {}; ITEM.Name = "Name here"; ITEM.Info = "Description here"; ITEM.Model = "Model path here"; ITEM.useAble = 1/0 -- 0 makes it so you can't use it in the menu, 1 enables it. This is default set to 1, so if you don't need to put this in the item file if you don't plan on making it none-use able. ITEM.dropAble = 1/0 -- Same as useAble. if (SERVER) then -- Only used on server so we use this check. function ITEM.UseItem( ply ) -- This is the function when a player uses the item from the menu. -- Do shit here. end; function ITEM.DropItem( ply ) -- This is the function when a player drops the item from the menu. -- Do shit here. -- This should stay here if you don't plan on doing something else. ply:SpawnItem("Unique item name here"); -- Spawns the item. ply:RemoveItem("Unique item name here", 1); -- Removes 1 count from your inventory on this item. end; end; -- Puts the item in the main item table. IA.Items:RegisterItem("Unique item name here", ITEM); [/lua] [B][U]Pictures[/U][/B] [img_thumb]http://i46.tinypic.com/15ywxsp.png[/img_thumb] [img_thumb]http://i46.tinypic.com/xkrsbk.png[/img_thumb] [B][U]Download[/U][/B] [url=http://www.garrysmod.org/downloads/?a=view&id=87714][img_thumb]http://www.garrysmod.org/img/?t=dll&id=87714[/img_thumb][/url] [B]Ask me anything and report and bugs or problems![/B][/QUOTE] but my key:f4 is for those cool achievements so what do i do?
[QUOTE=beanbag500;26811425]but my key:f4 is for those cool achievements so what do i do?[/QUOTE] Either use the achievements or inventory.
You can change line 22 and 23 at ia_init.lua to anything you want.
Why the flying fuck you replied to a post that was done TWO YEARS AGO
Sorry, you need to Log In to post a reply to this thread.