Jump to content

OutputChatBox problem


isa_Khamdan

Recommended Posts

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

element is vehicle as you have just checked it at line 3. You can't output to vehicle :mrgreen:.

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
element is vehicle as you have just checked it at line 3. You can't output to vehicle :mrgreen:.
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

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

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

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 :S

Link to comment
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
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 :S

Link to comment

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
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 :D

but what about the outputchatbox?

I want it for the player who triggered the function only

Link to comment
Thanks it's working now :D

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

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

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