AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] How make a automatic enable / disable plugin (https://forums.alliedmods.net/showthread.php?t=125921)

GalegO 05-03-2010 16:08

[SOLVED] How make a automatic enable / disable plugin
 
1 Attachment(s)
Hii guys, I try to modifique the Galileo plugin to enable and disable automatically.

I get a source part of this plugin: Show Admins Online to identify the admins.

I modified the source of Galileo and I think is correct, BUT I don't know what the correct function (or functions) I call to enable the plugin.

What I want: If have one or more ADM online, the plugin doesn't work. If don't have AMD online, the plugin work normaly

In attachments have my modified source.

Thanks guys.

PS: Sorry for may bad english...

wrecked_ 05-03-2010 17:41

Re: How make a automatic enable / disable plugin
 
Add this to your plugin.

Code:
#include <amxmisc> new iAdmins public client_putinserver( id ) {     if( is_user_admin( id ) )     {         iAdmins++         pause( "a" )     } } public client_disconnect( id ) {     if( is_user_admin( id ) )     {         if( --iAdmins < 1 )         {             unpause( "a" )         }     } }

GalegO 05-03-2010 23:05

Re: How make a automatic enable / disable plugin
 
wrecked, I'll remove my all modifications and put only this code?

What I write in the "a" ? The plugin's name?

And about a cvar to enable and disable this function... How I can do?

Thanks for help :)

Bugsy 05-03-2010 23:17

Re: How make a automatic enable / disable plugin
 
See for yourself
http://www.amxmodx.org/funcwiki.php?go=func&id=223

GalegO 05-04-2010 12:11

Re: How make a automatic enable / disable plugin
 
Thanks! I'll test now :)

Bugsy 05-04-2010 13:44

Re: How make a automatic enable / disable plugin
 
The only issue I see is whether or not the plugin will be able to unpause itself while in a paused state.

GalegO 05-04-2010 14:42

Re: How make a automatic enable / disable plugin
 
1 Attachment(s)
Yes, I compiled and tested now...

It pause, but no unpause :(

This is parts of my code:

Code:

new cvar_automatic;
new iAdmins;

public plugin_init()
{
    cvar_automatic                = register_cvar("gal_automatic", "1");
}

public client_disconnect(id)
{
    if( is_user_admin( id ) && get_pcvar_num(cvar_automatic) == 1 )
        {
            if( --iAdmins < 1 )
            {
                    unpause( "a" );
            }
        }
}

public client_putinserver(id)
{
    if( is_user_admin( id ) && get_pcvar_num(cvar_automatic) == 1 )
        {
            iAdmins++;
            pause( "a" );
        }
}

In attachments, my modified source...

PS: Search for //AUTOMATIC in the source, I put this to find more quicky my modifications...

Quote:

Originally Posted by Bugsy
The only issue I see is whether or not the plugin will be able to unpause itself while in a paused state.

Hahaha... IS true!!! If stoped he doen't work more!!! hahaah... I'll make a new plugin to pause and unpause this plugin... Is the only way...

This is my second modification in a plugin, the first I only translated the KnifeDuel to Pt_Br...

wrecked_ 05-04-2010 15:28

Re: How make a automatic enable / disable plugin
 
Give this a shot.

Code:
#include <amxmodx> #include <amxmisc> new iAdmins public plugin_init() {     register_plugin( "Galileo Fixer", "1.0", "Wrecked" ) } public client_putinserver( id ) {     if( is_user_admin( id ) )     {         iAdmins++                 pause( "ac", "galileo.amxx" )     } } public client_disconnect( id ) {     if( is_user_admin( id ) && ( --iAdmins < 1 ) )     {         unpause( "ac", "galileo.amxx" )     } }

GalegO 05-04-2010 16:22

Re: How make a automatic enable / disable plugin
 
Thanks MAN!!! Works perfectly!!!


All times are GMT -4. The time now is 03:52.

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