Raised This Month: $51 Target: $400
 12% 

How correctly to load/unload a module?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 12-30-2011 , 03:00   How correctly to load/unload a module?
Reply With Quote #1

I have problem while testing module.
In the game I print in console "meta unload mymodule" and module unloads but incorrectly. After this action I cant to rewrite module-file. How correctly to unload a module?
I know that you can rename the module and make a copy with the original name and problem with unloading the module is disappears. But I don't want to do it every time after CS. There is another solution?
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 12-31-2011 , 00:15   Re: How correctly to load/unload a module?
Reply With Quote #2

I found my error: I added module in addons\amxmodx\configs\modules.ini but for correct load/unload should to add in addons\metamod\plugins.ini
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 01-01-2012 , 11:35   Re: How correctly to load/unload a module?
Reply With Quote #3

Problem is relevant again. In module I added natives but amxx plugin can use its when module is written in addons\amxmodx\configs\modules.ini.
How to be in this situation?
I think should to add commands "amxx load" and "amxx unload" in amxmodx but it hard to do for me.

Last edited by -=hunter=-; 01-01-2012 at 11:39.
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 01-02-2012 , 10:07   Re: How correctly to load/unload a module?
Reply With Quote #4

I tried to change srvcmd.cpp in amxmodx but server hangs.
What wrong in this code?
PHP Code:
    else if (!strcmp(cmd"unload_module") && CMD_ARGC() > 2)
    {
        const 
char *szModuleFilename;
        
char *szModule = new char[256];
        
strcpy(szModuleCMD_ARGV(2));
        
strcat(szModule"_amxx.dll");        

        
CList<CModule, const char *>::iterator a g_modules.begin();

        
bool bFoundModule false;

        
// Search module with given name
        
while (a)
        {
            
szModuleFilename = (*a).getFilename();
            for ( 
int i strlen(szModuleFilename)-1>= 0i-- )
            {
                if ( 
szModuleFilename[i] == '\\' )
                {
                    if ( !
strcmp(szModule, &szModuleFilename[i+1]) )
                    {
                        
bFoundModule true;
                        break;                        
                    }
                }
            }

            ++
a;
        }

        if ( 
bFoundModule )
        {
            
print_srvconsole("Tried to unload \"%s\"\n"szModule);
                                 
// server hangs in this place:
            
(*a).CallPluginsUnloading();
            (*
a).CallPluginsUnloaded();
            (*
a).detachModule();            
            
a.remove();        

            
/*
            List<Library *>::iterator iter;
                        
            iter = g_libraries.begin();
            while (iter != g_libraries.end())
            {
                //(*iter)
            }
            */
            //print_srvconsole("Unloaded module \"%s\"\n", szModule);            
        
}
        else
        {
            
print_srvconsole("Module \"%s\" not found\n"szModule);
        }
    } 

Last edited by -=hunter=-; 01-02-2012 at 10:07.
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
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 10:54.


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