Raised This Month: $81 Target: $400
 20% 

Solved KillTimer vs. delete timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-31-2017 , 05:28   KillTimer vs. delete timer
Reply With Quote #1

Hey guys, could someone please examine the following code for me? I want to know which one is better or if there's anything wrong with either one of them.

PHP Code:
    if (hPunishTimer != null)
    {
        
KillTimer(hPunishTimer);
        
hPunishTimer null;
    } 
vs.

PHP Code:
    if (hPunishTimer != null)
    {
        
delete hPunishTimer;
        
hPunishTimer null;
    } 
I read somewhere (can't remember where since it was awhile back) that the if (hPunishTimer != null) isn't necessary for delete timer but I want to make sure.

I tried using just delete hPunishTimer; alone but I'm not sure if I'm doing it wrong or if it'll return errors at some point.
__________________

Last edited by Psyk0tik; 12-31-2017 at 06:47. Reason: Marked as [Solved]
Psyk0tik is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 12-31-2017 , 06:33   Re: KillTimer vs. delete timer
Reply With Quote #2

PHP Code:
delete timer
is fine. Null checks before are unnecessary
headline is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-31-2017 , 06:47   Re: KillTimer vs. delete timer
Reply With Quote #3

Quote:
Originally Posted by Headline View Post
PHP Code:
delete timer
is fine. Null checks before are unnecessary
I see. Thanks!
__________________
Psyk0tik is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 12-31-2017 , 14:32   Re: KillTimer vs. delete timer
Reply With Quote #4

delete also sets it to null, so no need to do that either
hmmmmm is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-31-2017 , 16:04   Re: KillTimer vs. delete timer
Reply With Quote #5

Quote:
Originally Posted by hmmmmm View Post
delete also sets it to null, so no need to do that either
Alright. Thanks!
__________________
Psyk0tik 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 04:20.


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