Jump to content

Help: setTimer Problem?


Hadif

Recommended Posts

Script:

function theLocator() 
    local allLocation = {"Las Venturas",  
    "San Fierro",  
    "Whetstone",  
    "Flint County",  
    "Red County",  
    "Los Santos"} 
    local theLocation = getElementZoneName(source, true) 
    for theKey, allLocation in pairs(allLocation) do 
        if (theLocation == allLocation) then 
            killPed(source) 
        end 
    end 
end 
  
function checkLocation() 
    setTimer(theLocator(source), 0, 0) 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), checkLocation) 

Result:

Bad argument @ 'setTimer' [Expected function at argument 1, got nil] 

Link to comment
setTimer ( 
    function () 
        theLocator () 
    end, 0, 0 
) 
  

You don't need to add a function statement for function inside a timer and also you don't need to add even parenthesis of a function inside a timer. If the function has arguments then you can declare them later.

@

You are assigning an argument to an argumentless function.

  
function checkLocation() 
    setTimer(theLocator(source), 0, 0) -- There are no arguments in theLocator 
end 
  

This should probably work:

  
setTimer(theLocator, 0, 0) 
  

Link to comment
setTimer ( 
    function () 
        theLocator () 
    end, 0, 0 
) 
  

You don't need to add a function statement for function inside a timer and also you don't need to add even parenthesis of a function inside a timer. If the function has arguments then you can declare them later.

@

You are assigning an argument to an argumentless function.

  
function checkLocation() 
    setTimer(theLocator(source), 0, 0) -- There are no arguments in theLocator 
end 
  

This should probably work:

  
setTimer(theLocator, 0, 0) 
  

Thanks! :D

Link to comment
setTimer ( 
    function () 
        theLocator () 
    end, 0, 0 
) 
  

You don't need to add a function statement for function inside a timer and also you don't need to add even parenthesis of a function inside a timer. If the function has arguments then you can declare them later.

@

You are assigning an argument to an argumentless function.

  
function checkLocation() 
    setTimer(theLocator(source), 0, 0) -- There are no arguments in theLocator 
end 
  

This should probably work:

  
setTimer(theLocator, 0, 0) 
  

]STILL NOT WORKING![/color] :(

Link to comment

Oh my god. Stop making new topics about the same problem!

  
local allLocation = {"Las Venturas", 
    "San Fierro", 
    "Whetstone", 
    "Flint County", 
    "Red County", 
    "Los Santos"} 
  
function theLocator() 
    for i, v in ipairs(getElementsByType"player") do 
        local theLocation = getElementZoneName(v, true) 
        for theKey, allLocation in pairs(allLocation) do 
            if (theLocation == theKey) then 
                killPed(v) 
            end 
        end 
    end 
end 
setTimer(theLocator, 50, 0) 

Link to comment
Oh my god. Stop making new topics about the same problem!
  
local allLocation = {"Las Venturas", 
    "San Fierro", 
    "Whetstone", 
    "Flint County", 
    "Red County", 
    "Los Santos"} 
  
function theLocator() 
    for i, v in ipairs(getElementsByType"player") do 
        local theLocation = getElementZoneName(v, true) 
        for theKey, allLocation in pairs(allLocation) do 
            if (theLocation == theKey) then 
                killPed(v) 
            end 
        end 
    end 
end 
setTimer(theLocator, 50, 0) 

Ok sir, no more! Coz I already hv the solution. :D:D:D

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