Elmatus Posted October 17, 2012 Share Posted October 17, 2012 Help, i created a scrit that when i write /hi the door opens and a smoke object appears, but i want tha when 5 seconds are passed, the smoke objet disappears, i have understand that is: removeObjet = ( myGate ) But it doesnt work, Please help Link to comment
myonlake Posted October 17, 2012 Share Posted October 17, 2012 setTimer destroyElement Link to comment
Elmatus Posted October 17, 2012 Author Share Posted October 17, 2012 Ob thanks .. It should be right this: setTimer ( 3000 ) destroyElement = ( myEffect ) end addCommandHandler ("effectoff") ???? Link to comment
TwiX! Posted October 17, 2012 Share Posted October 17, 2012 function rObject() setTimer( function() destroyElement(myEffect) end, 3000, 0 ); end addCommandHandler("effectoff",rObject); Link to comment
myonlake Posted October 17, 2012 Share Posted October 17, 2012 Or then just do this. addCommandHandler("effectoff", function(player, cmd) setTimer(destroyElement, 3000, 0, myeffect) end ) Doesn't really matter how. Link to comment
Elmatus Posted October 17, 2012 Author Share Posted October 17, 2012 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
Mossy Posted October 17, 2012 Share Posted October 17, 2012 Look on the wiki for any mistakes. https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/DestroyElement Link to comment
Elmatus Posted October 17, 2012 Author Share Posted October 17, 2012 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
Mossy Posted October 17, 2012 Share Posted October 17, 2012 [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
Elmatus Posted October 18, 2012 Author Share Posted October 18, 2012 I dont see the diference in you line 7 and my line 7 I tryed your script and its de same Link to comment
myonlake Posted October 18, 2012 Share Posted October 18, 2012 (edited) 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 October 18, 2012 by Guest Link to comment
50p Posted October 18, 2012 Share Posted October 18, 2012 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
myonlake Posted October 18, 2012 Share Posted October 18, 2012 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
Elmatus Posted October 18, 2012 Author Share Posted October 18, 2012 Thanks 50p it works Thanks to: -50p -myonlake -Twix Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now