A Tricky Carnie
Member
Posts: 72
Threads: 15
Joined: Sep 2011
Reputation:
0
Small little Issue.
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?
10-06-2011, 10:59 PM
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
RE: Small little Issue.
Help me help you: post your code.
10-06-2011, 11:06 PM
A Tricky Carnie
Member
Posts: 72
Threads: 15
Joined: Sep 2011
Reputation:
0
RE: Small little Issue.
(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()
{
}
10-06-2011, 11:18 PM
Elven
Posting Freak
Posts: 862
Threads: 37
Joined: Aug 2011
Reputation:
26
RE: Small little Issue.
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
!
Aka, it should be like this:
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");
}
10-06-2011, 11:22 PM
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
RE: Small little Issue.
I thought that was the case.
A more efficient method:
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
(This post was last modified: 10-06-2011, 11:24 PM by Your Computer .)
10-06-2011, 11:23 PM
A Tricky Carnie
Member
Posts: 72
Threads: 15
Joined: Sep 2011
Reputation:
0
RE: Small little Issue.
Thanks, both of you, I had a feeling it was something simple.
10-06-2011, 11:25 PM