ConnectNPCEx: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
{{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, script="", host="127.0.0.1", ...)</syntaxhighlight>
params=<syntaxhighlight lang="lua">(name, x, y, z, angle, skinId, weaponId, classId, script="", host="127.0.0.1", ...)</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.
::x : The x co-ordinate where the npc is to be spawned.
Line 12: Line 12:
::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 paramter 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 )
::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.  
::host : This IP address of the host.  

Revision as of 04:27, 5 December 2022

This function was added in v1.5 and will not work on previous versions.


Description:
Connect an NPC to the server with extended parameters


Parameters:

(name, x, y, z, angle, skinId, weaponId, classId, script="", host="127.0.0.1", ...)

name : The name for the NPC to connect to server.
x : The x co-ordinate 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
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.
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.
host : This IP address of the host.
... : 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",100.0,200.0,10.0,0.0,116,0,"","","paramter1", "parameter2", "parameter3");
}

Related Functions

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