Jump to content

setTimer - how does it work?


Galton

Recommended Posts

edit: I can get it to work with addCommandHandler now. I still don't know how it works with events though. I'd greatly appreciate it if you could explain.

fixed code with addEventHandler:

function delayedKill (player) 
setTimer ( 
function () killPed(player) end, 
1500, 1)  
end 
  
addCommandHandler ("test1", delayedKill) 

Link to comment
function delayedKill (player) 
setTimer ( 
function () killPed(player) end, 
1500, 1) 
end 
addCommandHandler ("test1", delayedKill) 

function asd(Player, Command) 
setTimer(killPed,2000,1,Player) 
end 
addCommandHandler("test1",asd) 

Is the same practically.

Link to comment
  • Moderators

I recommend this:

function delayedKill (player,command) -- player = you, command = "test1" 
    setTimer (function ()  
        if isElement(player) then -- Players can leave during the timer, which will give you warning if this happens. 
            killPed(player)  
        end 
    end,1500, 1) 
end 
addCommandHandler ("test1", delayedKill) 

As scripter you don't want warnings during execute your code.

Warnings = lagg and fill up your server logs.

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