ConnectNPCEx: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by one other user not shown)
Line 1: Line 1:
<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;">
<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;">
This function was added in v1.5 and will not work on previous versions.
From v1.6 beta 5, the second parameter is a '''Vector'''. Earlier parameters 2,3 and 4 were x, y and z.
</poem>
</poem>
{{Welcome|
{{Welcome|
desc=Connect an NPC to the server with extended parameters|
desc=Connect an NPC to the server with extended parameters|
params=<syntaxhighlight lang="lua">(name, x, y, z, angle, skinId, weaponId, classId, script="", host="127.0.0.1", ...)</syntaxhighlight>
params=<syntaxhighlight lang="lua">(name, Pos, angle, skinId, weaponId, classId, script="", enableconsoleinput=false, host="127.0.0.1", plugins="", ...)</syntaxhighlight>
<poem>::name : The name for the NPC to connect to server.
<poem>::name : The name for the NPC to connect to server.
::x : The x co-ordinate where the npc is to be spawned.
::Pos : The Vector position where the npc is to be spawned.
::y : The y co-ordinate where the npc is to be spawned.
::z : The z co-ordinate where the npc is to be spawned.
::'''Below are optional parameters'''
::'''Below are optional parameters'''
::angle : The npc's angle  
::angle : The npc's angle  
::skinId : The skin for the npc. Note that clients in VCMP 0.4 can not set skin by themselves. It is the server which can set skins. So if this paramter is provided then a command "_npc_skin_request skinId" will be send to server when spawning for first time.
::skinId : The skin for the npc. Note that clients in VCMP 0.4 can not set skin by themselves. It is the server which can set skins. So if this parameter is provided then a command "_npc_skin_request skinId" will be send to server when spawning for first time.
::weaponId : The weapon in npc's hand when spawning for the first time. Note that this must be one of the three weapons of the first spawn class of the server. Otherwise sometimes the server kick npc for 'acquiring' weapons.
::weaponId : The weapon in npc's hand when spawning for the first time. Note that this must be one of the three weapons of the first spawn class of the server. Otherwise sometimes the server kick npc for 'acquiring' weapons.
::classId :: The class npc should select at 'class selection' screen. 0 means first class, 1 means second and so on. Default is 0 ( if parameter is not passed. ie. In calling function, less than 8 parameters are passed )
::classId :: The class npc should select at 'class selection' screen. 0 means first class, 1 means second and so on. Default is 0 ( if parameter is not passed. ie. In calling function, less than 8 parameters are passed )
::script : The script NPC may use. This script must reside in npcscripts folder. From v1.5 this has been made optional. ie. npc's can be created without any script.
::script : The script NPC may use. This script must reside in npcscripts folder. From v1.5 this has been made optional. ie. npc's can be created without any script.
::host : This IP address of the host.  
::enableconsoleinput : true/false. If true, text typed in the console is passed to the npcscript by calling the function [[OnConsoleInput]], if available. If true, the console will not be hidden. If false, text cannot be typed in the console and visibility of console depends on [[ShowNPCConsole]] called earlier.
::host : This IP address of the host. host = "" will be replaced with "127.0.0.1".
::plugins : The string containing [[NPC Plugins|plugins]] to be loaded.
::... : The string parameters. If specified they are passed as an array to [[OnNPCScriptLoad]]</poem>|
::... : The string parameters. If specified they are passed as an array to [[OnNPCScriptLoad]]</poem>|
retval= This function always return 1.|
retval= This function always return 1.|
Line 21: Line 21:
function onScriptLoad()
function onScriptLoad()
{
{
ConnectNPCEx("Mercedes",100.0,200.0,10.0,0.0,116,0,"","","paramter1", "parameter2", "parameter3");
ConnectNPCEx("Mercedes", Vector(100.0,200.0,10.0), 0.0,116,0,"",true,"","paramter1", "parameter2", "parameter3");
}
}
</source>|
</source>|

Latest revision as of 15:24, 13 December 2023

From v1.6 beta 5, the second parameter is a Vector. Earlier parameters 2,3 and 4 were x, y and z.


Description:
Connect an NPC to the server with extended parameters


Parameters:

(name, Pos, angle, skinId, weaponId, classId, script="", enableconsoleinput=false, host="127.0.0.1", plugins="", ...)

name : The name for the NPC to connect to server.
Pos : The Vector position where the npc is to be spawned.
Below are optional parameters
angle : The npc's angle
skinId : The skin for the npc. Note that clients in VCMP 0.4 can not set skin by themselves. It is the server which can set skins. So if this parameter is provided then a command "_npc_skin_request skinId" will be send to server when spawning for first time.
weaponId : The weapon in npc's hand when spawning for the first time. Note that this must be one of the three weapons of the first spawn class of the server. Otherwise sometimes the server kick npc for 'acquiring' weapons.
classId :: The class npc should select at 'class selection' screen. 0 means first class, 1 means second and so on. Default is 0 ( if parameter is not passed. ie. In calling function, less than 8 parameters are passed )
script : The script NPC may use. This script must reside in npcscripts folder. From v1.5 this has been made optional. ie. npc's can be created without any script.
enableconsoleinput : true/false. If true, text typed in the console is passed to the npcscript by calling the function OnConsoleInput, if available. If true, the console will not be hidden. If false, text cannot be typed in the console and visibility of console depends on ShowNPCConsole called earlier.
host : This IP address of the host. host = "" will be replaced with "127.0.0.1".
plugins : The string containing plugins to be loaded.
... : The string parameters. If specified they are passed as an array to OnNPCScriptLoad


Return Values:
This function does not return any specific values.


Example

function onScriptLoad()
{
	ConnectNPCEx("Mercedes", Vector(100.0,200.0,10.0), 0.0,116,0,"",true,"","paramter1", "parameter2", "parameter3");
}

Related Functions

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