Should work, unless... you have something wierd.
PHP Code:
Handle mytimer;
public void OnPluginStart()
{
PrintToChatAll("Plugin loaded and timer creted");
mytimer = CreateTimer(60.0, timer_callback);
RegConsoleCmd("sm_test", test);
}
public Action test(int client, int args)
{
if(mytimer != null)
{
delete mytimer;
PrintToChat(client, "You stop timer.");
}
PrintToChat(client, "Piip!");
return Plugin_Handled;
}
public Action timer_callback(Handle timer)
{
// For example, when multiple timers have accidentally created to same handle, ignore previous timers.
// Or if Handle is null.
if(timer != mytimer)
{
return Plugin_Stop; // If repeating timer flag in use
}
// When you know timer callback will finish, not repeating.
// First step is clear handle.
mytimer = null;
PrintToChatAll("My timer got executed");
//return Plugin_Continue;
return Plugin_Stop; // If repeating timer flag in use
}
__________________