Devil Dogs SF
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2011
Reputation:
0
|
HPS script issue [SOLVED]
Hiya, I am trying to make a Custom Story, but unfortunately I kinda suck at scripting...
When I try to load the map in game it works fine, although with my HPS file in the story folder it give me a fatal error and crashes the game.
Could someone please take a look at this and see what the issue is, as I can't seem to find any info on it:
void OnStart()
{
AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
}
AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
}
(This post was last modified: 01-15-2011, 09:58 PM by Devil Dogs SF.)
|
|
01-15-2011, 05:29 AM |
|
Andross
Junior Member
Posts: 38
Threads: 1
Joined: Oct 2010
Reputation:
0
|
RE: HPS script issue
(01-15-2011, 05:29 AM)Devil Dogs SF Wrote: AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor", true);
} This call needs to be inside a function; propably OnStart().
Also, the closing brace in the following line must go.
Quote:void KeyOnDoor(string &in asItem, string &in asEntity)
...
void KeyOnDoor(string &in asItem, string &in asEntity)
You can't have two functions with the same name and the same parameters.
Btw.: If you set up a dev environment, the game will actually give you a rather helpful error message instead of just crashing.
(This post was last modified: 01-15-2011, 06:42 AM by Andross.)
|
|
01-15-2011, 06:34 AM |
|
Devil Dogs SF
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2011
Reputation:
0
|
RE: HPS script issue
I'm still doing something wrong here, don't exactly know what. I probably messed it up in this failed fix I just tried, I still don't understand scripting at all:
Quote:void OnStart(AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor1", true); )
{
void KeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
RemoveItem("key_tomb_rusty_1");
}
void OnStart(AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor2", true); )
{
}
void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
RemoveItem("key_torture_chamber_1");
}
void OnStart(AddUseItemCallback("", "key_tower_1", "hatch_ceiling_1", "KeyOnDoor3", true); )
{
void KeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hatch_ceiling_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "hatch_ceiling_1", 0.0f, true);
RemoveItem("key_tower_1");
}
Sorry if this is something super simple, but I am thoroughly confused...
(This post was last modified: 01-15-2011, 07:26 AM by Devil Dogs SF.)
|
|
01-15-2011, 07:26 AM |
|
Andross
Junior Member
Posts: 38
Threads: 1
Joined: Oct 2010
Reputation:
0
|
RE: HPS script issue
This way it is syntactically correct; don't know if it's functional, though.
I would suggest some basic programming tutorial. I believe that FrictionalGames suggest to start with JavaScript, as it is similar to AngelScript.
void OnStart()
{
AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor1", true);
AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor2", true);
AddUseItemCallback("", "key_tower_1", "hatch_ceiling_1", "KeyOnDoor3", true);
}
void KeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
RemoveItem("key_tomb_rusty_1");
}
void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
RemoveItem("key_torture_chamber_1");
}
void KeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hatch_ceiling_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "hatch_ceiling_1", 0.0f, true);
RemoveItem("key_tower_1");
}
|
|
01-15-2011, 07:38 AM |
|
Devil Dogs SF
Junior Member
Posts: 4
Threads: 2
Joined: Jan 2011
Reputation:
0
|
RE: HPS script issue
Thanks, works great. I'll take a look at JavaScript and get familiar with it so I don't feel helplessly confused again when I attempt more scripts.
(This post was last modified: 01-15-2011, 08:13 AM by Devil Dogs SF.)
|
|
01-15-2011, 08:13 AM |
|
Seragath
Junior Member
Posts: 34
Threads: 1
Joined: Jan 2011
Reputation:
0
|
RE: HPS script issue
Please change the thread to [Solved] example: "HPS script issue [Solved]"
|
|
01-15-2011, 06:07 PM |
|
|