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
aqfitz622 Offline
Junior Member

Posts: 23
Threads: 9
Joined: Nov 2011
Reputation: 0
#1
2 keys

I have come to the stunning realization that i suck at scripting. i am using two keys here. but one isn't working
the 1st AddUseItemCallback is not working right because it will not unlock the door



void OnStart()

{
AddUseItemCallback("", "doorway", "mansion_4", "FUNCTION", true);
AddUseItemCallback("", "floortwokey", "mansion_9", "UsedKeyOnDoor", true);
}

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

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


void OnEnter()
{

}

void OnLeave()
{
12-12-2011, 01:56 AM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#2
RE: 2 keys

Took a bit to realize, but once I re-read your key isn't working on the door, something is up with the AddUseItemCallback:

//___________________
void OnStart()

{
AddUseItemCallback("", "doorway", "mansion_4", "FUNCTION", true);
AddUseItemCallback("", "floortwokey", "mansion_9", "UsedKeyOnDoor", true);
}

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

//_________________________

Turns out you have the wrong name of the key in the AddUseItemCallback. I believe it should be "doorkey", NOT "doorway".
12-12-2011, 02:11 AM
Find
aqfitz622 Offline
Junior Member

Posts: 23
Threads: 9
Joined: Nov 2011
Reputation: 0
#3
RE: 2 keys

thanks for the help man i appreciate it.
12-12-2011, 05:29 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: 2 keys

It'd be a lot simpler if the parameter variables were used.

Tutorials: From Noob to Pro
12-12-2011, 05:33 AM
Website Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#5
RE: 2 keys

(12-12-2011, 05:33 AM)Your Computer Wrote: It'd be a lot simpler if the parameter variables were used.

What do you mean?
12-12-2011, 09:38 PM
Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#6
RE: 2 keys

I think what My Computer means is the following:

PHP Code: (Select All)
void OnStart()
 
 {
 
AddUseItemCallback("""doorway""mansion_4""useItemOnDoor"true);
 
AddUseItemCallback("""floortwokey""mansion_9""UsedKeyOnDoor"true);
 }
 
 
void useItemOnDoor(string &in asItemstring &in asEntity)//and for ffs, start using decent names. Doing otherwise is a bad programming technique.
 
{
 
SetSwingDoorLocked(asEntityfalsetrue);
 
PlaySoundAtEntity("""unlock_door"asEntity0false);
 
RemoveItem(asItem);
 } 

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
12-12-2011, 10:05 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: 2 keys

(12-12-2011, 10:05 PM)nemesis567 Wrote: I think what My Computer means is the following:

Half way there. Both use-item callbacks should use the same function since they carry the same purpose.

PHP Code: (Select All)
void OnStart()
 {
 
AddUseItemCallback("""doorway""mansion_4""useItemOnDoor"true);
 
AddUseItemCallback("""floortwokey""mansion_9""useItemOnDoor"true);
 } 

Tutorials: From Noob to Pro
12-13-2011, 01:35 AM
Website Find
nemesis567 Offline
Posting Freak

Posts: 874
Threads: 65
Joined: May 2011
Reputation: 10
#8
RE: 2 keys

Good point My Computer.

I sometimes find it more efficient to use callbacks. Something like having a specific function for AddUseItemCallback, for example OnItemUsed and then use a switch statement. It's best to keep track of how is it called and when and you can use partial names to compare with a predefined name like door or something like that which allows for quite some more flexibility.

Today I dreamt the life I could live forever. You only know that when you feel it for you know not what you like until you've experienced it.
(This post was last modified: 12-13-2011, 01:50 AM by nemesis567.)
12-13-2011, 01:37 AM
Find
irockpeople1 Offline
Junior Member

Posts: 9
Threads: 3
Joined: Jan 2012
Reputation: 0
#9
RE: 2 keys

Im also having this problum. My hps is this
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "mansion_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_2", "mansion_2", "Door", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key_1");
}
void Door(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 0, false);
RemoveItem("key_2");
}
////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Also when i try to have a custom name all it says for them are "Picked up"
but when I only have one key, it works fine.
01-01-2012, 07:31 PM
Find




Users browsing this thread: 2 Guest(s)