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
A problem with a key
vansd Offline
Junior Member

Posts: 8
Threads: 4
Joined: Apr 2011
Reputation: 0
#1
A problem with a key

I have a question.
I made a key and a door unlock it using this script
void OnStart()
{
AddUseItemCallback("", "key_tomb_2", "prison_2, "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_2", false, true);
RemoveItem(asItem);
PlaySoundAtEntity("", "unlock_door.snt", "prison_3", 0.0f, true);
}

And I want to do another key and another door
But I have an error. What I did wrong???
AddUseItemCallback("", "key_tomb_3", "prison_3", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_3", false, true);
RemoveItem(asItem);
PlaySoundAtEntity("", "unlock_door.snt", "prison_3", 0.0f, true);
}
(This post was last modified: 04-10-2011, 03:05 PM by vansd.)
04-10-2011, 10:50 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: A problem with a key

Err, you're using the same function again. You can't have two functions with the same name.
04-10-2011, 12:13 PM
Find
vansd Offline
Junior Member

Posts: 8
Threads: 4
Joined: Apr 2011
Reputation: 0
#3
RE: A problem with a key

Sorry, I wrote too fast and didn't see that I wrote the same code.
I corrected it and now there is a normal code of my second key and the door.
(This post was last modified: 04-10-2011, 03:10 PM by vansd.)
04-10-2011, 03:09 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#4
RE: A problem with a key

Not only that...you can't have the same name for a function. Name it KeyOnDoor2 or something.
04-10-2011, 03:24 PM
Find
vansd Offline
Junior Member

Posts: 8
Threads: 4
Joined: Apr 2011
Reputation: 0
#5
RE: A problem with a key

I tried! But I have an error again!
04-10-2011, 03:26 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#6
RE: A problem with a key

What's the error? The error always tells you where and what the problem is.

Edit: I see what the problem is anyway. All of your callback functions should be inside OnStart.
(This post was last modified: 04-10-2011, 03:27 PM by MrBigzy.)
04-10-2011, 03:27 PM
Find
vansd Offline
Junior Member

Posts: 8
Threads: 4
Joined: Apr 2011
Reputation: 0
#7
RE: A problem with a key

If it is possible, can you give me an example of this code?
04-10-2011, 03:36 PM
Find
iNs Offline
Junior Member

Posts: 21
Threads: 4
Joined: Mar 2011
Reputation: 0
#8
RE: A problem with a key

Here you go:

void OnStart()
{
  // use "key_tomb_2" on "prison_2" door => calls "KeyOnDoor"
  AddUseItemCallback("", "key_tomb_2", "prison_2", "KeyOnDoor", true);

  // use "key_tomb_3" on "prison_3" door => calls "KeyOnDoor2"
  AddUseItemCallback("", "key_tomb_3", "prison_3", "KeyOnDoor2", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
  SetSwingDoorLocked("prison_2", false, true);
  RemoveItem(asItem);
  PlaySoundAtEntity("", "unlock_door.snt", "prison_2", 0.0f, true);
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
  SetSwingDoorLocked("prison_3", false, true);
  RemoveItem(asItem);
  PlaySoundAtEntity("", "unlock_door.snt", "prison_3", 0.0f, true);
}
(This post was last modified: 04-10-2011, 03:43 PM by iNs.)
04-10-2011, 03:41 PM
Find




Users browsing this thread: 2 Guest(s)