Frictional Games Forum (read-only)

Full Version: Problems spawning an entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.


void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

{
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc1" , true , 1);
}

void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}

}


highlighted in bold is the one that is having the problems, it says there's an expected ( between the
void and the MonsterFunc1

Any help on this?
You should put your collision callbacks in a function blog, just putting them loose will not work like that

Code:
{
  something
}

Second thing is, you cannot put same name to two different functions. Make it MonsterFunc2 and put your callback into your OnStart function.
(10-13-2011, 11:07 AM)Tanshaydar Wrote: [ -> ]You should put your collision callbacks in a function blog, just putting them loose will not work like that

Code:
{
  something
}

Second thing is, you cannot put same name to two different functions. Make it MonsterFunc2 and put your callback into your OnStart function.
Thanks for the response, when your talking about the callbacks, where would i have to the callbacks in my script?
Usually in OnStart, which runs when your map starts.
(10-13-2011, 12:05 PM)Tanshaydar Wrote: [ -> ]Usually in OnStart, which runs when your map starts.
Thanks for that, but it comes up with unexpected token in Line 12 column 1


void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

{ <<<<----- Right here
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}
void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}


I've looked at some tutorials in basic scripting and haven't found anything that i could use in this situation. I need some help here Smile
Code:
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}


void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}
(10-13-2011, 12:21 PM)Tanshaydar Wrote: [ -> ]
Code:
void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_2" , "MonsterFunc2" , true , 1);
}


void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_brute_1" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);

}

void MonsterFunc2(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
SetEntityActive("barrel01_21" , true);
SetEntityActive("barrel01_22" , true);
SetEntityActive("barrel01_28" , true);
SetEntityActive("barrel01_29" , true);
SetEntityActive("barrel01_23" , true);
SetEntityActive("barrel01_24" , true);
SetEntityActive("barrel01_25" , true);
SetEntityActive("barrel01_27" , true);
SetEntityActive("barrel01_26" , true);
SetEntityActive("barrel01_10" , true);
PlaySoundAtEntity("", "explosion_rock_large.snt", "Player", 0.5f, false);
}
Thank you, i really appreciate that. You didn't have to give me the script. You could of told me what was in the wrong place, I am SOOOOO glad it works now, thank you for your help Smile
Actually you can see what I've changed in the script so that might tell you how to do it. But showing it with a working script would be better I thought.