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
well..I'm stuck again on doors
megsb927 Offline
Junior Member

Posts: 30
Threads: 10
Joined: Feb 2013
Reputation: 0
#1
Rainbow  well..I'm stuck again on doors

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()
{

}
04-07-2013, 05:20 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: well..I'm stuck again on doors

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.)

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-07-2013, 06:11 AM
Find
megsb927 Offline
Junior Member

Posts: 30
Threads: 10
Joined: Feb 2013
Reputation: 0
#3
RE: well..I'm stuck again on doors

(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?:/
04-07-2013, 07:33 AM
Find
noovra Offline
Junior Member

Posts: 9
Threads: 1
Joined: Apr 2013
Reputation: 0
#4
RE: well..I'm stuck again on doors

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
Find
megsb927 Offline
Junior Member

Posts: 30
Threads: 10
Joined: Feb 2013
Reputation: 0
#5
RE: well..I'm stuck again on doors

(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
04-07-2013, 08:58 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: well..I'm stuck again on doors

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

Trying is the first step to success.
04-07-2013, 09:15 AM
Find
noovra Offline
Junior Member

Posts: 9
Threads: 1
Joined: Apr 2013
Reputation: 0
#7
RE: well..I'm stuck again on doors

(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
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#8
RE: well..I'm stuck again on doors

(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

Trying is the first step to success.
04-07-2013, 09:45 AM
Find
noovra Offline
Junior Member

Posts: 9
Threads: 1
Joined: Apr 2013
Reputation: 0
#9
RE: well..I'm stuck again on doors

(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.
04-07-2013, 10:08 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: well..I'm stuck again on doors

Oh sorry then.

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

Great job. We'll just hope he understands it.

Trying is the first step to success.
04-07-2013, 10:10 AM
Find




Users browsing this thread: 2 Guest(s)