Raised This Month: $ Target: $400
 0% 

Pausing/unpausing a plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
...
Junior Member
Join Date: Jun 2014
Old 06-23-2014 , 13:11   Re: Pausing/unpausing a plugin
Reply With Quote #3

You need to use natives :- pause and unpause
Pause :-
PHP Code:
pause flag[], const param1[]= ) 
Usage :

Quote:
param2 name of plugin (all depends on flags).
Flags:
"a" - pause whole plugin.
"b" - pause function.
"c" - look outside the plugin (by given plugin name).
"d" - set "stopped" status when pausing whole plugin.
"e" - set "locked" status when pausing whole plugin.
In this status plugin is unpauseable.
Example: pause("ac","myplugin.amxx")
pause("bc","myfunc","myplugin.amxx")


Unpause :-
PHP Code:
unpause flag[], const param1[]= ) 
Quote:
Flags:
"a" - unpause whole plugin.
"b" - unpause function.
"c" - look outside the plugin (by given plugin name).
Example
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "..."

#define TASK_TIME 444645

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("/pause","pause_plugin",ADMIN_BAN,"<pluginname> <float:seconds>")
}


public 
pause_plugin(id,level ,cid)
{
    if(!
cmd_access(id,level,cid,2))
        return 
PLUGIN_HANDLED
    
new pluginname[64] , seconds[10]
    
read_argv(1,pluginname,charsmax(pluginname)) 
    
read_argv(2,seconds,charsmax(seconds))
    
trim(pluginname); trim(seconds); remove_quotes(pluginname); remove_quotes(seconds)
    new 
num str_to_float(seconds)

    if(
seconds[0] == EOS || num <= 0)
    {
        
        
client_cmd(id,"echo [ Plugin Pause ] : Invalid seconds , it should be number !")
        return 
PLUGIN_HANDLED
        
    
}
    
    if(
task_exists(TASK_TIME))
    {
        
        
client_cmd(id,"echo [ Plugin Pause ] : Another plugin is already paused.")
        return 
PLUGIN_HANDLED
        
    
}
    
    if(
is_plugin_loaded(pluginname,true) != -1)
    {
        
        
pause("ac",pluginname)
        
set_task(num,"unpause_plugin",TASK_TIME,pluginname,strlen(pluginname))
        
client_print(0,3,"[ Plugin Pause ] : Plugin ^"%s^" is now paused and will be unpaused after %f seconds.",pluginname,num)
        
client_cmd(id,"echo [ Plugin Pause ] : Plugin ^"%s^" successfully paused for %f seconds",pluginname,num)
        
    }
    else
        
client_cmd(id,"echo [ Plugin Pause ] : Plugin ^"%s^" not found",pluginname)
}

public 
unpause_plugin(plugin[])
{
    
client_print(0,3,"[ Plugin Pause ] : Plugin ^"%s^" is now unpaused.",plugin)
    
unpause("ac",plugin)

... is offline
 



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 21:06.


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