Frictional Games Forum (read-only)
Can't get unlock door with key code to work? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Can't get unlock door with key code to work? (/thread-19191.html)

Pages: 1 2


Can't get unlock door with key code to work? - Storfigge - 11-12-2012

Hey I've been working on my CS for quite a while now and I'm very close to finishing it so i was making a locked door which a key would be required to open it, I've done this like 4 times before and it has worked... Now it doesn't work. When I use the key it says "Cannot use item this way". I have put in all the code and saved everything I've checked for a mistake many times but can't seem to figure it out. I'm using a sewer_arched door named "water_door" and a key_ laboratory named "key5". I'm not very good with programming though I have solved most problems I've had.

Here's the code

{
AddUseItemCallback("", "key5", "water_door", "UsedKeyOnDoor5", true);
}

void UsedKeyOnDoor5(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("water_door", false, true);
PlaySoundAtEntity("", "unlock_door", "water_door", 0, false);
RemoveItem("key5");
}

Really appreciate if someone could tell me what I've done wrong, thx!


RE: Can't get unlock door with key code to work? - FlawlessHappiness - 11-12-2012

Check names again. Script looks normal to me. Check for capitals and such


RE: Can't get unlock door with key code to work? - The chaser - 11-12-2012

(11-12-2012, 11:42 AM)beecake Wrote: Check names again. Script looks normal to me. Check for capitals and such
^that.


RE: Can't get unlock door with key code to work? - FlawlessHappiness - 11-12-2012

Also where did you ut this line: AddUseItemCallback("", "key5", "water_door", "UsedKeyOnDoor5", true); ?


You did put it in OnStart() right?


RE: Can't get unlock door with key code to work? - The chaser - 11-12-2012

When it says "Cannot use this item this way, is a problem of names.Also, remain that scripts are Case-sensitive. It's not the same "key" than "Key".


RE: Can't get unlock door with key code to work? - Storfigge - 11-13-2012

(11-12-2012, 02:35 PM)beecake Wrote: Also where did you ut this line: AddUseItemCallback("", "key5", "water_door", "UsedKeyOnDoor5", true); ?


You did put it in OnStart() right?
Yes... There's nothing wrong with the names either I've checked it a lot of times I've even copy pasted old codes and changed the names and yet it wont work Sad

Heres the entire code for the level


void Onstart()
{
AddUseItemCallback("", "key5", "water_door", "UsedKeyOnDoor5", true);
}

void UsedKeyOnDoor5(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("water_door", false, true);
PlaySoundAtEntity("", "unlock_door", "water_door", 0, false);
RemoveItem("key5");
}

void DoorLockedPlayer2(string &in entity)

{
if(GetSwingDoorLocked("metal_1") == true)
{

SetMessage("Messages", "msgname2", 0);

}
}



void OnEnter()
{
}

void OnLeave()
{
}

Does anyone see something that can cause this problem? I just can't figure it out -.-


RE: Can't get unlock door with key code to work? - The chaser - 11-13-2012

Is the script exactly names the same as the map? Is it in it's place?


RE: Can't get unlock door with key code to work? - Storfigge - 11-13-2012

(11-13-2012, 12:05 PM)The chaser Wrote: Is the script exactly names the same as the map? Is it in it's place?
Yes the door message i have put in there works just fine :/

The door is placed in water but that shouldn't matter right?? I just tried to rename everything but it still wont work....


RE: Can't get unlock door with key code to work? - FlawlessHappiness - 11-13-2012

Do you have a map .cache? If so, delete it.


RE: Can't get unlock door with key code to work? - Storfigge - 11-13-2012

(11-13-2012, 01:14 PM)beecake Wrote: Do you have a map .cache? If so, delete it.
Damnit didn't notice that >_< ty alot man these forums have helped greatly Smile