Frictional Games Forum (read-only)

Full Version: well..I'm stuck again on doors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi guys well here's the problem: You go into map3, a door in the room is locked, you leave this room to get a key, but when you come back the door is unlocked before you can use a key on it... here's the script for map3:
void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4", "castle_2", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key3");
SetSwingDoorLocked("castle_2", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
RemoveItem("Key4");
}
void OnEnter()
{

}

void OnLeave()
{

}
void OnStart()
{
SetEntityCallbackFunc("KEYNAME", "FUNCTION");
}

void FUNCTION(string &in asEntity, string &in Type)
{
SetSwingDoorLocked("DOORNAME", false, false);
}

(NOTE: This is the script that you've mentioned -- which is making the door to unlock BEFORE you can use it. Although it's unlocked when you pick the key up.)
(04-07-2013, 06:11 AM)JustAnotherPlayer Wrote: [ -> ]void OnStart()
{
SetEntityCallbackFunc("KEYNAME", "FUNCTION");
}

void FUNCTION(string &in asEntity, string &in Type)
{
SetSwingDoorLocked("DOORNAME", false, false);
}

(NOTE: This is the script that you've mentioned -- which is making the door to unlock BEFORE you can use it. Although it's unlocked when you pick the key up.)

I'm still confused what do I change?:/
Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.
(04-07-2013, 08:02 AM)noovra Wrote: [ -> ]Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room
What? Why?

Listen. You need to understand how the script functions work.

Look.

When you write this line:
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);



It means, "When i use Key3 on castle_1 it should call the function UsedKeyOnDoor."
Then you create the function:

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



This function says: "Unlock castle_1 and castle_2! Play two sound! Remove Key1 and Key4"


Do you see there's something wrong? When you use 1 key on a door, both doors will unlock.
THat's a problem!


You have to create 2 functions!



void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key3");
}


void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{

SetSwingDoorLocked("castle_2", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
RemoveItem("Key4");
}


I have called them: UsedKeyOnDoor1 and UsedKeyOnDoor2.


Now the void OnStart() looks like this:


void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor1", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor2", true);
}



Do you see? They call each their function.


Key3 on castle_1 calls UsedKeyOnDoor1
Key4 on caslte_2 calls UsedKeyOnDoor2
(04-07-2013, 08:58 AM)megsb927 Wrote: [ -> ]
(04-07-2013, 08:02 AM)noovra Wrote: [ -> ]Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?
(04-07-2013, 09:33 AM)noovra Wrote: [ -> ]
(04-07-2013, 08:58 AM)megsb927 Wrote: [ -> ]
(04-07-2013, 08:02 AM)noovra Wrote: [ -> ]Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?

No, it looks like he wants KeyA for DoorA and KeyB for DoorB
Key3 for castle_1
Key4 for castle_2
(04-07-2013, 09:45 AM)BeeKayK Wrote: [ -> ]
(04-07-2013, 09:33 AM)noovra Wrote: [ -> ]
(04-07-2013, 08:58 AM)megsb927 Wrote: [ -> ]
(04-07-2013, 08:02 AM)noovra Wrote: [ -> ]Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?

No, it looks like he wants KeyA for DoorA and KeyB for DoorB
Key3 for castle_1
Key4 for castle_2

Exactly what I meant. Both scripts should work fine.
Oh sorry then.

Ah, yes i see how your script works now! Wink

Great job. We'll just hope he understands it.
Pages: 1 2