isa_Khamdan Posted October 5, 2013 Share Posted October 5, 2013 The output doesn't work and I do not know what is the reason ( I want it to be visible for the player who triggered the function only ) function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z >= 90) and (z <= 270) then outputChatBox ( "* Destroyed", element, 255, 0, 0, true ) destroyElement( element ) end end end Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 element is vehicle as you have just checked it at line 3. You can't output to vehicle . outputChatBox ( "* Destroyed", element, 255, 0, 0, true ) If you have used the right event, i guess you should use source. outputChatBox ( "* Destroyed", source, 255, 0, 0, true ) Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 element is vehicle as you have just checked it at line 3. You can't output to vehicle . outputChatBox ( "* Destroyed", element, 255, 0, 0, true ) If you have used the right event, i guess you should use source. outputChatBox ( "* Destroyed", source, 255, 0, 0, true ) function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z >= 90) and (z <= 270) then outputChatBox ( "* Destroyed", source, 255, 0, 0, true ) destroyElement( element ) end end end function DSC( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) then if ( isElementWithinColShape( element, LineLS ) ) then DestroyT [ element ] = setTimer ( Destroy , 10000, 0, element ) LST [ element ] = setTimer ( DestroyLS , 5000, 0, element ) end end if ( isElement(element) and getElementType (element) == "vehicle" ) then if ( isElementWithinColShape( element, LineRS ) ) then DestroyT [ element ] = setTimer ( Destroy , 10000, 0, element ) RST [ element ] = setTimer ( DestroyRS , 5000, 0, element ) end end end Can you tell me how can I fix it? Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 https://forum.multitheftauto.com/viewtopic.php?f=91&t=65917 You have infinite repetitions timer that why it was give you bad argument, when you destroy the vehicle you should destroy the timer and remove it from the table too. The output doesn't work? I am not sure if source is who triggered the function DSC, can you show how function DSC is called? I guess you will need to pass the source from DSC function to the timer. Also the IF statement in function DSC is unnecessary you can use elseif. Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 https://forum.multitheftauto.com/viewtopic.php?f=91&t=65917You have infinite repetitions timer that why it was give you bad argument, when you destroy the vehicle you should destroy the timer and remove it from the table too. The output doesn't work? I am not sure if source is who triggered the function DSC, can you show how function DSC is called? I guess you will need to pass the source from DSC function to the timer. Also the IF statement in function DSC is unnecessary you can use elseif. Hmm what about this function? It dose destroy the vehicle but killTimer doesn't work function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z > 90) and (z < 270) then Check [ element ] = setTimer ( destroyElement , 4000, 1, element ) if isElementWithinColShape ( element, LineRS ) and not (z > 90) and not (z < 270) and isTimer ( Check [ element ] ) then killTimer ( Check [ element ] ) outputChatBox ( "* Check", root, 255, 0, 0, true ) end end end end Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 https://forum.multitheftauto.com/viewtopic.php?f=91&t=65917You have infinite repetitions timer that why it was give you bad argument, when you destroy the vehicle you should destroy the timer and remove it from the table too. The output doesn't work? I am not sure if source is who triggered the function DSC, can you show how function DSC is called? I guess you will need to pass the source from DSC function to the timer. Also the IF statement in function DSC is unnecessary you can use elseif. Hmm what about this function? It dose destroy the vehicle but killTimer doesn't work function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z > 90) and (z < 270) then Check [ element ] = setTimer ( destroyElement , 4000, 1, element ) if isElementWithinColShape ( element, LineRS ) and not (z > 90) and not (z < 270) and isTimer ( Check [ element ] ) then killTimer ( Check [ element ] ) outputChatBox ( "* Check", root, 255, 0, 0, true ) end end end end This Function will be triggered every 1 second to check for the rotation and destroy but I want it that if the rotation changed while the timer is running then it will be destroyed. I have another function like with different rotation and it's working fine but this doesn't work well and I do not know what is the reason Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z > 90) and (z < 270) and not isTimer(Check [ element ]) then Check [ element ] = setTimer (function(element) destroyElement(element) Check [ element ] = nil end, 4000, 1, element) killTimer ( RST [ element ] ) RST [ element ] = nil outputChatBox ( "* Check", root, 255, 0, 0, true ) end end end Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 function DestroyRS( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then local x,y,z = getElementRotation ( element ) if isElementWithinColShape ( element, LineRS ) and (z > 90) and (z < 270) and not isTimer(Check [ element ]) then Check [ element ] = setTimer (function(element) destroyElement(element) Check [ element ] = nil end, 4000, 1, element) killTimer ( RST [ element ] ) RST [ element ] = nil outputChatBox ( "* Check", root, 255, 0, 0, true ) end end end That's won't help I just want to fix my code Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 I start to get confused, currently what is doesn't work? I still don't know what you trying to do, you not showing enough code, there a lot of functions why do you need this much of functions and tables. Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 I start to get confused, currently what is doesn't work?I still don't know what you trying to do, you not showing enough code, there a lot of functions why do you need this much of functions and tables. It doesn't kill timer if the rotation changed while the timer is running. Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 Which timer? if isElementWithinColShape ( element, LineRS ) and not (z > 90) and not (z < 270) and isTimer ( Check [ element ] ) then killTimer ( Check [ element ] ) outputChatBox ( "* Check", root, 255, 0, 0, true ) Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 Nvm i got what you mean, try this: function DestroyRS(element) if (isElement(element) and getElementType (element) == "vehicle") and not (getElementModel(element) == 431) then local x, y, z = getElementRotation(element) if isElementWithinColShape(element, LineRS) then if (z > 90) and (z < 270) then if not isTimer(Check[element]) then Check[element] = setTimer(function(element) destroyElement(element) Check[element] = nil end, 4000, 1, element) end else if isTimer(Check[element]) then killTimer(Check[element]) Check[element] = nil outputChatBox("* Check", root, 255, 0, 0, true) end end end end end Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 Nvm i got what you mean, try this: function DestroyRS(element) if (isElement(element) and getElementType (element) == "vehicle") and not (getElementModel(element) == 431) then local x, y, z = getElementRotation(element) if isElementWithinColShape(element, LineRS) then if (z > 90) and (z < 270) then if not isTimer(Check[element]) then Check[element] = setTimer(function(element) destroyElement(element) Check[element] = nil end, 4000, 1, element) end else if isTimer(Check[element]) then killTimer(Check[element]) Check[element] = nil outputChatBox("* Check", root, 255, 0, 0, true) end end end end end Thanks it's working now but what about the outputchatbox? I want it for the player who triggered the function only Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 Thanks it's working now but what about the outputchatbox? I want it for the player who triggered the function only I need to know how this function is called. function DSC( element ) Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 Thanks it's working now but what about the outputchatbox? I want it for the player who triggered the function only I need to know how this function is called. function DSC( element ) it start on colshapehit function DSC( element ) if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then if isElementWithinColShape ( element, LineLS ) then timers [ element ] = setTimer ( Destroy , 6500, 0, element ) timers [ element ] = setTimer ( DestroyLS , 500, 0, element ) end end if ( isElement(element) and getElementType (element) == "vehicle" ) and not ( getElementModel ( element ) == 431 ) then if isElementWithinColShape ( element, LineRS ) then timers [ element ] = setTimer ( Destroy , 6500, 0, element ) timers [ element ] = setTimer ( DestroyRS , 500, 0, element ) end end end addEventHandler ( "onColShapeHit", resourceRoot, DSC ) Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 You need to get who is drive the vehicle. local player = getVehicleController(element) function DestroyRS(element) if (isElement(element) and getElementType (element) == "vehicle") and not (getElementModel(element) == 431) then local x, y, z = getElementRotation(element) local player = getVehicleController(element) if isElementWithinColShape(element, LineRS) then if (z > 90) and (z < 270) then if not isTimer(Check[element]) then Check[element] = setTimer(function(element) destroyElement(element) Check[element] = nil end, 4000, 1, element) end else if isTimer(Check[element]) then killTimer(Check[element]) Check[element] = nil if player then outputChatBox("* Check", player, 255, 0, 0, true) end end end end end end Link to comment
isa_Khamdan Posted October 5, 2013 Author Share Posted October 5, 2013 You need to get who is drive the vehicle. local player = getVehicleController(element) function DestroyRS(element) if (isElement(element) and getElementType (element) == "vehicle") and not (getElementModel(element) == 431) then local x, y, z = getElementRotation(element) local player = getVehicleController(element) if isElementWithinColShape(element, LineRS) then if (z > 90) and (z < 270) then if not isTimer(Check[element]) then Check[element] = setTimer(function(element) destroyElement(element) Check[element] = nil end, 4000, 1, element) end else if isTimer(Check[element]) then killTimer(Check[element]) Check[element] = nil if player then outputChatBox("* Check", player, 255, 0, 0, true) end end end end end end How can I make it output the message when the timer finish and the vehicle is destroyed? Link to comment
TAPL Posted October 5, 2013 Share Posted October 5, 2013 function DestroyRS(element) if (isElement(element) and getElementType (element) == "vehicle") and not (getElementModel(element) == 431) then local x, y, z = getElementRotation(element) local player = getVehicleController(element) if isElementWithinColShape(element, LineRS) then if (z > 90) and (z < 270) then if not isTimer(Check[element]) then Check[element] = setTimer(function(element, player) if player then outputChatBox("..................", player, 255, 0, 0, true) end destroyElement(element) Check[element] = nil end, 4000, 1, element, player) end else if isTimer(Check[element]) then killTimer(Check[element]) Check[element] = nil if player then outputChatBox("* Check", player, 255, 0, 0, true) end end end end end end 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