Rope::addRope: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Creates a rope at the specific position, that extends in the specified direction when not attached to any entities.<br>__<br><br>Add_Rope(pos.x,pos.y,pos.z,0.0,0.0,0.0,20.0,4,20.0,1.0,0.0,false,false,false,5.0,false,NULL)<br><br>When attached, Position&lt;vector&gt; does not matter<br>When attached, Angle&lt;vector&gt; does not matter<br><br>Rope Type:<br>4 and bellow is a thick rope<br>5 and up are small metal wires<br>0 crashes the game<br><br>Max_length - Rope is forced to this length, generally best to keep this the same as your rope length.<br><br>Rigid - If max length is zero, and this is set to false the rope will become rigid (it will force a specific distance, what ever length is, between the objects).<br><br>breakable - Whether or not shooting the rope will break it.<br><br>unkPtr - unknown ptr, always 0 in orig scripts<br>__<br><br>Lengths can be calculated like so:<br><br>float distance = abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2); // Rope length<br><br><br>NOTES:<br><br>Rope does NOT interact with anything you attach it to, in some cases it make interact with the world AFTER it breaks (seems to occur if you set the type to -1).<br><br>Rope will sometimes contract and fall to the ground like you'd expect it to, but since it doesn't interact with the world the effect is just jaring.
__NOTOC__
{{ClientsideJsFunction}}
Creates a rope at the specific position, that extends in the specified direction when not attached to any entities.
{{JSContainer|
 
=== Required Params ===
*'''x:''' {{RageType|Float}}
*'''y:''' {{RageType|Float}}
*'''z:''' {{RageType|Float}}
*'''rotX:''' {{RageType|Float}}
*'''rotY:''' {{RageType|Float}}
*'''rotZ:''' {{RageType|Float}}
*'''length:''' {{RageType|Number}}
*'''ropeType:''' {{RageType|Number}}
*'''initialLength:''' {{RageType|Number}}
*'''minLength:''' {{RageType|Number}}
*'''changeRate:''' {{RageType|Float}}
*'''populOnly:''' {{RageType|Boolean}}
*'''collision:''' {{RageType|Boolean}}
*'''lockfront:''' {{RageType|Boolean}}
*'''timeMultiplier:''' {{RageType|Float}}
*'''breakable:''' {{RageType|Boolean}}
*'''materialName:''' {{RageType|String}} or {{RageType|Null}}
 
=== Return Value ===
*'''{unkPtr, result}''' {{RageType|{number, handle}}}
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.rope.addRope(x, y, z, rotX, rotY, rotZ, length, ropeType, maxLength, minLength, p10, p11, p12, rigid, p14, breakWhenShot, unkPtr);</syntaxhighlight>
<pre>
=== Required Arguments ===
mp.game.physics.addRope(x, y, z, rotX, rotY, rotZ, length, ropeType, initialLen, minLen, changeRate, populOnly, collision, lockFront, timeMultiplier, breakWhenShot, materialName);
*'''x:''' float
</pre>
*'''y:''' float
*'''z:''' float
*'''rotX:''' float
*'''rotY:''' float
*'''rotZ:''' float
*'''length:''' float
*'''ropeType:''' int
*'''maxLength:''' float
*'''minLength:''' float
*'''p10:''' float (0.5 makes the rope twist when you fold it and there's excess (more realistic))
*'''p11:''' Boolean
*'''p12:''' Boolean
*'''rigid:''' Boolean
*'''p14:''' float
*'''breakWhenShot:''' Boolean
*'''unkPtr:''' unknown (to be checked)
 
===Return value===
*'''Object:''' unkPtr, result (rope handle)


==Example==
==Example==
{{ClientsideCode|
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
const {x, y, z} = mp.players.local.position;
const forwardPos = mp.players.local.getForwardVector();
const {result} = mp.game.physics.addRope(x, y, z, forwardPos.x, forwardPos.y, forwardPos.z, 50.0, 1, 50.0, 50.0, 1.2, false, true, true, 10.0, true, null);
mp.console.logInfo(`Rope created! Handle: ${result}`);
 
</syntaxhighlight>
</syntaxhighlight>
}}
}}
==See also==
==See also==
{{Rope_s_function_c}}
{{Rope_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 10:54, 12 May 2024

Client-Side
Function

 JavaScript



Creates a rope at the specific position, that extends in the specified direction when not attached to any entities.

JavaScript Syntax


Required Params

  • x: Float
  • y: Float
  • z: Float
  • rotX: Float
  • rotY: Float
  • rotZ: Float
  • length: Number
  • ropeType: Number
  • initialLength: Number
  • minLength: Number
  • changeRate: Float
  • populOnly: Boolean
  • collision: Boolean
  • lockfront: Boolean
  • timeMultiplier: Float
  • breakable: Boolean
  • materialName: String or Null

Return Value

  • {unkPtr, result} {number, handle}

Syntax

mp.game.physics.addRope(x, y, z, rotX, rotY, rotZ, length, ropeType, initialLen, minLen, changeRate, populOnly, collision, lockFront, timeMultiplier, breakWhenShot, materialName);

Example

Client-Side
const {x, y, z} = mp.players.local.position;
const forwardPos = mp.players.local.getForwardVector();
const {result} = mp.game.physics.addRope(x, y, z, forwardPos.x, forwardPos.y, forwardPos.z, 50.0, 1, 50.0, 50.0, 1.2, false, true, true, 10.0, true, null);
mp.console.logInfo(`Rope created! Handle: ${result}`);


See also