AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [STOCK] Clear a timer (https://forums.alliedmods.net/showthread.php?t=197677)

shavit 10-06-2012 00:29

[STOCK] Clear a timer
 
I'm making a BIG plugin for CS:S Jailbreak and it uses some timers, so I made this but in a native (the plugin will include an API with this native):
PHP Code:

stock ClearTimer(&Handle:Timer)
{
    if(
Timer != INVALID_HANDLE)
    {
        
CloseHandle(Timer);
        
Timer INVALID_HANDLE;
    }


Paste it in the bottom of your plugin and use it like in this example:
PHP Code:

new coolInt;

public 
Action:hellobuddy(clientargs)
{
          new 
Handle:MyTimer CreateTimer(30.0blabla_TIMER_FLAG_NOMAPCHANGE);
          
          switch(
coolInt)
          {
                    case 
3:
                    {
                              
ClearTimer(MyTimer);
                              
coolInt 0;
                    }
                    
                    
                    default:
                    {
                              
coolInt++;
                              
PrintToServer("hey homie the coolInt is now %i."coolInt);
                    }
          }



mcpan313 10-06-2012 03:38

Re: [STOCK] Clear a timer
 
miss &
Code:

stock ClearTimer(&Handle:Timer)
{
    if(Timer != INVALID_HANDLE)
    {
        CloseHandle(Timer);
        Timer = INVALID_HANDLE;
    }
}


shavit 10-06-2012 04:23

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by mcpan313 (Post 1813496)
miss &
Code:

stock ClearTimer(&Handle:Timer)
{
    if(Timer != INVALID_HANDLE)
    {
        CloseHandle(Timer);
        Timer = INVALID_HANDLE;
    }
}


whoops

ReFlexPoison 10-06-2012 15:25

Re: [STOCK] Clear a timer
 
And you are the one who made this ... ?

Doc-Holiday 10-06-2012 15:40

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by ReFlexPoison (Post 1813764)
And you are the one who made this ... ?

seeing as it is incredibly simple. im sure its been made like a million times lolz.

shavit 10-06-2012 16:09

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by ReFlexPoison (Post 1813764)
And you are the one who made this ... ?

This one yes.

I think that they have to add a native like this to SourceMod.

Doc-Holiday 10-06-2012 16:12

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by shavit (Post 1813790)
This one yes.

I think that they have to add a native like this to SourceMod.

its pretty easy and inexpensive to run this type of stock on your own in each plugin. its not really that big of a deal.


BUT INCREDIBLY USEFUL hahaha

ReFlexPoison 10-06-2012 16:22

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by shavit (Post 1813790)
This one yes.

I think that they have to add a native like this to SourceMod.

Well I can tell you this post is really unnecessary as:
  • This stock has already been posted on the forum several times.
  • They probably wont be adding it as a native to core Sourcemod as simply just killing a timer and stating it as INVALID_HANDLE is all this stock does. (Read from older thread(s))
  • This has probably been used in several includes already.

thetwistedpanda 10-06-2012 19:26

Re: [STOCK] Clear a timer
 
This stock goes back a few years, just about every coder has one or uses one lol... (in b4 trash)

shavit 10-06-2012 20:55

Re: [STOCK] Clear a timer
 
Quote:

Originally Posted by thetwistedpanda (Post 1813927)
in b4 trash

meh


All times are GMT -4. The time now is 18:29.

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