Jump to content
timmiej93

ChildID's. Can someone explain them to me?

Recommended Posts

ChildID's are essentially divisions of the main script. Each ChildID is a predefined set of conditions for the script to execute. It is used in conjunction with the
v.PushActionExecuteCommand() function. Note the number that is before false or true.

Example:
v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);
This means that the script will execute that command in its first child.

Its logic is like this:

if (ChildID == 1){	Do some stuff}else if (ChildID == 2){	Do other stuff different from the first}You can use the PushActionExecuteCommand to execute a specific child in the script, or in other scripts. The important thing is that number.
Link to comment
Share on other sites

One little question I'm finding right now:

 

In a script, say it looks like this

			if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0)			{				PersonList transports = v.GetTransports();				if (transports.GetNumPersons() > 0)					v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);				else

Does the script "jump" to the ChildID=1 section straight after the line "v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);", or does it finish something first?

 

Tim

Link to comment
Share on other sites

Assuming that we're in CMD_TOPOLICESTATION right now...

 

Well since you are using a PushAction, it will execute CMD_TOPOLICESTATION, but it will not pause the execution of the rest of the script in which it is called, unless you add another action to the PushAction queue, in which case that action will execute after CMD_TOPOLICESTATION has been executed. PushAction is a Queue which is processed separate of the rest of the script.

 

It is relatively instant unless your caught behind a PushActionWait in which case you should probably start an ACTION_NEWLIST if you don't want to wait.

Link to comment
Share on other sites

This is indeed the CMD_TOPOLICESTATION command

 

So if I understand correctly, below script should tell the Van to do whatever is stated under ChildID=1 whenever it has transports in it, and when it doesn't, it parks at Donut, right?

if(StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0){	PersonList transports = v.GetTransports();	if (transports.GetNumPersons() > 0)		v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);	else	{		Park at Donut;	}} 
Link to comment
Share on other sites

It should. Looks good to me, However, I often find out the hard way I'm wrong!

I would probably use ACTION_NEWLIST instead of ACTION_APPEND so that it is in its own queue and won't get stuck behind another command.

Link to comment
Share on other sites

Hello Chris,

Sorry to bother you again, but I'm running into trouble.

 

I've got a script set up like seen below, but for some reason the game just ignores me when I call the command from the VAN, and it just goes to ChildID 1, straight below this piece of code, instead of ChildID2. Any idea how this can be?

Or is it just my misunderstanding?

if (StrCompare(v.GetPrototypeFileName(), OBJ_VAN) == 0 || StrCompare(v.GetPrototypeFileName(), OBJ_SUV == 0) || StrCompare(v.GetPrototypeFileName(), OBJ_CRUISER04) == 0 || StrCompare(v.GetPrototypeFileName(), OBJ_CRUISER01) == 0){		v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 2, false);	Mission::PlayHint("1");	return;}else if (v.GetVehicleType() == VT_POLICE_PHC){	v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 3, false);	return;}else{	v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);}

I'm assuming that after a PushAction to ChildID2, the script continues from there right?

So below script (simplified ofcourse) should give everybody treats and just skip blowing up the vehicle right?

v.PushActionExecuteCommand(ACTION_APPEND, CMD_TOPOLICESTATION, Caller, 1, false);if(ChildID==0);{    Blow up vehicle}if(ChildID==1);{    Give everybody treats};
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...