Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A problem with a key
Author Message
vansd Offline
Junior Member

Posts: 8
Joined: Apr 2011
Reputation: 0
Post: #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 all posts by this user Quote this message in a reply
MrBigzy Offline
Senior Member

Posts: 616
Joined: Mar 2011
Reputation: 8
Post: #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 all posts by this user Quote this message in a reply
vansd Offline
Junior Member

Posts: 8
Joined: Apr 2011
Reputation: 0
Post: #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 all posts by this user Quote this message in a reply
MrBigzy Offline
Senior Member

Posts: 616
Joined: Mar 2011
Reputation: 8
Post: #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 all posts by this user Quote this message in a reply
vansd Offline
Junior Member

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

I tried! But I have an error again!
04-10-2011 03:26 PM
Find all posts by this user Quote this message in a reply
MrBigzy Offline
Senior Member

Posts: 616
Joined: Mar 2011
Reputation: 8
Post: #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 all posts by this user Quote this message in a reply
vansd Offline
Junior Member

Posts: 8
Joined: Apr 2011
Reputation: 0
Post: #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 all posts by this user Quote this message in a reply
iNs Offline
Junior Member

Posts: 21
Joined: Mar 2011
Reputation: 0
Post: #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 all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)