Raised This Month: $ Target: $400
 0% 

Pausing/unpausing a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 06-23-2014 , 06:32   Pausing/unpausing a plugin
Reply With Quote #1

Hey there. I am trying to pause a plugin. And by trying, I mean having no idea how to do that. I'm guessing the plugin_pause and plugin_unpause functions must be involved. But still, I do not know how to do it. Please, could you give me a hand? I'm a begginer in scripting, so I don't feel really handy with some things. I usually search tutorials or explanations on what I can't manage to figure out myself, but I was not able to find any documentation about this, except, ofcourse, the amxmodx functions list, which did not help me. So... what I basically want to learn is how can I pause a plugin for "x" seconds/minutes, and then unpause it.

Thank you for taking the time to read my issue and thank you for the future helping.

Best regards to you all, AMs.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-23-2014 , 09:25   Re: Pausing/unpausing a plugin
Reply With Quote #2

What exactly are you trying to achieve?
__________________
In Flames we trust!
Nextra is offline
...
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
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 06-23-2014 , 17:00   Re: Pausing/unpausing a plugin
Reply With Quote #4

Quote:
Originally Posted by Nextra View Post
What exactly are you trying to achieve?
By this thread, knowledge. With the achieved knowledge, I intend to achieve succes in writing my plugin.

Quote:
Originally Posted by ... View Post
You need to use natives :- pause and unpause
Pause :-
PHP Code:
pause flag[], const param1[]= ) 
Usage :



Unpause :-
PHP Code:
unpause flag[], const param1[]= ) 

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)

Thank you so much! The details on theese two natives helped me a lot. Also, by writing this plugin, you helped me understand it's use even better! Thanks again! Owe you one!
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Reply



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