Frictional Games Forum (read-only)
Need help with script - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Need help with script (/thread-9888.html)



Need help with script - lanlord000 - 08-21-2011

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()

{


RE: Need help with script - Tanshaydar - 08-21-2011

Why do you have a use item callback in your OnLeave function? Do you know what OnLeave works for?


RE: Need help with script - lanlord000 - 08-21-2011

(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


RE: Need help with script - Elven - 08-21-2011

Why you have double OnLeave?


RE: Need help with script - Khan - 08-21-2011

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.


RE: Need help with script - lanlord000 - 08-21-2011

(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



RE: Need help with script - Khan - 08-21-2011

(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.