SendOnFootSyncDataLV: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Welcome|
{{Welcome|
desc= Same as [[SendOnFootSyncData]] with the fields like keys, position, health, armour etc of the function used from the Local Values ( calculated from the last packet send to server or modified using [[SetLocalValue]] )|
desc= Modify angle, health or weapon of npc and calling function will make it reflect in server. LV means Local Value or Last Values. It can be modified using [[SetLocalValue]]|
params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight> |
params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight> |
note=This was added in v1.4 and will not work in previous builds.|
example=<source lang="lua">
//The following function when called will make npc attack player with pid as ID with a  Baseball bat.
function DoMeleeAttack( pid )
{
local ppos = GetPlayerPos( pid );
local mpos = GetMyPos( );
local angle = atan2( - (ppos.x- mpos.x), ppos.y-mpos.y);
//Set the weapon
SetLocalValue(I_CURWEP, 6 );
//Set the angle
SetLocalValue( F_ANGLE , angle );
//Set the keys ( very important )
SetLocalValue( I_KEYS, 576 );
//Send the data to server now.
SendOnFootSyncDataLV();
}
</source>|
note=This was added in v1.5 and will not work in previous builds.|
relfuncs=*[[SendOnFootSyncData]]|
relfuncs=*[[SendOnFootSyncData]]|
}}
}}

Revision as of 17:56, 7 December 2022


Description:
Modify angle, health or weapon of npc and calling function will make it reflect in server. LV means Local Value or Last Values. It can be modified using SetLocalValue


Parameters:

NoParams


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

Important Note:
This was added in v1.5 and will not work in previous builds.

Example

//The following function when called will make npc attack player with pid as ID with a  Baseball bat.
function DoMeleeAttack( pid )
{
	local ppos = GetPlayerPos( pid );
	local mpos = GetMyPos( );
	local angle = atan2( - (ppos.x- mpos.x), ppos.y-mpos.y);
	//Set the weapon
	SetLocalValue(I_CURWEP, 6 );
	//Set the angle
	SetLocalValue( F_ANGLE , angle );
	//Set the keys ( very important )
	SetLocalValue( I_KEYS, 576 );
	//Send the data to server now.
	SendOnFootSyncDataLV();
}

Related Functions

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