aqfitz622
Junior Member
Posts: 23
Threads: 9
Joined: Nov 2011
Reputation:
0
|
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 |
|
Statyk
Schrödinger's Mod
Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation:
241
|
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 |
|
aqfitz622
Junior Member
Posts: 23
Threads: 9
Joined: Nov 2011
Reputation:
0
|
RE: 2 keys
thanks for the help man i appreciate it.
|
|
12-12-2011, 05:29 AM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: 2 keys
It'd be a lot simpler if the parameter variables were used.
|
|
12-12-2011, 05:33 AM |
|
Statyk
Schrödinger's Mod
Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation:
241
|
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 |
|
nemesis567
Posting Freak
Posts: 874
Threads: 65
Joined: May 2011
Reputation:
10
|
RE: 2 keys
I think what My Computer means is the following:
void OnStart() { AddUseItemCallback("", "doorway", "mansion_4", "useItemOnDoor", true); AddUseItemCallback("", "floortwokey", "mansion_9", "UsedKeyOnDoor", true); } void useItemOnDoor(string &in asItem, string &in asEntity)//and for ffs, start using decent names. Doing otherwise is a bad programming technique. { SetSwingDoorLocked(asEntity, false, true); PlaySoundAtEntity("", "unlock_door", asEntity, 0, false); 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 |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
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.
void OnStart() { AddUseItemCallback("", "doorway", "mansion_4", "useItemOnDoor", true); AddUseItemCallback("", "floortwokey", "mansion_9", "useItemOnDoor", true); }
|
|
12-13-2011, 01:35 AM |
|
nemesis567
Posting Freak
Posts: 874
Threads: 65
Joined: May 2011
Reputation:
10
|
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 |
|
irockpeople1
Junior Member
Posts: 9
Threads: 3
Joined: Jan 2012
Reputation:
0
|
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 |
|
|