Raised This Month: $ Target: $400
 0% 

[Request] - Plugin that randomly turn on/off other plugins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ThatGuyCZ
Junior Member
Join Date: Jul 2014
Old 07-12-2014 , 13:30   [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #1

Hello,
so i want to make plugin that will at the end of map randomly turn off and on plugins (what i select that they can be turned off and on) by one of these ways:

1. Randomizer_Plugin will rewrite plugins.ini file by one of predefined
2. Randomizer_Plugin will move plugins (that i want to be randomized) to another folder and back
3. Randomizer_Plugin will save orig. names of plugins (that i want to be randomized), change names by random numbers, save this changed names and after new map will change names back

Or if you have better idea How, please say it.

Thank you
ThatGuyCZ is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-12-2014 , 13:36   Re: [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #2

Better idea: just make plugins-random.ini file, type in there plugins you want to be randomized. Now you only need script that does that random and writes file - polymorph does something similar in writing.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-12-2014 , 13:43   Re: [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #3

You want to turn on/off plugins just before map change? If so configuration file should look like this:
plugin1.amxx
plugin2.amxx
plugin3.amxx
plugin4.amxx

After this plugin choose some random plugins and turn them on/off for next map ( let's say 1 and 3 on / 2 and 4 off ) ?
HamletEagle is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-12-2014 , 14:02   Re: [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #4

Made an example, should be working fine, just make sure that file name exists.
PHP Code:
#include <amxmodx>
new Array:g_aPluginsList;

public 
plugin_init()
{
    
register_plugin("Random plugins""1.0""GuskiS");
    
g_aPluginsList ArrayCreate(485);

    
random_plugins("plugins-random.ini");
}

stock random_plugins(filename[])
{
    new 
path[96];
    
get_localinfo("amxx_configsdir"pathcharsmax(path));
    
format(pathcharsmax(path), "%s/%s"pathfilename);

    if(
file_exists(path))
    {
        new 
fileline[64];
        
file fopen(path"rt");
        if(!
file)
            return 
0;

        while(!
feof(file))
        {
            
fgets(filelinecharsmax(line));
            if(!
line[0])
                continue;

            
ArrayPushString(g_aPluginsListline);
        }
        
fclose(file);

        
file fopen(path"wt");
        if(!
file)
            return 
0;

        for(new 
0ArraySize(g_aPluginsList); i++)
        {
            
ArrayGetString(g_aPluginsListilinecharsmax(line));
            if(
random_num(01))
            {
                if(
line[0] != ';')
                    
format(linecharsmax(line), ";%s"line);
            }
            else
            {
                if(
line[0] == ';')
                    
line[0] = ' ';
            }

            
trim(line);
            
fprintf(file"%s^n"line);
        }
        
fclose(file);
    }

    return 
1;

__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 07-12-2014 at 14:04.
GuskiS is offline
ThatGuyCZ
Junior Member
Join Date: Jul 2014
Old 07-13-2014 , 15:35   Re: [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #5

It works! Thank you - but can i have one more thing that i want? can you please make it that it will load only one of randomized plugins? - turn off all random plugins and enable just one of them randomly. Please

Edit: And can you make it that it will say (at the end or start of the map) what plugin is turned on? (like - i have plugin GunGame.amxx and it will say it without .amxx)

Last edited by ThatGuyCZ; 07-14-2014 at 09:26.
ThatGuyCZ is offline
ThatGuyCZ
Junior Member
Join Date: Jul 2014
Old 07-13-2014 , 15:40   Re: [Request] - Plugin that randomly turn on/off other plugins
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
You want to turn on/off plugins just before map change? If so configuration file should look like this:
plugin1.amxx
plugin2.amxx
plugin3.amxx
plugin4.amxx

After this plugin choose some random plugins and turn them on/off for next map ( let's say 1 and 3 on / 2 and 4 off ) ?
got it from gentleman above

Last edited by ThatGuyCZ; 07-13-2014 at 15:51.
ThatGuyCZ is offline
Old 07-14-2014, 11:39
ThatGuyCZ
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
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 05:11.


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