Scripting/Server/Classes/Vehicle/AttachTo_2

(v0.3.1-r2+) Glues the object to a vehicle, player or another object at the offset with an optional rotation offset in degrees; returns true when it worked. An attached object has no collision. Detach() puts it back at its own stored Pos (or at the given pos); it is also detached when the parent goes away.

Syntax

object.AttachTo(vehicle | player | object, x, y, z [, rx, ry, rz])
object.Detach([pos])

Arguments

Example

function onPlayerCommand( player, cmd, params )
{
	if ( cmd == "attachto" )
	{
		local pos = player.Pos;
		local obj = CreateObject( 1362, player.Pos );
		obj.AttachTo( 0, pos.x, pos.y, pos.z );
	}
}

This sample was generated from the signature – adapt the values to your gamemode.

Section: Vehicle

Categories: Server methods | Vehicle