SendPassengerSyncData: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
(Created page with "{{Welcome| desc= Sends a passenger sync packet to server. The NPC's position is updated in server corresponding to position of vehicle in which the bot is passenger.| params=<...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight> |
params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight> |
example=<source lang="lua">
example=<source lang="lua">
SetPSLimit(-1); //Disable automatic passenger syncing
pst <- null; //short for passenger sync timer
pst <- null; //short for passenger sync timer
function OnNPCEnterVehicle(vehicleid, seatid)  
function OnNPCEnterVehicle(vehicleid, seatid)  
Line 10: Line 11:
if( pst )
if( pst )
KillTimer( pst );
KillTimer( pst );
pst = SetTimerEx("RemainSeated",1000,0);
pst = SetTimerEx("RemainSeated",300,0);
}
}
}
}
Line 24: Line 25:
}
}
</source>|
</source>|
retvals=true if the function is successful, false if not ( npc is not on vehicle ). It can return null also on other type of failures|
note=This was added in v1.5 patch 1 and will not work in previous versions.|
note=This was added in v1.5 patch 1 and will not work in previous versions.|
relfuncs=*[[SendOnFootSyncData]]
relfuncs=*[[SetPSLimit]]|
*[[SendOnFootSyncDataLV]]|
}}
}}

Latest revision as of 07:37, 22 December 2022


Description:
Sends a passenger sync packet to server. The NPC's position is updated in server corresponding to position of vehicle in which the bot is passenger.


Parameters:

NoParams


Return Values:
true if the function is successful, false if not ( npc is not on vehicle ). It can return null also on other type of failures

Important Note:
This was added in v1.5 patch 1 and will not work in previous versions.

Example

SetPSLimit(-1); //Disable automatic passenger syncing
pst <- null; //short for passenger sync timer
function OnNPCEnterVehicle(vehicleid, seatid) 
{ 
    if(seatid)
	{
		if( pst )
			KillTimer( pst );
		pst = SetTimerEx("RemainSeated",300,0);
	}
}
function OnNPCConnect(myplayerid) 
{ 
    npcid <- myplayerid;
}
function RemainSeated()
{
	if( GetPlayerVehicleID(npcid) )
		SendPassengerSyncData();
	else KillTimer(pst);
}

Related Functions

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