Jump to content

Remove and Objet with CommandHandler


Elmatus

Recommended Posts

The final code was this:

function createTheGate () 
   myGate = createObject ( 18483, -783.20001220703, 2597.1999511719, 104.09999847412, 0, 0, 83.984985351563 )  
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate () 
   moveObject ( myGate, 500, -781.20001220703, 2624.8000488281, 104.09999847412, 0, 0, 0 )        
   myEffect = createObject ( 2780, -783.90002441406, 2660.5, 104.09999847412, 0, 0, 0 ) 
   setTimer ( function() destroyElement (myEffect) end, 3000, 0 ); 
end 
addCommandHandler("opengate",openMyGate)   
  
function movingMyGateBack () 
   moveObject ( myGate, 500, -783.20001220703, 2597.1999511719, 104.09999847412, 0, 0, 0 )   
end 
addCommandHandler("closegate",movingMyGateBack)  

The door opens,the somoke appears, the smoke disappears, BUT, in the consolo say this repeatedly:

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

help me please D:

Link to comment

It doesnt help me that links D:

I need to solve this in console:

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

WARNIG: beta\testsmoke.lua:9: Bad Argument @ 'destroyElement' [Expected element at argument 1]

I dont know why appears, the scrip works perfect, bug that appears in console many times

Link to comment
[Expected element at argument 1]

Try:

function createTheGate () 
   myGate = createObject ( 18483, -783.20001220703, 2597.1999511719, 104.09999847412, 0, 0, 83.984985351563 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
function openMyGate () 
   moveObject ( myGate, 500, -781.20001220703, 2624.8000488281, 104.09999847412, 0, 0, 0 )       
   myEffect = createObject ( 2780, -783.90002441406, 2660.5, 104.09999847412, 0, 0, 0 ) 
   setTimer ( function() end, 3000, 0 )  
   destroyElement (myEffect) 
end 
addCommandHandler("opengate",openMyGate)   
  
function movingMyGateBack () 
   moveObject ( myGate, 500, -783.20001220703, 2597.1999511719, 104.09999847412, 0, 0, 0 )   
end 
addCommandHandler("closegate",movingMyGateBack) 

You're missing an argument at line 7, check it out.

Link to comment
local originalX = -783.20001220703 
local originalY = 2597.1999511719 
local originalZ = 104.09999847412 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        myGate = createObject(18483, originalX, originalY, originalZ, 0, 0, 83.984985351563) 
    end 
) 
  
addCommandHandler("opengate", 
    function () 
        moveObject(myGate, 500, -781.20001220703, 2624.8000488281, 104.09999847412, 0, 0, 0)       
        myEffect = createObject(2780, -783.90002441406, 2660.5, 104.09999847412, 0, 0, 0) 
        setTimer(destroyElement, 3000, 1, myEffect) 
    end 
) 
  
addCommandHandler("closegate", 
    function() 
        moveObject(myGate, 500, originalX, originalY, originalZ, 0, 0, 0)   
    end 
) 

Edited by Guest
Link to comment

Why do you set a timer with infinite number of executes? This is the reason why you get them all messages, first time the object gets deleted and then each destroyElement call will fail because myEffect is not a valid object any more. Check the setTimer parameters again.

Link to comment
Why do you set a timer with infinite number of executes? This is the reason why you get them all messages, first time the object gets deleted and then each destroyElement call will fail because myEffect is not a valid object any more. Check the setTimer parameters again.

Right, didn't pay attention to that.

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