Ga naar inhoud


Foto

ChildID's. Can someone explain them to me?


  • Please log in to reply
8 replies to this topic

#1 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 27 juli 2014 - 04:48

As the title states, I'm wondering how the childID's work, specifically in the ToPoliceStation script. I've got a general idea, but I don't know how they work.

 

Tim



#2 itchboy

itchboy

    Assistant Chief

  • Member
  • 1788 Posts:
  • Gender:Not Telling

Gepost 27 juli 2014 - 04:56

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.



#3 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 27 juli 2014 - 05:00

Aaah, now it's kinda clear to me, thanks. I'll go messing around with them, see if I can get them to werk and if I really understand them.

 

Tim



#4 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 27 juli 2014 - 09:54

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



#5 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Posts:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Gepost 27 juli 2014 - 10:16

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.



#6 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 27 juli 2014 - 10:21

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;
	}
} 


#7 Chris07

Chris07

    Senior Captain

  • Member
  • 292 Posts:
  • Gender:Male
  • Location:Los Angeles, CA, USA
  • Interests:Medicine & Computer Science...what a combo!

Gepost 27 juli 2014 - 10:35

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.

#8 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 27 juli 2014 - 11:46

Thank you sir, you've clarified a lot.

I've got many more questions about the script I'm working on, but they don't fit this topic unfortunately. Too bad, because you seem to know a lot about it. Hopefully you'll find my other topics too!

 

Tim



#9 timmiej93

timmiej93

    Captain

  • Members
  • 206 Posts:
  • Gender:Male
  • Location:Netherlands

Gepost 31 juli 2014 - 02:36

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
};