Jump to content

DetachElement from Player


redditing

Recommended Posts

function building(source, command, detached)
	xP, yP, zP = getElementPosition(source)
	
	local build = createObject(3374, xP, yP, zP)
	
	attachElements(build, source, 0, 3, 1)
	
	setElementAlpha(build, 150)
	
	if detached=="detach" then
		setElementAlpha(build, 255)
		if isElement(build) then
			detachElement(build)
		end
	end
end

addCommandHandler("setBuild", building)

When I type the command, a block of hay appears in front of me, but when I type the command with "detach" then I get an error. Can anything be done about it? 

Link to comment
build = {}
function building(player, command)
if command == "setBuild" then
if isElement(build[player]) then destroyElement(build[player]) end 
xP, yP, zP = getElementPosition(player)
build[player] = createObject(3374, xP, yP, zP)
attachElements(build[player],player, 0, 3, 1)
setElementAlpha(build[player], 150)
elseif command == "detach" and isElement(build[player])  then
detachElements(build[player] )
end
end
addCommandHandler("setBuild", building)
addCommandHandler("detach",building)

try

Link to comment

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