Frictional Games Forum (read-only)

Full Version: Need help with script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is wrong with this script, when i start the map it gives me an error. The names a right and everyting else. Am noobish at scripting

////////////////////////////
// Run when entering map
void OnEnter()

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

void OnLeave()

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

void OnLeave()

{
Why do you have a use item callback in your OnLeave function? Do you know what OnLeave works for?
(08-21-2011, 01:50 AM)Tanshaydar Wrote: [ -> ]Why do you have a use item callback in your OnLeave function? Do you know what OnLeave works for?

No Not really, nobbish at scripting
Why you have double OnLeave?
You dont need two OnLeave's. everything that happens will be above the Onleave.

void OnStart()
{
AddUseItemCallback("", "roomkey_1", "mansion_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "roomkey_2", "mansion_3", "UsedKeyOnDoor_2", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("roomkey_1");
}
void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("roomkey_2");
}

void OnLeave()
{

}

That should work.
(08-21-2011, 04:33 AM)Khan Wrote: [ -> ]You dont need two OnLeave's. everything that happens will be above the Onleave.

Void OnStart()
{
AddUseItemCallback("", "roomkey_1", "mansion_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "roomkey_2", "mansion_3", "UsedKeyOnDoor_2", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("roomkey_1");
}
void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("roomkey_2");
}

void OnLeave()
{

}

That should work.

first it gave me an error but then i changed the Void to void and it worked
(08-21-2011, 12:25 PM)lanlord000 Wrote: [ -> ]
(08-21-2011, 04:33 AM)Khan Wrote: [ -> ]You dont need two OnLeave's. everything that happens will be above the Onleave.

Void OnStart()
{
AddUseItemCallback("", "roomkey_1", "mansion_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "roomkey_2", "mansion_3", "UsedKeyOnDoor_2", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("roomkey_1");
}
void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("roomkey_2");
}

void OnLeave()
{

}

That should work.

first it gave me an error but then i changed the Void to void and it worked

woops, accidently put a capital V.