ConnectMultipleNpcs
This function was added in v1.8 beta and will not work on previous versions.
Description:
Opens a .hrec_file and starts connecting npcs using name present in the file.
Parameters:
(filename,host="127.0.0.1",flags=7,execArg="")
filename : The name of the hrec file without the ".hrec" extension. The file must be present in the recordings/a_server/ folder.
host : The IP address of the server to connect the npcs.
flags :
Flag | Description | Value |
---|---|---|
HF_AUTOMATIC_PLAY | Starts playing playback on class select. | 1 |
HF_DISCONNECT_AT_END | Disconnects after playback is finished. | 2 |
HF_SHOW_CONSOLE | The console of NPCs will be visible. | 4 |
execArg : The string to be executed when npc is connected.
When HF_AUTOMATIC_PLAY is used, "function OnNPCClassSelect() {if (!IsPlaybackRunning())StartRecordingPlayback(3, \\\""+filename_rec+"\\\")};"
is prepended to execArg. When HF_DISCONNECT_AT_END is used, "function OnRecordingPlaybackEnd(){QuitServer()};"
is also prepended. If you do not want npc to play automatically on connect (on Class Select), pass HF_NONE=0 as flag and use execArg parameter.
Return Values:
true, on success. throws error on failure.
Error codes information for debugging
Error Code | Description |
---|---|
1 | Indicates that a play operation is already in progress. |
2 | Indicates an error occurred while trying to open a file. |
3 | Indicates an error during the process of reading a magic number from a file. |
4 | Indicates that the magic number read from the file is not valid or expected. |
5 | Indicates an error occurred while reading data from a file. |
6 | Indicates a failure in memory allocation, possibly during dynamic memory allocation. |
7 | Indicates a failure to establish a connection. |
8 | Indicates an error while trying to read a new row or record. |
9 | Indicates an error while attempting to seek or position within a file. |
Example
- Assuming file titled two_friends.hrec in
recordings/a_server/
folder. If friend1.rec and friend2.rec are the associated playback recordings with the .hrec_file given, they must be in the foldernpcscripts/recordings
like any other .rec_file.
- Assuming file titled two_friends.hrec in
ConnectMultipleNpcs("two_friends");
Related Functions
The following functions may be helpful as they relate to this function in one way or another.