Jump to content

Help: setTimer Problem?


Hadif

Recommended Posts

Posted

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] 

My ingame nickname is Vaulthuntr.

Host a server?

CSGO_468x60.png

Join a server?

430x73_FFFFFF_FF9900_000000_000000.png

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

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted
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

My ingame nickname is Vaulthuntr.

Host a server?

CSGO_468x60.png

Join a server?

430x73_FFFFFF_FF9900_000000_000000.png

Posted
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] :(

My ingame nickname is Vaulthuntr.

Host a server?

CSGO_468x60.png

Join a server?

430x73_FFFFFF_FF9900_000000_000000.png

Posted
The problem isn't at timer then, can you post all the script you have and show us what debugscript says?

I think the problem is at the element(player) :/

...but I still didnt find the answer

My ingame nickname is Vaulthuntr.

Host a server?

CSGO_468x60.png

Join a server?

430x73_FFFFFF_FF9900_000000_000000.png

Posted

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) 

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
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

My ingame nickname is Vaulthuntr.

Host a server?

CSGO_468x60.png

Join a server?

430x73_FFFFFF_FF9900_000000_000000.png

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