• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Is there a problem with this code?

Status
Not open for further replies.
Level 3
Joined
Aug 6, 2019
Messages
74
Look at this code,There are 100 leaks, right?
code.png
 
First I noticed that it's the same timer being started i times; I thought it was multiple different timers. The way you've written it the timer will ultimately only be started for 100s once and only expire that one time.
If I destroyed it,Whether there is still a callback or event leak?
I'm not really sure I understand what you're saying. The object itself needs to be destroyed, either in the callback or some other function that runs after the callback.
 
Pyrogasm is correct. This loop is useless by its current state, you destroy the timer in the callback (or in a function in callback), doing it outside would just prevent it from doing anything in the callback.
Lua:
TimerStart(t, i, false, function()
--do stuff
call DestroyTimer(t)
set t = nil --not sure if you actually need to null local variables in lua
end)
 
Status
Not open for further replies.
Back
Top