-- server side:
local objectsSpawned = { }
function createWorldObject ( thePlayer, objectID, objectPosX, objectPosY, objectPosZ, objectRotX, objectRotY, objectRotZ )
obj = createObject ( objectID, objectPosX, objectPosY, objectPosZ, objectRotX, objectRotY, objectRotZ )
setElementDoubleSided ( obj, true )
if ( not objectsSpawned [ client ] ) then
objectsSpawned [ client ] = { }
end
objectsSpawned [ client ] [ obj ] = true
end
addEvent ( "spawnConstruction", true )
addEventHandler ( "spawnConstruction", root, createWorldObject )
addEvent ( 'onDestroyElement', true )
addEventHandler ( 'onDestroyElement', root,
function ( obj )
if ( objectsSpawned [ client ] ) then
if ( objectsSpawned [ client ] [ obj ] ) then
destroyElement ( obj )
objectsSpawned [ client ] [ obj ] = nil
end
end
end
)
-- client side:
function clickObject ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )
if ( clickedElement and isElement ( clickedElement ) and getElementType ( clickedElement ) == "object" ) then
guiSetVisible ( mainGUI, true )
removeEventHandler ( "onClientClick", root, clickObject )
triggerServerEvent ( 'onDestroyElement', localPlayer, clickedElement )
end
end