Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GiveItem
Cyphermur9t Offline
Junior Member

Posts: 38
Threads: 17
Joined: Jan 2013
Reputation: 2
#1
GiveItem

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: (Select All)
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: (Select All)
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: (Select All)
GiveItemFromFile("wooden_bucket_filled_1""wooden_bucket_filled.ent"); 
to give me a filled bucket of water.
(This post was last modified: 03-24-2013, 11:01 PM by Cyphermur9t.)
03-24-2013, 10:53 PM
Find
plutomaniac Offline
Super Moderator

Posts: 6,368
Threads: 45
Joined: May 2011
Reputation: 183
#2
RE: GiveItem

FYI, you don't need to type .ent when using GiveItemFromFile
03-25-2013, 02:09 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#3
RE: GiveItem

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:
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

In Ruins [WIP]
03-25-2013, 05:46 AM
Find
plutomaniac Offline
Super Moderator

Posts: 6,368
Threads: 45
Joined: May 2011
Reputation: 183
#4
RE: GiveItem

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...)
(This post was last modified: 03-25-2013, 02:17 PM by plutomaniac.)
03-25-2013, 02:17 PM
Find




Users browsing this thread: 1 Guest(s)