OnElementStartSync

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This event is triggered when an element becomes synced by a player.

Parameters

player newSyncer
  • newSyncer: a 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

Click to collapse [-]
Server

This 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 a certain area by destroying them upon entrance

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


Event functions