jtylerg
Junior Member
Posts: 4
Threads: 2
Joined: Aug 2012
Reputation:
0
|
RE: Fatal Error on this script
I copy and pasted Ongka's solution onto notepad++ ad still recieve a fatal error at 15'1 unexpected token {
(08-15-2012, 04:19 PM)Ongka Wrote: ////////////////////////////
// Run when entering map
void OnStart()
{
AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("BasementKey_1");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("cabinet_1", false, true);
PlaySoundAtEntity("", "unlock_door", "cabinet_1", 0, false);
RemoveItem("startkey");
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
You put brackets around the green function but didn't use a header, this caused the error.
You can just put it in the voidOnStart().
Edit: Andy was a bit faster ^^ I copy and pasted that and still receive the same error.
(08-15-2012, 04:19 PM)andyrockin123 Wrote: You must put all callbacks under void OnStart(), you can use void OnEnter() but that has more specific applications. You also can't have two functions with the exact same name (you used UseKeyOnDoor twice). Here's a cool trick you can do using asItem and asEntity that will fix your problem as well as reduce script clutter:
void OnStart()
{
AddUseItemCallback("", "BasementKey_1", "mansion_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "startkey", "cabinet_1", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}
Hope that helped This doesn't work either... same error every time "15,1" Unexpected token {
(This post was last modified: 08-16-2012, 06:48 PM by jtylerg.)
|
|