Galton Posted May 21, 2015 Posted May 21, 2015 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)
Guest Posted May 21, 2015 Posted May 21, 2015 function asd(Player, Command) setTimer(killPed,2000,1,Player) end addCommandHandler("test1",asd)
Galton Posted May 21, 2015 Author Posted May 21, 2015 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.
Enargy, Posted May 21, 2015 Posted May 21, 2015 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 IIYAMA Posted May 21, 2015 Moderators Posted May 21, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now