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
2 keys script
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
2 keys script

I'm having 2 keys in my map.

The first key you can pick up unlocks a door into another room.
On the way to the locked door, you pass another locked door. But when you unlock the door with the valid key, the other door becomes unlocked automatic... However the next key still works on the newly unlocked door...
Here is my script:

////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door", "door1", 0, false);
RemoveItem("key1");

SetSwingDoorLocked("door2", false, true);
PlaySoundAtEntity("", "unlock_door", "door2", 0, false);
RemoveItem("key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

What is wrong?

Trying is the first step to success.
03-10-2012, 11:32 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: 2 keys script

////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor", true);
}

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

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
Use this one: They don't figure themselves out. If you put those veents in there, the game will do both of them, not in the order you put them in.


03-10-2012, 11:45 AM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#3
RE: 2 keys script

Quote:////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor2", true);
}

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

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

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
No it's this one.

Signature to awesome to be displayed.
(This post was last modified: 03-10-2012, 12:16 PM by Stepper321.)
03-10-2012, 12:14 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: 2 keys script

Yay it works!!! Big Grin

I occured another question not related to the keys...

I have a room with 2 locked doors.
In the middle is a table with a note.
Behind one of the doors is a monster.

I already set up the pathnotes (there is only 1)
and made the monster inactive.

Now i want it to go break the door (by just following the pathnote) when i pick up the note.
But i cant make it work.
Script:

////////////////////////////
// Run first time starting map
void OnStart()

{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

void SetEntityCallbackFunc("note3", "OnPickup");
{
void OnPickup(string &in asItem, string &in asEntity)
{
SetEntityActive("PlayerCollide", true);
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("monster1", true);
AddEnemyPatrolNode("monster1", "PathNodeArea_1", 0, "");
}
}
}

Trying is the first step to success.
03-10-2012, 12:29 PM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#5
RE: 2 keys script

You are doing much wrong, you can't do a void in the callbacks, and there must be an } after any callbacks.
not after you did it all, i can't fix this sorry, its too messed for me Sad

Signature to awesome to be displayed.
(This post was last modified: 03-10-2012, 12:45 PM by Stepper321.)
03-10-2012, 12:43 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#6
RE: 2 keys script

(03-10-2012, 12:14 PM)Stepper321 Wrote:
Quote:////////////////////////////
// Run first time starting map
void OnStart()
{

}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key1", "door1", "KeyOnDoor", true);
AddUseItemCallback("", "key2", "door2", "KeyOnDoor2", true);
}

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

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

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
No it's this one.
Correction: Both work.


(03-10-2012, 12:43 PM)Stepper321 Wrote: You are doing much wrong, you can't do a void in the callbacks, and there must be an } after any callbacks.
not after you did it all, i can't fix this sorry, its too messed for me Sad
Those are not callbacks.

(This post was last modified: 03-10-2012, 12:49 PM by flamez3.)
03-10-2012, 12:47 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: 2 keys script

Instead of editing it, could you then try doing it the right way?

On pickup - Monster spawn..

Trying is the first step to success.
03-10-2012, 01:08 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#8
RE: 2 keys script


void OnStart()
{
SetEntityPlayerInteractCallback("notename", "MonsterSpawm", true);
}

void MonsterSpawn(string &in asEntity)
{
SetEntityActive("monstername", true);
}

03-10-2012, 01:33 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: 2 keys script

It doesn't work... yes my FATAL ERROR messages disappear, but the monster spawn, or begin its pathnode... i tried editing after what you did, with no luck.
I tried making the area get active when i pick up the node and then the area will make the monster spawn... but i guess it is impossible to use notes to trigger anything...

Trying is the first step to success.
03-10-2012, 02:55 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#10
RE: 2 keys script

No, you can trigger things with notes. Using the exact way I said. Post the scri[t of the edited version.

03-10-2012, 03:01 PM
Find




Users browsing this thread: 1 Guest(s)