Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems spawning an entity
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#1
Problems spawning an entity



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?
10-13-2011, 11:03 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#2
RE: Problems spawning an entity

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

{
  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
Website Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#3
RE: Problems spawning an entity

(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

{
  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?
10-13-2011, 11:49 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#4
RE: Problems spawning an entity

Usually in OnStart, which runs when your map starts.

10-13-2011, 12:05 PM
Website Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#5
RE: Problems spawning an entity

(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
10-13-2011, 12:15 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#6
RE: Problems spawning an entity

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
Website Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#7
RE: Problems spawning an entity

(10-13-2011, 12:21 PM)Tanshaydar Wrote:
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
10-13-2011, 12:30 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#8
RE: Problems spawning an entity

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.

10-13-2011, 12:54 PM
Website Find




Users browsing this thread: 3 Guest(s)