createRope
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
xfloatWorld X.
yfloatWorld Y.
zfloatWorld Z.
optionstableoptionalOptional 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.
holderelementoptionalPhysical element the rope hangs from. Required for every type except swat.
holderOffsettableoptionalLocal attachment offset on the holder, as {x, y, z}.
lengthfloatoptional · default 0Rope length. 0 or greater.
winchHeightfloatoptional · default 0.5Winch height.
fixedNodeintoptional · default 0Which node is pinned, 0 through 30. A rope holds at most 32 nodes.
durationintoptional · default 0Lifetime in milliseconds. 0 means the rope does not expire on its own.
sitOnGroundbooloptional · default falseWhether the rope rests on the ground.
physicsbooloptional · default trueWhether the native rope solver simulates it.
topVelocitytableoptionalVelocity applied at the rope top, as {x, y, z}.
carriedElementelementoptionalElement 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.
- 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,})