Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Whats wrong with my script?
Author Message
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #1
Whats wrong with my script?
Hi, I was trying to script random events today but it doesnt work, can anyone see whats wrong with my script'?

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}

void Func01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1, 3);
if (x == 1)
{
[SetEntityActive("servant_grunt_1", true);]
return;
}
if (x == 2)
{
[SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);]
return;
}
if (x == 3)
{
[SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
SetEntityActive("servant_grunt_3", true);]
return;
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{    
PlayMusic("ambience_voice.ogg", true, 0.7f, 1, 0, false);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

05-28-2011 10:48 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #2
RE: Whats wrong with my script?
[SetEntityActive("servant_grunt_1", true);]

'[' & ']' needless. Omit all of them.

05-28-2011 11:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
teddifisk Offline
Senior Member

Posts: 303
Joined: Dec 2010
Reputation: 2
Post: #3
RE: Whats wrong with my script?
(05-28-2011 11:13 AM)Tanshaydar Wrote:  [SetEntityActive("servant_grunt_1", true);]

'[' & ']' needless. Omit all of them.

My script now looks like this but it still doesnt work:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}

void Func01(string &in asParent, string &in asChild, int alState)
{
int x = RandInt(1, 3);
if (x == 1)
{
SetEntityActive("servant_grunt_1", true);
return;
}
if (x == 2)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
return;
}
if (x == 3)
{
SetEntityActive("servant_grunt_1", true);
SetEntityActive("servant_grunt_2", true);
SetEntityActive("servant_grunt_3", true);
return;
}
}

////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("ambience_voice.ogg", true, 0.7f, 1, 0, false);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

05-28-2011 11:14 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,091
Joined: Mar 2009
Reputation: 66
Post: #4
RE: Whats wrong with my script?
I'm not sure what's wrong since script looks right. There might be something wrong with the map file. Try to add debug messages to see if player collides with the area and if statements are working.

05-28-2011 11:19 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)