ConnectMultipleNpcs: Difference between revisions
No edit summary |
No edit summary |
||
(11 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
:: filename : The name of the hrec file without the ".hrec" extension. The file must be present in the recordings/a_server/ folder. | :: 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. | :: host : The IP address of the server to connect the npcs. | ||
:: flags : </poem>{ | :: flags : </poem> | ||
{{{!}} class="wikitable" | |||
! Flag !! Description | {{!}}+ Flag Table | ||
! 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 | {{!}}} | ||
retvals=true, on success. throws error on failure.| | <poem> | ||
:: execArg : The string to be executed when npc is connected. | |||
When HF_AUTOMATIC_PLAY is used, <source inline lang="lua">"function OnNPCClassSelect() {if (!IsPlaybackRunning())StartRecordingPlayback(3, \\\""+filename_rec+"\\\")};"</source> is prepended to execArg. When HF_DISCONNECT_AT_END is used, <source inline lang="lua">"function OnRecordingPlaybackEnd(){QuitServer()};"</source> 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. | |||
</poem>| | |||
example= | |||
::Assuming file titled ''two_friends.hrec'' in <source inline>recordings/a_server/</source> folder. If ''friend1.rec'' and ''friend2.rec'' are the associated playback recordings with the [[.hrec_file]] given, they must be in the folder <source inline>npcscripts/recordings</source> like any other [[.rec_file]]. | |||
<source lang="lua"> | |||
ConnectMultipleNpcs("two_friends"); | |||
</source>| | |||
retvals=true, on success. throws error on failure. | |||
Error codes information for debugging | |||
{{{!}} class="wikitable" | |||
{{!}}+ Error Codes Information | |||
! 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. | |||
{{!}}} | |||
| | |||
relfuncs=*[[ConnectNPC]] | relfuncs=*[[ConnectNPC]] | ||
*[[ConnectNPCEx]] | *[[ConnectNPCEx]] |
Latest revision as of 14:48, 17 February 2024
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.