Jump to content

setTimer - how does it work?


Galton

Recommended Posts

Posted

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) 

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

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

thanks for the answer. it's shorter than mine and it works. your example is a much better way to do it.

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

  • Moderators
Posted

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.

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