Constraint.rope Create between player and "prop"

I been trying to make a scripts that creates a rope between a player and a “prop” to allow him to drag the “prop”
But i haven’t got it to work so im asking for help here now.
This is how the “code” looks right now:

constraint.Rope( ply, ent, 0, 0, Local, Local, 0, 40, 0, 20, “cable/rope”, rigid )

don’t do this, it crashes your game
my kidnapper swep originally allowed players to drag bodies around with a rope but it had a 33% chance of crashing gmod when the rope was created

Fuuuuuck. what about a weld that will break if it has to much force?

[editline]8th November 2016[/editline]

And could i still get the rope config please?

First of all, the official wiki is in almost all cases better than the old one, and is also much more up to date:

constraint.Rope

That aside, try to do it anyway. Not that I don’t believe legendofrobbo, but you’ve got nothing to lose. If you’re having trouble post fuller code.

This is what i have now:
constraint.Weld(ent,ply,tr.PhysicsBone,0,0,true) (This works)
Would this work?
constraint.Rope(ply,ent,0,tr.PhysicsBone,ent,ent,10,10,0,5,“cable/rope”,true)

[editline]8th November 2016[/editline]

Just tried constraint.Rope(ply,ent,0,tr.PhysicsBone,ent,ent,10,10,0,5,“cable/rope”,true)
Got:

[ERROR] lua/includes/modules/constraint.lua:491: bad argument #1 to ‘LocalToWorld’ (Vector expected, got userdata)

  1. LocalToWorld - [C]:-1
  2. Rope - lua/includes/modules/constraint.lua:491
    3. v - lua/autorun/server/drag.lua:22
    4. unknown - lua/includes/modules/hook.lua:84

You’re putting the wrong arguments in the wrong place, see the link to the wiki in my post

tr.PhysicsBone
constraint.Rope(ply Ent1,ent Ent2,0 Bone1,tr.PhysicsBone Bone2,ply LPos1,ent LPos2,0 length,50 addlength,50 forcelimit,10 width,“cable/rope” material,true rigid ) Is this right or is this right:

constraint.Rope(ply,ent,0,tr.PhysicsBone,ply,ent,0,50,50,10,“cable/rope”,true)

New problem. I get this error:

[ERROR] lua/includes/modules/constraint.lua:282: attempt to index local ‘Ent’ (a boolean value)

  1. CanConstrain - lua/includes/modules/constraint.lua:282
  2. Rope - lua/includes/modules/constraint.lua:486
    3. v - lua/autorun/server/drag.lua:22
    4. unknown - lua/includes/modules/hook.lua:84

My rope code is now: constraint.Rope(ply:IsPlayer(),ent,0,tr.PhysicsBone,ply,ent,0 ,50,50,10,“cable/rope”,true)

[editline]9th November 2016[/editline]

and if i use: constraint.Rope(ply,ent,0,tr.PhysicsBone,ply,ent,0 ,50,50,10,“cable/rope”,true)
I get:
[ERROR] lua/includes/modules/constraint.lua:491: bad argument #1 to ‘LocalToWorld’ (Vector expected, got userdata)

  1. LocalToWorld - [C]:-1
  2. Rope - lua/includes/modules/constraint.lua:491
    3. v - lua/autorun/server/drag.lua:22
    4. unknown - lua/includes/modules/hook.lua:84

[editline]9th November 2016[/editline]

constraint.Rope(ply:IsPlayer(),ent,true,tr.PhysicsBone,ply:IsPlayer(),ent,0,50,50,10,“cable/rope”,true)
This dosn’t give any errors but it dosn’t create the rope.
:frowning:

[editline]9th November 2016[/editline]

constraint.Rope(ply,ent,true,tr.PhysicsBone,ply:IsPlayer(),ent,0,50,50,10,“cable/rope”,true) *

[editline]9th November 2016[/editline]

The code:

hook.Add( “KeyPress”, “keypress_use_ty”, function( ply, key )
if ( key == IN_WALK ) then
local tr = ply:GetEyeTrace() --Get an eye trace
local poss = ply:GetPos()
local ent = tr.Entity --Get the entity hit by the eye trace, if anything
local Distance = ply:GetPos():Distance( ent:GetPos() )
local Remove = constraint.HasConstraints(ply:GetEyeTrace().Entity)
if constraint.HasConstraints( ent ) then
if !( Distance < 100 ) then return end
if (ent:GetClass() == “prop_ragdoll”) then
constraint.RemoveConstraints( ply:GetEyeTrace().Entity, “Weld” )
ply:PrintMessage(4, “The ragdoll aint being draged anymore.”)
ply:SetWalkSpeed(160)
ply:SetRunSpeed(240)
return end
return end
if !( Distance < 100 ) then return end
if (ent:GetClass() == “prop_ragdoll”) then
ply:SetWalkSpeed(50)
ply:SetRunSpeed(50)
ply:PrintMessage(4, “The ragdoll is now being draged with a rope!”)
constraint.Rope(ply,ent,true,tr.PhysicsBone,ply:IsPlayer(),ent,0,50,50,10,“cable/rope”,true)
end
end
end )

hook.Add( “KeyPress”, “keypress_use_heil”, function( ply, key )
if ( key == IN_USE ) then
local tr = ply:GetEyeTrace() --Get an eye trace
local poss = ply:GetPos()
local ent = tr.Entity --Get the entity hit by the eye trace, if anything
local Distance = ply:GetPos():Distance( ent:GetPos() )
ply:SetWalkSpeed(160)
ply:SetRunSpeed(240)

if (ent:GetClass() == “prop_vehicle_jeep”) then
constraint.RemoveAll(ply)
print (“Wow, It worked! All welds to the players have been removed!”)
end
end
end )

[lua]
‘LocalToWorld’ (Vector expected, got userdata)
[/lua]

Its expecting a vector there. You define ent as the entity hit. However

[lua]
constraint.Rope( Entity Ent1, number Ent2, number Bone1, number Bone2, Vector LPos1, Vector LPos2, number length, number addlength, number forcelimit, number width, string material, boolean rigid )
[/lua]

It wants the vector not the actual entity itself. Hope this helps. Feel free to correct me as i am still learning myself and i can and will be wrong sometimes.

I have a big problem then? If i do ply:GetPos() dosn’t it just tell the game where im standing? Wouldn’t i need to find a command that does like add a sertain amount up on the vecor pos like ply:GetPos()+0,0,10.

Honestly. Just break the problem down. Attempt to use constraint.rope in another lua file down to the T on how its used. Once you understand that start adding what you really want to do in and things will start to make much more sense.

It would probably be easier for you to allow the player to pick up the prop by toggling E.

They can pick up props but im trying to allow them to drag prop_ragdolls.

[editline]10th November 2016[/editline]

will use this instead. https://wiki.garrysmod.com/page/Player/PickupObject
Thank guys for the help! :slight_smile:
<3