06-09-2012, 05:56 PM
Hello guys , i am trying to script a key to open a door.
I have looked for some tutorials and i found some.
But when i tried them, It didnt work for me.
This is what i did:
I have made a small room with a door and a key .
I have locked the door and named it "mansion_1".
I made a key and on name i called it "key_1" and in the entity i have called it "key1"
After that i have created this script.
And when i run this on game, the game crash.
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key1", "mansion_1", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", mansion_1, 0, false);
RemoveItem(asItem);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Any idea why its not working ?
I have looked for some tutorials and i found some.
But when i tried them, It didnt work for me.
This is what i did:
I have made a small room with a door and a key .
I have locked the door and named it "mansion_1".
I made a key and on name i called it "key_1" and in the entity i have called it "key1"
After that i have created this script.
And when i run this on game, the game crash.
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key1", "mansion_1", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", mansion_1, 0, false);
RemoveItem(asItem);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Any idea why its not working ?