Frictional Games Forum (read-only)

Full Version: Key Not Being Removed From Inventory After Use
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just as the title says, I have an issue with a level door key not being destroyed after its use (in the 00_map). I checked my files and it seems to be scripted correctly, but then again, I'm new to this, so I'm more than likely wrong.

I attempted to just make a script file for the next map and remove the item from the inventory there (the 01_map) by using the following script:

void RemoveItem("leveldoorkey_1");

That didn't work so I removed the void and the map loaded with the key still in the inventory. Moved it to the void OnStart section, still nothing.

Okay, so my hps scripts look like this:

AddUseItemCallback("OpenDoor", "leveldoor1_key", "leveldoor1", "UnlockLevelDoor", true);

From what I understand, the last parameter is for auto removal of the item once it's been used.

Help will be greatly appreciated and met with a very outstanding "thank you!"
The last parameter is for the callback to be removed when the item is used on the entity. In other words, the connection between the key and the door is removed when the key is used on the door. If you used the parameter variables, you wouldn't have to worry about manually typing in the entity names. Also, we need to see more of your code.
Errr... nope.

It is:

void OnStart()
{

AddUseItemCallback("OpenDoor", "leveldoor1_key", "leveldoor1", "UnlockLevelDoor", true);
}

void UnlockLevelDoor (string &in asItem, string &in asEntity)
{
///Door stuff
RemoveItem("leveldoor1_key");
}

It would be certainly better if you posted the whole script Wink but, by what I can see, that's the issue.
With simple key-to-door scripts you can write RemoveItem(asItem);

This will remove the item that you just used
Thanks to everyone who replied! It's been fixed.

It was a simple matter of forgetting a semi-colon at the end of
RemoveItem("leveldoor1_key");

I had had it in there before but didn't add the ;... so *facepalm*.

But thank you all for helping! =D =D