Frictional Games Forum (read-only)

Full Version: Can't get unlock door with key code to work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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!
Check names again. Script looks normal to me. Check for capitals and such
(11-12-2012, 11:42 AM)beecake Wrote: [ -> ]Check names again. Script looks normal to me. Check for capitals and such
^that.
Also where did you ut this line: AddUseItemCallback("", "key5", "water_door", "UsedKeyOnDoor5", true); ?


You did put it in OnStart() right?
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".
(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 -.-
Is the script exactly names the same as the map? Is it in it's place?
(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....
Do you have a map .cache? If so, delete it.
(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
Pages: 1 2