Frictional Games Forum (read-only)

Full Version: ERROR: Unexpected end of file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I need some help here with this script. It says "Unexpected end of file" and I just can't figure out what's wrong. Can anyone help and solve this, please?

Quote: ////////////////////////////
// Run first time starting map
void OnStart()

{
AddUseItemCallback("", "Key_1", "Door_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key_2", "Door_2", "UsedKeyOnDoor_2", true);
AddUseItemCallback("", "Secretkey2", "metal_1", "UsedKeyOnDoor_3", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_1", false, true);
PlaySoundEntity("", "unlock_door", "Door_1", 0, false);
RemoveItem("Key_1");
}

void UsedKeyOnDoor_2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_2", false, true);
PlaySoundAtEntity("", "unlock_door", "Door_2", 0,false);
RemoveItem("Key_2");

void Message_1(string &in asEntity)
{
SetMessage("Message", "Message_1", 2);
}
void UsedKeyOnDoor_3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundEntity("", "unlock_door", "metal_1", 0, false);
RemoveItem("Secretkey2");
}
/////////////////////////////
// Run when entering map
void OnEnter()
{

}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}
PHP Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
  
AddUseItemCallback("""Key_1""Door_1""UsedKeyOnDoor"true);
  
AddUseItemCallback("""Key_2""Door_2""UsedKeyOnDoor_2"true);
  
AddUseItemCallback("""Secretkey2""metal_1""UsedKeyOnDoor_3"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("Door_1"falsetrue);
  
PlaySoundEntity("""unlock_door""Door_1"0false);
  
RemoveItem("Key_1");
}

void UsedKeyOnDoor_2(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("Door_2"falsetrue);
  
PlaySoundAtEntity("""unlock_door""Door_2"0,false);
  
RemoveItem("Key_2");
// <- THERE WAS A } MISSING.

void Message_1(string &in asEntity)
{
  
SetMessage("Message""Message_1"2);
}

void UsedKeyOnDoor_3(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("metal_1"falsetrue);
  
PlaySoundEntity("""unlock_door""metal_1"0false);
  
RemoveItem("Secretkey2");


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


}

////////////////////////////
// Run when leaving map
void OnLeave()
{




There was a } missing, I added a comment in the code at the location.
(10-19-2011, 03:10 PM)jens Wrote: [ -> ]
PHP Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
  
AddUseItemCallback("""Key_1""Door_1""UsedKeyOnDoor"true);
  
AddUseItemCallback("""Key_2""Door_2""UsedKeyOnDoor_2"true);
  
AddUseItemCallback("""Secretkey2""metal_1""UsedKeyOnDoor_3"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("Door_1"falsetrue);
  
PlaySoundEntity("""unlock_door""Door_1"0false);
  
RemoveItem("Key_1");
}

void UsedKeyOnDoor_2(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("Door_2"falsetrue);
  
PlaySoundAtEntity("""unlock_door""Door_2"0,false);
  
RemoveItem("Key_2");
// <- THERE WAS A } MISSING.

void Message_1(string &in asEntity)
{
  
SetMessage("Message""Message_1"2);
}

void UsedKeyOnDoor_3(string &in asItemstring &in asEntity)
{
  
SetSwingDoorLocked("metal_1"falsetrue);
  
PlaySoundEntity("""unlock_door""metal_1"0false);
  
RemoveItem("Secretkey2");


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


}

////////////////////////////
// Run when leaving map
void OnLeave()
{




There was a } missing, I added a comment in the code at the location.
Hm.. Strange. It's still not working. (I also deleted your "// <- THERE WAS A } MISSING."-text) and still not working.


Can't see anything that would cause an unexpected end of file. usually it is a {} )( ;, " that is missing or incorrect positioned.
(10-19-2011, 03:32 PM)jens Wrote: [ -> ]Can't see anything that would cause an unexpected end of file. usually it is a {} )( ;, " that is missing or incorrect positioned.
Hm.. I solve it by removing:

Code:
PlaySoundEntity("", "unlock_door", "metal_1", 0, false);


Ah, that should be PlaySoundAtEntity not PlaySoundEntity!
(10-19-2011, 03:36 PM)jens Wrote: [ -> ]Ah, that should be PlaySoundAtEntity not PlaySoundEntity!
I tryed to change it, but then I got the error again (unexpected end of file).
The strange thing is, that when I remove the whole "PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);", it still gives me a "key sound". Is it supose to do that?


(10-19-2011, 03:36 PM)jens Wrote: [ -> ]Ah, that should be PlaySoundAtEntity not PlaySoundEntity!
Ah, I got it to work now, with your "PlaySoundAtEntity"-script! I don't know what went wrong..
Thank you! Smile


Hi im stuck to and really don't know what to do can you help me??? all it says main (25,15) : ERR : Expected "{"
hear is my hps file:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "K_1", "door_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0, false);
RemoveItem("K_1");
}

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


}

////////////////////////////
// Run when leaving map
void OnLeave()
You are missing the { and } at void OnLeave().