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 Two locked doors + keys on one map???
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Two locked doors + keys on one map???

You are calling the same function!
What you do is making key_1 open both doors when used on door_1. key_2 opens both doors when used on door_2.

The engine cannot separate:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
SetSwingDoorLocked("door_1", false, true);
RemoveItem("key_1");
PlaySoundAtEntity("", "unlock_door", "door_2", 0, false);
SetSwingDoorLocked("door_2", false, true);
RemoveItem("key_2");
}



It believes it has to do it all at the same time.
Heres what you have to do:


void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor_1", true);
AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor_2", true);
}


void UsedKeyOnDoor_1(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
SetSwingDoorLocked("door_1", false, true);
RemoveItem("key_1");
}


void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("", "unlock_door", "door_2", 0, false);
SetSwingDoorLocked("door_2", false, true);
RemoveItem("key_2");
}



I don't want to make you more confused, but if you want to make it a bit easier for yourself, you can do this:


void OnStart()
{
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key_2", "door_2", "UsedKeyOnDoor", true);
}


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


If it doesn't make sense to you, or if you don't understand it, use the first script.
Never use something you don't understand!

Trying is the first step to success.
09-28-2012, 02:21 PM
Find


Messages In This Thread
RE: Two locked doors + keys on one map??? - by FlawlessHappiness - 09-28-2012, 02:21 PM



Users browsing this thread: 1 Guest(s)