Skip to content

createRope

Shared

Creates a managed rope driven by one of GTA's own native rope types.

Syntax

rope|false createRope(float x, float y, float z [, table options])

Arguments

xfloat

World X.

yfloat

World Y.

zfloat

World Z.

optionstableoptional

Optional type, duration, length, winchHeight, fixedNode, sitOnGround, physics, holderOffset, topVelocity, holder and carriedElement.

Table keys

typestringoptional · default "swat"

winchMagnet, harness, miniMagnet, dockCrane, wreckingBall, quarryCrane, vegasCrane or swat.

holderelementoptional

Physical element the rope hangs from. Required for every type except swat.

holderOffsettableoptional

Local attachment offset on the holder, as {x, y, z}.

lengthfloatoptional · default 0

Rope length. 0 or greater.

winchHeightfloatoptional · default 0.5

Winch height.

fixedNodeintoptional · default 0

Which node is pinned, 0 through 30. A rope holds at most 32 nodes.

durationintoptional · default 0

Lifetime in milliseconds. 0 means the rope does not expire on its own.

sitOnGroundbooloptional · default false

Whether the rope rests on the ground.

physicsbooloptional · default true

Whether the native rope solver simulates it.

topVelocitytableoptional

Velocity applied at the rope top, as {x, y, z}.

carriedElementelementoptional

Element attached to the rope on creation.

Returns

A rope element, or false when the position or options are rejected.

Ownership and lifecycle

A rope belongs to the resource that created it. GTA has eight native rope slots, so Neon leases them to the logical ropes that need one; a rope without a lease still exists but is not natively simulated at that moment. Every native type except swat requires a valid physical holder.

Important behavior
  • Every type except swat requires a physical holder element. GTA's CRope::Update dereferences the holder, so a rope without one is refused rather than allowed to crash.
  • Server-created ropes are synchronized. Clients can also create local ropes.
  • GTA has eight native rope slots. More logical ropes than that can exist; Neon leases the slots to the ropes that need them.

Example

local rope = createRope(x, y, z, {
type = "wreckingBall",
length = 14,
holder = holderObject,
})

Where this comes from

RELATED NEON APIS

Continue exploring

Read the system guide →