Homicide13
Senior Member
Posts: 323
Threads: 41
Joined: Nov 2010
Reputation:
14
|
Death with inventory item.
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 ^^
|
|
08-22-2011, 03:50 PM |
|
Tanshaydar
From Beyond
Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation:
67
|
RE: Death with inventory item.
RemoveItem
CreateEntityAtArea
These two function will do it for you.
|
|
08-22-2011, 03:58 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Death with inventory item.
Perhaps something like this?
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.
(This post was last modified: 08-22-2011, 04:00 PM by Kyle.)
|
|
08-22-2011, 03:58 PM |
|
Homicide13
Senior Member
Posts: 323
Threads: 41
Joined: Nov 2010
Reputation:
14
|
RE: Death with inventory item.
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.
(This post was last modified: 08-22-2011, 06:36 PM by Homicide13.)
|
|
08-22-2011, 06:27 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Death with inventory item.
(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:
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);
}
(This post was last modified: 08-22-2011, 06:44 PM by Kyle.)
|
|
08-22-2011, 06:41 PM |
|
Homicide13
Senior Member
Posts: 323
Threads: 41
Joined: Nov 2010
Reputation:
14
|
RE: Death with inventory item.
I tried SetEntityActive, it didn't work :/ I don't know why
|
|
08-22-2011, 08:17 PM |
|
Kyle
Posting Freak
Posts: 911
Threads: 36
Joined: Sep 2010
Reputation:
7
|
RE: Death with inventory item.
(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.
|
|
08-22-2011, 08:44 PM |
|
Homicide13
Senior Member
Posts: 323
Threads: 41
Joined: Nov 2010
Reputation:
14
|
RE: Death with inventory item.
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:
(This post was last modified: 08-22-2011, 09:09 PM by Homicide13.)
|
|
08-22-2011, 08:55 PM |
|
|