Frictional Games Forum (read-only)
[SCRIPT] Using the GiveItem function? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Using the GiveItem function? (/thread-12880.html)

Pages: 1 2


Using the GiveItem function? - Shadowfied - 01-26-2012

Been searching a bit and I can't find out how to get it to work.

void GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);
Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.
asName - internal name
asType - item to give
asSubTypeName - item name for .lang file
asImageName -
afAmount - amount to give
(from the FG wiki)
PHP Code:
void FillContFunc (string &in asItemstring &in asEntity)
{
    
RemoveItem(asItem);
    
GiveItem("FullCont""glass_container_mix_done""glasscontainer_full"""1);

What's wrong with this? It removes the empty glass container but it doesn't give me the filled one.

I know how to use GiveItemFromFile but then I don't get my custom set name and description, besides it says on the FG wiki that script is mostly for debug purposes. (I do use the GiveItemFromFile function to get the items otherwise when In debug mode)





RE: Using the GiveItem function? - palistov - 01-26-2012

Needs to have an image file. Browse the Amnesia files (redist/graphics/items if I'm not mistaken) and pick one out.


RE: Using the GiveItem function? - Shadowfied - 01-26-2012

(01-26-2012, 03:10 PM)palistov Wrote: Needs to have an image file. Browse the Amnesia files (redist/graphics/items if I'm not mistaken) and pick one out.
It must have an image even though it's one of the default items?




RE: Using the GiveItem function? - palistov - 01-26-2012

Yep, as far as I know.


RE: Using the GiveItem function? - Shadowfied - 01-26-2012

Changed it to:

PHP Code:
void FillContFunc (string &in asItemstring &in asEntity)
{
    
RemoveItem(asItem);
    
GiveItem("FullCont""glass_container_mix_done""glasscontainer_full""glass_container_mix_full.tga"1);


Still doesn't work. It doesn't give me an error or anything, it works to use the empty container but it doesn't return anything..

Nevermind! I'm stupid. I wrote "glass_container_mix_full.tga" but it was "glass_container_mix_done.tga". My bad. Works now.

Thank you very much.



RE: Using the GiveItem function? - palistov - 01-26-2012

Anytime Wink


RE: Using the GiveItem function? - Cranky Old Man - 04-20-2012

(Arise, Great Old One!)
What does the asType parameter do?
You see, while I know what the other parameters do, I can set asType to whatever, and my key will still work fine.



RE: Using the GiveItem function? - Shadowfied - 04-20-2012

It says that it is the name of the item and the subType is the item name in the .lang file.



RE: Using the GiveItem function? - Cranky Old Man - 04-20-2012

(04-20-2012, 09:36 PM)Shadowfied Wrote: It says that it is the name of the item and the subType is the item name in the .lang file.
Yes, I read the wiki too, but "name of the item" in what context? What does it do?




RE: Using the GiveItem function? - palistov - 04-20-2012

The entity type "Item" has subtypes: Puzzle, PotionHealth, PotionOil, Key and a few others I can't think of off the top of my head. Basically designates what the item does. Not sure why this is required, but it can't hurt to put the appropriate subtype.