setElementSyncer | Multi Theft Auto: Wiki Skip to content

setElementSyncer

Client-side
Server-side
Shared

Pair: getElementSyncer

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function can be used to change the syncer (player) of an element. The syncer is the player who is responsible for informing the server about the state of that element - it's position, orientation and other state information. The function can be also used to remove an element's syncer.

OOP Syntax Help! I don't understand this!

  • Method:element:setSyncer(...)
  • Variable: .syncer

Syntax

bool setElementSyncer ( element theElement, player thePlayer, [ bool persist = false ] )
Required Arguments
  • theElement: The element whose syncer you wish to change.
  • thePlayer: The player who should be the new syncer of the element. If set to false , this element will not have a syncer. If set to true , MTA will pick automatically the nearest or most relevant player to that element.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • persist (default: false): If true , the server will not automatically change the syncer. If set to false , default syncer behavior resumes.

Returns

  • bool: value

Returns true if the syncer was changed successfully, false if the element passed was not a ped or vehicle.

Code Examples

shared
addCommandHandler ( "createMyVehicle", function ( player, command )
local x, y, z = getElementPosition ( player )
local myVehicle = createVehicle ( 411, x, y, z )
setElementSyncer ( myVehicle, player )
end
)

See Also

Element Functions