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 Help with a locked doors!
Viuffuz Offline
Junior Member

Posts: 13
Threads: 4
Joined: Jan 2012
Reputation: 0
#1
Help with a locked doors!

I have two locked doors in the same level and when I open the first door with a key, it opens the other door at the same time. Why does this happen?

Here's the script!

void OnStart ()
{
AddUseItemCallback("", "Avain", "mansion_3", "UsedKeyOnDoor", true);
AddUseItemCallback("", "pihan_avain", "mansion_11", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("Avain");

SetSwingDoorLocked("mansion_11", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_11", 0, false);
RemoveItem("pihan_avain")
}
04-23-2012, 07:23 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#2
RE: Help with a locked doors!

You should put bracket between the removeitem and setswingdoor locked
because if they are in the same they will both open.Try this:

void OnStart ()
{
AddUseItemCallback("", "Avain", "mansion_3", "UsedKeyOnDoor", true);
AddUseItemCallback("", "pihan_avain", "mansion_11", "UsedKeyOnDoor2", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("Avain");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{

SetSwingDoorLocked("mansion_11", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_11", 0, false);
RemoveItem("pihan_avain")
}

(This post was last modified: 04-23-2012, 07:36 PM by Datguy5.)
04-23-2012, 07:35 PM
Find
overscore Offline
Junior Member

Posts: 10
Threads: 1
Joined: Apr 2012
Reputation: 1
#3
RE: Help with a locked doors!

Giving the keys and doors unique names will help with that problem. As shown above.
04-23-2012, 08:02 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#4
RE: Help with a locked doors!


If YourComputer was here, he would frown.

Just do this:

void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{

SetSwingDoorLocked(asEntity, false, true);

PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);

RemoveItem(asItem);

}

Noob scripting tutorial: From Noob to Pro

04-23-2012, 08:13 PM
Find
Viuffuz Offline
Junior Member

Posts: 13
Threads: 4
Joined: Jan 2012
Reputation: 0
#5
RE: Help with a locked doors!

Thanks Datguy5! It helped! Big Grin
04-23-2012, 08:15 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#6
RE: Help with a locked doors!

(04-23-2012, 08:15 PM)Viuffuz Wrote: Thanks Datguy5! It helped! Big Grin

Np glad that i could help.

04-24-2012, 05:34 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Help with a locked doors!

The problem was that both of your scripts were called void UsedKeyOnDoor
Datguy5 called one of them UsedKeyOnDoor2. And also edited in the
void OnStart script Wink

Just so it won't happen again

Trying is the first step to success.
04-24-2012, 07:07 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#8
RE: Help with a locked doors!

(04-24-2012, 07:07 PM)beecake Wrote: The problem was that both of your scripts were called void UsedKeyOnDoor
Datguy5 called one of them UsedKeyOnDoor2. And also edited in the
void OnStart script Wink

Just so it won't happen again
Dude, just use my script. It's half the size, and you can use it for 50 doors if you want.



Noob scripting tutorial: From Noob to Pro

(This post was last modified: 04-24-2012, 07:15 PM by Cranky Old Man.)
04-24-2012, 07:15 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#9
RE: Help with a locked doors!

The problem is already solved.No need to fight about it nuff said.

04-24-2012, 07:37 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#10
RE: Help with a locked doors!

(04-24-2012, 07:37 PM)Datguy5 Wrote: The problem is already solved.No need to fight about it nuff said.
I'm not "fighting you". I'm talking about using efficient code. Would there be a woman involved somewhere, then I could possibly fight you, but there's no point in "fighting" on these forums.

Noob scripting tutorial: From Noob to Pro

04-24-2012, 08:22 PM
Find




Users browsing this thread: 3 Guest(s)