Jump to content

Problem with 'setTimer'


FSXTim

Recommended Posts

Error (line 13): Bad argument @ 'setElementData' [expected element at argument one, got nil]

function spam(message) 
    local player = source 
    local msg = getElementData(source, "Spam") 
    if message == msg then 
        outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
        cancelEvent() 
    end 
    if isTimer(spamTimer) then 
        killTimer(spamTimer)  
    end 
    spamTimer = setTimer( 
        function() 
            setElementData(source, "Spam", "0") 
        end  
    , 10000, 1, source) 
    setElementData(source, "Spam", message)      
end 
addEventHandler("onPlayerChat", getRootElement(), spam) 

Greets

Link to comment
function spam(message) 
    local msg = getElementData(source, "Spam") 
    if message == msg then 
        outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
        cancelEvent() 
    end 
    if isTimer(spamTimer) then 
        killTimer(spamTimer) 
    end 
    spamTimer = setTimer( 
        function(source) 
            setElementData(source, "Spam", "0") 
        end  
    , 10000, 1, source) 
    setElementData(source, "Spam", message)     
end 
addEventHandler("onPlayerChat", getRootElement(), spam) 

Link to comment
function spam(message) 
    local msg = getElementData(source, "Spam") 
    if message == msg then 
        outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
        cancelEvent() 
    end 
    if isTimer(spamTimer) then 
        killTimer(spamTimer) 
    end 
    spamTimer = setTimer( 
        function(source) 
            setElementData(source, "Spam", "0") 
        end  
    , 10000, 1, source) 
    setElementData(source, "Spam", message)     
end 
addEventHandler("onPlayerChat", getRootElement(), spam) 

function spam(message) 
    local msg = getElementData(source, "Spam") or setElementData(source, "Spam", "0") 
    if message == msg then 
        outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
        cancelEvent() 
    end 
    if isTimer(spamTimer) then 
        killTimer(spamTimer) 
    end 
    spamTimer = setTimer( 
        function(source) 
            setElementData(source, "Spam", "0") 
        end  
    , 10000, 1, source) 
    setElementData(source, "Spam", message)     
end 
addEventHandler("onPlayerChat", getRootElement(), spam) 

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