Frictional Games Forum (read-only)

Full Version: Death with inventory item.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When a player dies, I want to remove an item from their inventory and re-place it back where it belongs in the level. However, resetting the prop just gives it to their inventory, and I can't figure out how to do what I want to do with it.
(and yes, I have the whole checkpoint/call a function script correct. I just don't know how to deal with this one reset)

Help would be much appreciated ^^
RemoveItem
CreateEntityAtArea

These two function will do it for you.
Perhaps something like this?

Code:
void OnStart()
{
     if (GetPlayerHealth() <= 0)
     {
          RemoveItem("ItemName");
          SetEntityActive("ItemName");
     }
}

It might work if you try it like this.

Whoops, Tanshaydar is right. I shouldn't use SetEntityActive because the player can move the object with another entity. Tongue
This works...except the new item doesn't have a CustomSubItemTypeName, so it doesn't display any information in the inventory :/ I can't find a command that will change this on an item.

Also, is there a way to check if an entity is in somebody's inventory? I assume there would be, but all I can find is bool GetEntityExists(string& asName);, which would just return true either way.
(08-22-2011, 06:27 PM)Homicide13 Wrote: [ -> ]This works...except the new item doesn't have a CustomSubItemTypeName, so it doesn't display any information in the inventory :/ I can't find a command that will change this on an item.

Also, is there a way to check if an entity is in somebody's inventory? I assume there would be, but all I can find is bool GetEntityExists(string& asName);, which would just return true either way.

You just add a local variable that's attached to a SetEntityPlayerInteractCallback. Like so:

Code:
void OnStart()
{
     SetLocalVarInt("Var01", 0);
     SetEntityPlayerInteractCallback("ItemName", "Func01", false);
     if ((GetPlayerHealth() <= 0) && (GetLocalVarInt("Var01") == 1))
     {
          RemoveItem("ItemName");
          SetEntityActive("ItemName", true); //Or change this to make it work with CreateEntityAtArea.
     }
}
void Func01(string &in asEntity)
{
     SetLocalVarInt("Var01", 1);
}
I tried SetEntityActive, it didn't work :/ I don't know why
(08-22-2011, 08:17 PM)Homicide13 Wrote: [ -> ]I tried SetEntityActive, it didn't work :/ I don't know why

Of course it wouldn't work, that's what I said.
er - then why did you suggest I use a local var? T_T EDIT: Oh right, to see if it's in the inventory. I normally think of stuff like that. >.<

haha I have this map completely finished except for this one bug D: