Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
Need help with scripting!
So I'm making my map in amnesia level editor, everything's just fine. But then I wanna start my scripting. So I add a function, and it's works perfectly fine, but when I try to add a new function there's an error when I start up my custom story! D: I dunno what the problem is D:
Here's the error message:
Uploaded with ImageShack.us
Here's my script:
void OnStart()
{
AddEntityCollideCallback("Player", "door_slamHousekeeper", "func_slam", true, 1);
}
void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}
{
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);
}
void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}
{
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
}
void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}
void OnEnter()
{
}
void OnLeave()
{
}
Please help me!
|
|
12-27-2011, 07:56 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Need help with scripting!
It's telling you have you two dangling code blocks. Were they supposed to be functions, or are you new to scripting in general?
|
|
12-27-2011, 09:25 PM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
RE: Need help with scripting!
Well I am new to scripting
|
|
12-28-2011, 09:53 AM |
|
ferryadams10
Senior Member
Posts: 288
Threads: 40
Joined: Apr 2011
Reputation:
19
|
RE: Need help with scripting!
these once aren't announced with a special function.
When should they use them.
Most likely it'll have to be connected with AddEntityCollideCallback or AddUseItemCallback but now the game doesn't know WHEN to use those things so I think you'll have to place those two scripts (without the brackets "{}") into void OnStart()
{ AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1); }
{ AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1); }
Got a nice sofa
Please come and have a seat for a while
(This post was last modified: 12-28-2011, 10:08 AM by ferryadams10.)
|
|
12-28-2011, 10:07 AM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
RE: Need help with scripting!
Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:
|
|
12-28-2011, 11:42 AM |
|
Tripication
Member
Posts: 172
Threads: 19
Joined: Dec 2011
Reputation:
6
|
RE: Need help with scripting!
Im just skimming ur script, and im not really concentrating on what your problem is, but try this
GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);
same with the oil, remove the .0f
(This post was last modified: 12-28-2011, 11:48 AM by Tripication.)
|
|
12-28-2011, 11:47 AM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
RE: Need help with scripting!
(12-28-2011, 11:47 AM)Tripication Wrote: Im just skimming ur script, and im not really concentrating on what your problem is, but try this
GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);
same with the oil, remove the .0f yeah I tried that too...
|
|
12-28-2011, 12:07 PM |
|
flamez3
Posting Freak
Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation:
57
|
RE: Need help with scripting!
(12-28-2011, 11:42 AM)Zaapeer Wrote: Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:
The message doesn't specify where the error is. It tells you what block it is in. If it says (for e.g) main (45,5), it doesn't directly mean there is something wrong with that line and character. It means in the entire block; something's wrong. Post your script again and I'll see if I can help.
|
|
12-28-2011, 02:31 PM |
|
ferryadams10
Senior Member
Posts: 288
Threads: 40
Joined: Apr 2011
Reputation:
19
|
RE: Need help with scripting!
Add me and I'll help you with all your problems xD
Much easier.
Skype: ferryadams10
Steam: ferryadams10
Msn: ferry_hooligan@live.nl
Got a nice sofa
Please come and have a seat for a while
|
|
12-28-2011, 02:47 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
RE: Need help with scripting!
Have you got it to work? becuse i think i know what the problem is
If im not mistaken it should look like this: (12-27-2011, 07:56 PM)Zaapeer Wrote: void OnStart()
{
AddEntityCollideCallback("Player", "door_slamHousekeeper", "func_slam", true, 1);
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);
}
void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}
void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}
void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}
void OnEnter()
{
}
void OnLeave()
{
} the bolded ones is the ones I moved You need to have them in either void onstart, void onenter or void onleave
Correct me if i'm mistaken
|
|
12-28-2011, 02:53 PM |
|
|