A problem with a key - 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 (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: A problem with a key (/thread-7282.html) |
A problem with a key - vansd - 04-10-2011 I have a question. I made a key and a door unlock it using this script void OnStart() { AddUseItemCallback("", "key_tomb_2", "prison_2, "KeyOnDoor", true); } void KeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("prison_2", false, true); RemoveItem(asItem); PlaySoundAtEntity("", "unlock_door.snt", "prison_3", 0.0f, true); } And I want to do another key and another door But I have an error. What I did wrong??? AddUseItemCallback("", "key_tomb_3", "prison_3", "KeyOnDoor", true); } void KeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("prison_3", false, true); RemoveItem(asItem); PlaySoundAtEntity("", "unlock_door.snt", "prison_3", 0.0f, true); } RE: A problem with a key - MrBigzy - 04-10-2011 Err, you're using the same function again. You can't have two functions with the same name. RE: A problem with a key - vansd - 04-10-2011 Sorry, I wrote too fast and didn't see that I wrote the same code. I corrected it and now there is a normal code of my second key and the door. RE: A problem with a key - MrBigzy - 04-10-2011 Not only that...you can't have the same name for a function. Name it KeyOnDoor2 or something. RE: A problem with a key - vansd - 04-10-2011 I tried! But I have an error again! RE: A problem with a key - MrBigzy - 04-10-2011 What's the error? The error always tells you where and what the problem is. Edit: I see what the problem is anyway. All of your callback functions should be inside OnStart. RE: A problem with a key - vansd - 04-10-2011 If it is possible, can you give me an example of this code? RE: A problem with a key - iNs - 04-10-2011 Here you go: Code: void OnStart() |