ConnectNPCEx

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search

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.