|
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
|

06-23-2014
, 17:00
Re: Pausing/unpausing a plugin
|
#4
|
Quote:
Originally Posted by Nextra
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 ...
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(PLUGIN, VERSION, AUTHOR)
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!
|
|