Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Multiple Keys
BadCoverMan Offline
Junior Member

Posts: 27
Threads: 7
Joined: Feb 2012
Reputation: 0
#1
Multiple Keys

Hello, I had just one key and everything was fine. Then when I tried to have a second key and second locked door, neither of them worked anymore. Here's the script. Any help would be much appreciated. I'm very new to scripting as well so I apologize if it's a really stupid mistake.

Spoiler below!

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey1", "LockedDoor_1", "UsedLockedDoorKey1", true);
}

void UsedLockedDoorKey1(string &in asItem, string &in asEntity)
{
AddUseItemCallback("", "SecondFloorKey", "LockedDoor_2", "UsedSecondFloorKey", true);
}

void UsedSecondFloorKey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey1");

SetSwingDoorLocked("LockedDoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_2", 0, false);
RemoveItem("SecondFloorKey");
}

02-21-2012, 07:24 PM
Find
BallisticDK Offline
Junior Member

Posts: 5
Threads: 2
Joined: Feb 2012
Reputation: 0
#2
RE: Multiple Keys

it needs to be like this

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey1", "LockedDoor_1", "UsedLockedDoorKey1", true);
AddUseItemCallback("", "LockedDoorKey2", "LockedDoor_2", "UsedLockedDoorKey2", true);
}

void UsedLockedDoorKey1(string &in asItem, string &in asEntity)
{
AddUseItemCallback("", "SecondFloorKey", "LockedDoor_2", "UsedSecondFloorKey", true);
}

void UsedSecondFloorKey1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey1");
}


void UsedSecondFloorKey2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_2", 0, false);
RemoveItem("SecondFloorKey");
}


1 AddUseItemCallback per door. i made that fail to, im also new to Scripting, <for Hardcore Scripters. do not flame me if there is an easyer way, im just saying how i do it >
(This post was last modified: 02-21-2012, 08:16 PM by BallisticDK.)
02-21-2012, 08:10 PM
Find
BadCoverMan Offline
Junior Member

Posts: 27
Threads: 7
Joined: Feb 2012
Reputation: 0
#3
RE: Multiple Keys

(02-21-2012, 08:10 PM)BallisticDK Wrote: it needs to be like this

Spoiler below!

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey1", "LockedDoor_1", "UsedLockedDoorKey1", true);
AddUseItemCallback("", "LockedDoorKey2", "LockedDoor_2", "UsedLockedDoorKey2", true);
}

void UsedLockedDoorKey1(string &in asItem, string &in asEntity)
{
AddUseItemCallback("", "SecondFloorKey", "LockedDoor_2", "UsedSecondFloorKey", true);
}

void UsedSecondFloorKey1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey1");
}


void UsedSecondFloorKey2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_2", 0, false);
RemoveItem("SecondFloorKey");
}


1 AddUseItemCallback per door. i made that fail to, im also new to Scripting, <for Hardcore Scripters. do not flame me if there is an easyer way, im just saying how i do it >
It didn't work. Sad

02-21-2012, 08:19 PM
Find
Ninami Offline
Member

Posts: 59
Threads: 6
Joined: Feb 2012
Reputation: 2
#4
RE: Multiple Keys

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey1", "LockedDoor_1", "UsedLockedDoorKey1", true);
AddUseItemCallback("", "SecondFloorKey", "LockedDoor_2", "UsedSecondFloorKey", true);
}

void UsedLockedDoorKey1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey1");
}

void UsedSecondFloorKey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "LockedDoor_2", 0, false);
RemoveItem("SecondFloorKey");
}


Try this
(This post was last modified: 02-21-2012, 08:28 PM by Ninami.)
02-21-2012, 08:27 PM
Find
BadCoverMan Offline
Junior Member

Posts: 27
Threads: 7
Joined: Feb 2012
Reputation: 0
#5
RE: Multiple Keys

(02-21-2012, 08:27 PM)Ninami Wrote: ////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey1", "LockedDoor_1", "UsedLockedDoorKey1", true);
AddUseItemCallback("", "SecondFloorKey", "LockedDoor_2", "UsedSecondFloorKey", true);
}

void UsedLockedDoorKey1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey1");
}

void UsedSecondFloorKey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "LockedDoor_2", 0, false);
RemoveItem("SecondFloorKey");
}


Try this
Thank you very much. Worked perfectly.


02-21-2012, 08:36 PM
Find
Ninami Offline
Member

Posts: 59
Threads: 6
Joined: Feb 2012
Reputation: 2
#6
RE: Multiple Keys

No problem!

Just remember to have all the "AddUseItemCallback" functions in the "void OnEnter" and have one for each door.

And also I changed the sound, you need to have "unlock_door.snt" with the ".snt" for it to work.
02-21-2012, 08:40 PM
Find




Users browsing this thread: 1 Guest(s)