Raised This Month: $275 Target: $400
 68% 

[Any] Delay Command (testing appreciated!)


Post New Thread Reply   
 
Thread Tools Display Modes
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-19-2018 , 03:17   Re: [Any] Delay Command (testing appreciated!)
Reply With Quote #11

Quote:
Originally Posted by Mitchell View Post
then why are you using CloseHandle() (old syntax) instead of delete and also I think you need to use KillTimer() not just close the handle.
https://sm.alliedmods.net/new-api/timers/KillTimer
It also has an auto close for the data handle, just briefly looking it may close those datapacks you're also not closing but storing in the ArrayList (this is just how it appears, i'm not familiar with looping through the indices of an ArrayList).
delete is just CloseHandle() with the added bonus of setting the passed variable to null by-reference. In this case, delete is incorrect, because you're totally right: I'm leaking DataPacks by not instead using KillTimer(hTimer, true) in OnClientDisconnect(). This still doesn't explain the error log, though.
__________________

Last edited by ddhoward; 07-19-2018 at 03:40.
ddhoward is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 07-19-2018 , 10:20   Re: [Any] Delay Command (testing appreciated!)
Reply With Quote #12

Quote:
Originally Posted by ddhoward View Post
delete is just CloseHandle() with the added bonus of setting the passed variable to null by-reference. In this case, delete is incorrect, because you're totally right: I'm leaking DataPacks by not instead using KillTimer(hTimer, true) in OnClientDisconnect(). This still doesn't explain the error log, though.
iirc Closing the handle does not stop a timer, so it will execute sooner or later. I may be wrong on this though.
__________________

Last edited by Mitchell; 07-19-2018 at 10:23.
Mitchell is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-19-2018 , 22:37   Re: [Any] Delay Command (testing appreciated!)
Reply With Quote #13

Closing the Timer's Handle stops the timer. The only difference between KillTimer() and CloseHandle() is that KillTimer() has that second argument which, when set to true, also runs the timer's data through CloseHandle().

And actually, turns out Sourcemod is smart enough to close the Datapack's Handle automatically if the DataTimer's handle is closed prematurely; the timer firing isn't required for Sourcemod to auto-close the DataPack. So I'm not leaking datapack handles lol. delete, KillTimer(), and CloseHandle() are all equally valid here. In most of my functions, CloseHandle is the most efficient.
__________________

Last edited by ddhoward; 07-19-2018 at 23:29.
ddhoward is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:59.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode