MaksoPL
Member
Posts: 51
Threads: 26
Joined: Mar 2014
Reputation:
0
Error with scripts
Hi. I've got an error with a script:
main (10,1) Unexpected token '{'
main (15,16) Expected identifier
main (16,1) Unexpected token '}'
My .hps file:
void OnStart()
{
SetSanityDrainDisabled(true);
GiveItemFromFile("lantern", "lantern.ent");
for(int i=0;i< 25;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
}
{
AddEntityCollideCallback("Player", "12_girl_scream", "GirlScream", true, 1);
AddEntityCollideCallback("Player", "message1", "Message1", true, 1);
AddEntityCollideCallback("Player", "message2", "Message2", true, 1);
}
PlaySoundAtArea("12_girl_scream", "12_girl_scream.snt", "GirlScream01", 0, false);
}
void Message1(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "Wiadomosc1", 10);
}
void Message2(string &in asChild, string &in asParent, int alState)
{
SetMessage("Messages", "Wiadomosc2", 10);
}
void OnEnter()
{
PlayMusic("07_amb", true, 1.0f, 4.0f, 1, true);
}
What i've must do?
01-15-2015, 01:53 PM
DnALANGE
Banned
Posts: 1,549
Threads: 73
Joined: Jan 2012
RE: Error with scripts
Do like this;
void OnStart () { SetSanityDrainDisabled ( true ); GiveItemFromFile ( "lantern" , "lantern.ent" ); for( int i = 0 ; i < 25 ; i ++) GiveItemFromFile ( "tinderbox_" + i , "tinderbox.ent" ); AddEntityCollideCallback ( "Player" , "12_girl_scream" , "GirlScream" , true , 1 ); AddEntityCollideCallback ( "Player" , "message1" , "Message1" , true , 1 ); AddEntityCollideCallback ( "Player" , "message2" , "Message2" , true , 1 ); } void GirlScream ( string & in asParent , string & in asChild , int alState ) { PlaySoundAtEntity ( "12_girl_scream" , "12_girl_scream.snt" , "GirlScream01" , 1.0f , true ); } void Message1 ( string & in asChild , string & in asParent , int alState ) { SetMessage ( "Messages" , "Wiadomosc1" , 10 ); } void Message2 ( string & in asChild , string & in asParent , int alState ) { SetMessage ( "Messages" , "Wiadomosc2" , 10 ); } void OnEnter () { PlayMusic ( "07_amb" , true , 1.0f , 4.0f , 1 , true ); }
Quote: That should do the trick, IF you intended to do it like i do now though.
IF not, we are here to help you out.
---
Here are some things you miswrote;
You were having some {}
Where they should NOT be there.
And:
{// Wrong
AddEntityCollideCallback("Player", "12_girl_scream", "GirlScream", true, 1); //put this in OnSTART
AddEntityCollideCallback("Player", "message1", "Message1", true, 1); //put this in OnSTART
AddEntityCollideCallback("Player", "message2", "Message2", true, 1); //put this in OnSTART
}//Wrong
PlaySoundAtArea("12_girl_scream", "12_girl_scream.snt", "GirlScream01", 0, false); <<<- Use PlaySoundAtEntity in stead.
}
IF you are making a function\script, try with void
(This post was last modified: 01-15-2015, 02:29 PM by DnALANGE .)
01-15-2015, 02:18 PM
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
RE: Error with scripts
From Julius Caesar's bot, log compiled.
Spoiler below!
ERRORS FOUND: 2
MISTAKES: NO CALLBACK FUNCTION
INCORRECT SYNTAX
FIXING: CORRECT FUNCTION PLACEMENT
CORRECTING SYNTAX
RUN: GENERATE CORRECTION
GENERATING CORRECTION....
WORKING...
void OnStart () { SetSanityDrainDisabled ( true ); GiveItemFromFile ( "lantern" , "lantern.ent" ); for( int i = 0 ; i < 25 ; i ++) GiveItemFromFile ( "tinderbox_" + i , "tinderbox.ent" ); AddEntityCollideCallback ( "Player" , "12_girl_scream" , "GirlScream" , true , 1 ); AddEntityCollideCallback ( "Player" , "message1" , "Message1" , true , 1 ); AddEntityCollideCallback ( "Player" , "message2" , "Message2" , true , 1 ); } void GirlScream ( string & in asParent , string & in asChild , int alState ) { PlaySoundAtEntity ( "12_girl_scream" , "12_girl_scream.snt" , "GirlScream01" , 0 , false ); } void Message1 ( string & in asChild , string & in asParent , int alState ) { SetMessage ( "Messages" , "Wiadomosc1" , 10 ); } void Message2 ( string & in asChild , string & in asParent , int alState ) { SetMessage ( "Messages" , "Wiadomosc2" , 10 ); } void OnEnter () { PlayMusic ( "07_amb" , true , 1.0f , 4.0f , 1 , true ); }
SUCCESSFUL. CORRECTION GENERATED.
---END---
"Veni, vidi, vici."
"I came, I saw, I conquered."
01-16-2015, 02:58 PM
DnALANGE
Banned
Posts: 1,549
Threads: 73
Joined: Jan 2012
RE: Error with scripts
??? what went wrong with my script?
didnt check mine tho.
just pointed out things what could have been wrong..
01-16-2015, 03:06 PM