OnElementStartSync: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Zangomangu (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server event}} | {{Server event}} | ||
This event is triggered when an element becomes synced by a player. | This event is triggered when an element becomes synced by a player. | ||
Line 15: | Line 14: | ||
==Example== | ==Example== | ||
When an element receives a new syncer, this example matches the model of the element to match the player. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function elementStartSync( newSyncer ) | |||
local strElementType = getElementType( source ) | |||
local playerVehicle = getPedOccupiedVehicle( newSyncer ) | |||
if ( strElementType == 'vehicle' ) then | |||
if ( not playerVehicle ) then return false end | |||
setElementModel( source, getElementModel(playerVehicle) ) | |||
elseif ( strElementType == 'ped' ) then | |||
setElementModel( source, getElementModel(newSyncer) ) | |||
end | |||
end | |||
addEventHandler ('onElementStartSync', root, elementStartSync) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Element events}} | {{See also/Server event|Element events}} |
Revision as of 14:55, 5 January 2014
This event is triggered when an element becomes synced by a player.
Parameters
player newSyncer
- newSyncer: player element representing the player who is now syncing the element
Source
The source of this event is the element that got synced by a player.
Example
When an element receives a new syncer, this example matches the model of the element to match the player.
function elementStartSync( newSyncer ) local strElementType = getElementType( source ) local playerVehicle = getPedOccupiedVehicle( newSyncer ) if ( strElementType == 'vehicle' ) then if ( not playerVehicle ) then return false end setElementModel( source, getElementModel(playerVehicle) ) elseif ( strElementType == 'ped' ) then setElementModel( source, getElementModel(newSyncer) ) end end addEventHandler ('onElementStartSync', root, elementStartSync)
See Also
Element events
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled