Sign in to follow this  
JeViCo

getAttachedElements loop problem

Recommended Posts

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\\\

Share this post


Link to post

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

Share this post


Link to post
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:

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.