Frictional Games Forum (read-only)

Full Version: Small little Issue.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay...I have two keys in one map, however, when I unlock the first door (the second key is behind the first locked door), it actually ends up unlocking both doors at once.

How do I fix this?
Help me help you: post your code.
(10-06-2011, 11:06 PM)Your Computer Wrote: [ -> ]Help me help you: post your code.
This is what I have for my script:
Spoiler below!
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_2", "mansion_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_3", "mansion_2", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_2");
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_3");

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
Both functions call same function called "KeyOnDoor"

You need to make 2 different callbacks one is KeyOnDoor and other is KeyOnDoor2

And both of them opens different doors Smile!

Aka, it should be like this:

Code:
void OnEnter()
{
AddUseItemCallback("", "key_2", "mansion_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_3", "mansion_2", "KeyOnDoor2", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_2");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_3");
}
I thought that was the case.

A more efficient method:
Code:
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
Thanks, both of you, I had a feeling it was something simple.