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
Key Not Being Removed From Inventory After Use
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#1
Key Not Being Removed From Inventory After Use

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!"

(This post was last modified: 12-07-2012, 07:07 PM by AGP.)
12-07-2012, 07:03 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Key Not Being Removed From Inventory After Use

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.

Tutorials: From Noob to Pro
12-07-2012, 08:40 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#3
RE: Key Not Being Removed From Inventory After Use

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.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
12-07-2012, 08:44 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Key Not Being Removed From Inventory After Use

With simple key-to-door scripts you can write RemoveItem(asItem);

This will remove the item that you just used

Trying is the first step to success.
12-07-2012, 09:34 PM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#5
RE: Key Not Being Removed From Inventory After Use

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

12-07-2012, 10:37 PM
Find




Users browsing this thread: 1 Guest(s)