#3 - Actions
As shown previously you can do things like :AddDrop
I call these actions, as it's something the user will be able to do with the item in the inventory.
If your addon has a functionality, like food can be eaten, you should add a Use action for it in the inventory. This will make people able to eat the food while in the inventory.
AddDrop
Realm: Server
Syntax:
Arguments:
- (table) self - ITEM template
- (player) ply - The player
- (entity) ent - The entity that have been spawned
- (table) tbl - The item table for the item that have just been spawned
- (TraceResult) tr - The trace performed by the drop function. It is range limited.
Amount/all
You can define if it should drop an amount that the player chooses, or if it should drop all.
I recommend having a normal drop function that drops 1 automatically for the most cases, but some cases like DarkRP money it wouldn't make sense to drop 1 by default.
You can only have one of normal drop/drop amount at a time, you can't have both! But you can always have drop all.
To change the drop case, simply add a second argument to :AddDrop
AddUse/AddEquip
Realm: Shared
Syntax:
Arguments:
- (table) self - ITEM template
- (player) ply - The player
- (table) tbl - The item table for the item that have just been spawned