Raised This Month: $ Target: $400
 0% 

Pausing/unpausing a plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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