Hi, i got a weird error that i can't make sense out. this is what it sends me:
Entity [0][phys_constraint]
and this is the code.
[LUA]function spawntowtruck( ply, key, activator, caller, CMoveData, hooktows )
towtruck = ents.Create("prop_vehicle_jeep")
towtruck:SetModel("models/statetrooper/ram_tow.mdl")
towtruck:SetKeyValue("vehiclescript","scripts/vehicles/statetrooper/ram3500_tow.txt" )
towtruck:Spawn()
towtruck:SetPos(Vector(96.216995, 811.046936, -83.379456))
ninety_eight = ents.GetByIndex(towtruck:EntIndex())
print (ninety_eight)
local buttonfortow = ents.Create( "entity_tow" )
buttonfortow:SetPos(towtruck:GetPos()+Vector(50,-55,45))
buttonfortow:SetAngles(towtruck:GetAngles()+Angle(90,0,0))
buttonfortow:Spawn()
constraint.Weld(buttonfortow,towtruck,0,0,0,0,true)
print ("towtruckbutton1spawned")
hook.Add( "PlayerUse", "some_unique_nameforyou", function( ply, ent, spawntowtruck )
if (ent:GetClass() == "entity_tow") 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 ninety_six = ents.GetByIndex(ent:EntIndex())
local Distance = ( constraint.GetAllConstrainedEntities( ninety_six ) )
print (ninety_six)
print ("ok")
print (constraint.FindConstraintEntity(ninety_six,"Weld"))
end
end )
end
function spawntowtr()
spawntowtruck()
end
[/LUA]
[editline]21st November 2016[/editline]
And the spawn message:
Vehicle [204][prop_vehicle_jeep]
towtruckbutton1spawned
Entity [216][entity_tow]
ok
Entity [0][phys_constraint]
Entity [216][entity_tow]
What exactly is "Weird"? What is the problem? Where's the error?
It should find the second entity but it doesn't give the others entity id.
I don't know if it is because i'm failing to understand the code or if there is another problem not caused because of the code.
Sorry, you need to Log In to post a reply to this thread.