Frictional Games Forum (read-only)
GiveItem - 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: GiveItem (/thread-20910.html)



GiveItem - Cyphermur9t - 03-24-2013

I'm getting pretty ticked here since this should be a basic frickin' command and I'm probably missing something simple. All I want to do is have the player fill a bucket with oil, and have the empty bucket be replaced with a full bucket in the inventory.......

PHP Code:
void FUNCTION1(string &in itemstring &in door)
{
    
RemoveItem("wooden_bucket_1");
    
PlaySoundAtEntity("""ui_use_oil.snt""Player"0false);
    
GiveItem("wooden_bucket_filled.ent");
}

//////////

void FUNCTION2(string &in itemstring &in door)
{
    
RemoveItem("wooden_bucket_filled_1");
    
PlaySoundAtEntity("""ui_use_oil.snt""lever_simple01_1"0false);
    
AddPlayerSanity(10);
    
SetPropStaticPhysics("lever_simple01_1"false);


I have also tried:
PHP Code:
GiveItem("wooden_bucket_filled");
GiveItem("wooden_bucket_filled_1"); 

But the game never loads and comes up with an error and is getting me frustrated. I've already looked at scripts wiki and frankly looks like a glob of colored text.

void GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);

doesn't help.

-----------------------------------

EDIT:
FIXED IT. -.-

Just had to write
PHP Code:
GiveItemFromFile("wooden_bucket_filled_1""wooden_bucket_filled.ent"); 
to give me a filled bucket of water.


RE: GiveItem - plutomaniac - 03-25-2013

FYI, you don't need to type .ent when using GiveItemFromFile


RE: GiveItem - NaxEla - 03-25-2013

If you use GiveItemFromFile, beware that you won't be able to use that bucket for anything. GiveItemFromFile creates the actual item, but destroys it after, so it won't work if you use it in a AddUseItemCallback. It's mainly used for debugging.

You'll want to use GiveItem. Try this:
Code:
GiveItem("wooden_bucket_filled_1", "wooden_bucket_filled.ent", "filled_bucket", "wooden_bucket_filled.tga", 1)

wooden_bucket_filled_1 - internal name (use this name in the AddUseItemCallback function)
wooden_bucket_filled.ent - item to give
filled_bucket - the name for the .lang file
wooden_bucket_filled.tga - the image that shows up in the inventory
1 - amount to give


RE: GiveItem - plutomaniac - 03-25-2013

GiveItemFromFile does work with AddUseItemCallback if the internal name given matches the exact name of the item at the LevelEditor but as NaxEla said, it is used for debugging purposes because it does not work as intended (custom items called via GiveItemFromFile usually do not have inventory descriptions etc...)