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()
{
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".
thanks for the help man i appreciate it.
It'd be a lot simpler if the parameter variables were used.
(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?
I think what
My Computer means is the following:
PHP Code:
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);
}
(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:
void OnStart()
{
AddUseItemCallback("", "doorway", "mansion_4", "useItemOnDoor", true);
AddUseItemCallback("", "floortwokey", "mansion_9", "useItemOnDoor", true);
}
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.
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.