OnElementStartSync: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 45: | Line 45: | ||
</section> | </section> | ||
{{See also/Server event|Element events}} | |||
Revision as of 02:56, 27 September 2018
This event is triggered when an element becomes synced by a player.
Parameters
player newSyncer
Source
The source of this event is the element that got synced by a player.
Example
Click to collapse [-]
ServerThis example matches the model of the element to the player, when an element receives a new syncer.
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)
This example will prevent vehicles from entering an area covered by a colshape, by automatically destroying them upon enter.
local myColShape = createColCuboid(1000, -800, 900, 1000, 1000, 1000) function checkSyncOfVehicles() if isElement(source) and getElementType (source) == "vehicle" and isElementWithinColShape(source, myColShape) then destroyElement (source) end end addEventHandler ("onElementStartSync", root, checkSyncOfVehicles)
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