ConnectMultipleNpcs: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by one other user not shown)
Line 10: Line 10:
! Flag !! Description !!Value
! Flag !! Description !!Value
{{!}}-
{{!}}-
{{!}} AUTOMATIC_PLAY {{!}}{{!}} Starts playing playback on class select.{{!}}{{!}}1
{{!}} HF_AUTOMATIC_PLAY {{!}}{{!}} Starts playing playback on class select.{{!}}{{!}}1
{{!}}-
{{!}}-
{{!}} DISCONNECT_AT_END {{!}}{{!}} Disconnects after playback is finished.{{!}}{{!}}2
{{!}} HF_DISCONNECT_AT_END {{!}}{{!}} Disconnects after playback is finished.{{!}}{{!}}2
{{!}}-
{{!}}-
{{!}} SHOW_CONSOLE {{!}}{{!}} The console of NPCs will be visible.{{!}}{{!}}4
{{!}} HF_SHOW_CONSOLE {{!}}{{!}} The console of NPCs will be visible.{{!}}{{!}}4
{{!}}}
{{!}}}
<poem>
<poem>
:: execArg = The string to be executed when npc is connected.  
:: execArg : The string to be executed when npc is connected.  
When AUTOMATIC_PLAY is used, <source inline lang="lua">"function OnNPCClassSelect() {if (!IsPlaybackRunning())StartRecordingPlayback(3, \\\""+filename+"\\\")};"</source> is prepended to execArg. When DISCONNECT_AT_END is used, <source inline lang="lua">"function OnRecordingPlaybackEnd(){QuitServer()};"</source> is also prepended. If you want to manually do everything, pass 0 as flag and use execArg parameter.
 
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>|
</poem>|
example=<source lang="lua">
example=
ConnectMultipleNpcs("two_friends")
::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>|
</source>|


retvals=true, on success. throws error on failure.|
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 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 : 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 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.


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 folder npcscripts/recordings like any other .rec_file.
ConnectMultipleNpcs("two_friends");

Related Functions

The following functions may be helpful as they relate to this function in one way or another.