Frictional Games Forum (read-only)

Full Version: Using the GiveItem function?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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)


Needs to have an image file. Browse the Amnesia files (redist/graphics/items if I'm not mistaken) and pick one out.
(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?

Yep, as far as I know.
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.
Anytime Wink
(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.
It says that it is the name of the item and the subType is the item name in the .lang file.
(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?

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.
Pages: 1 2