Jump to content

getAttachedElements loop problem


JeViCo

Recommended Posts

Posted

Hello everyone! My code doesn't work for unknown reason:

addCommandHandler("ivi",function()
	det = getAttachedElements(getPedOccupiedVehicle(localPlayer))
	for u , num in ipairs(det) do
		outputDebugString(tostring(num))
	end
end)

Any ideas? Maybe i'm doing something wrong\\\

Posted

Your code works.Are you sure that you have attached elements to vehicle?

addCommandHandler("ivi",function()
	det = getAttachedElements(getPedOccupiedVehicle(localPlayer))
	if #det > 0 then
		for k,v in ipairs(det) do
			outputDebugString(tostring(v))
		end
	else
		outputChatBox("no elements were attached")
	end
end)

or

addCommandHandler("ivi",function()
	det = getAttachedElements(getPedOccupiedVehicle(localPlayer))
	iprint(det)
end)

 

  • Thanks 1
Posted
1 hour ago, IRBIS said:

Your code works.Are you sure that you have attached elements to vehicle?


addCommandHandler("ivi",function()
	det = getAttachedElements(getPedOccupiedVehicle(localPlayer))
	if #det > 0 then
		for k,v in ipairs(det) do
			outputDebugString(tostring(v))
		end
	else
		outputChatBox("no elements were attached")
	end
end)

or


addCommandHandler("ivi",function()
	det = getAttachedElements(getPedOccupiedVehicle(localPlayer))
	iprint(det)
end)

 

i forgot that i used setElementParent instead. I added attachElements and it works now. Thank you!

but now it is not attaches properly\ soo how can i use only setElementParent to detect objects? getElementParent can return only a vehicle - not a vehicle attached part :sad:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...