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
Posted 27 July 2014 - 04:48 PM
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
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with:
Posted 27 July 2014 - 04:56 PM
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.
Posted 27 July 2014 - 05:00 PM
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
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with:
Posted 27 July 2014 - 09:54 PM
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
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with:
Posted 27 July 2014 - 10:16 PM
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.
Chris
Modding Hobbyist
Emergency 4 Tutorials • Northview South County Mod • Northview Paramedics Mod (WIP) • EM4 Packer Utility
Posted 27 July 2014 - 10:21 PM
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; } }
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with:
Posted 27 July 2014 - 10:35 PM
Chris
Modding Hobbyist
Emergency 4 Tutorials • Northview South County Mod • Northview Paramedics Mod (WIP) • EM4 Packer Utility
Posted 27 July 2014 - 11:46 PM
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
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with:
Posted 31 July 2014 - 02:36 AM
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 };
[LA Mod] A Police Station that functions like a Fire Station, check it out!
Some scripting I could use some help with: