AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CSS] Plugin Only in a Specified Map (https://forums.alliedmods.net/showthread.php?t=181832)

away000 04-02-2012 17:52

[CSS] Plugin Only in a Specified Map
 
How can i do to run a plugin only in a pre defined map?

I want a "code" who i can put in "OnPluginStart" and check if is the map who need the plugin, if is the map them RUN plugin if not them no load the plugin (but plugin stay in PLUGIN folder in case run the map after...)

Lord Canistra 04-02-2012 18:20

Re: [CSS] Plugin Only in a Specified Map
 
Check map with GetCurrentMap, then disable it by some means (try sm plugin unload *plugin_name*)

minimoney1 04-02-2012 18:47

Re: [CSS] Plugin Only in a Specified Map
 
can just make a global bool which tells the plugin if it should function or not.
OnMapStart you can call GetCurrentMap and check if it's a specific map.

If you want to do this with another plugin and disable it, you can use ServerCommand("sm plugins unload \"plugin name\"");

mcpan313 04-03-2012 11:18

Re: [CSS] Plugin Only in a Specified Map
 
PHP Code:

new bool:g_bPluginEnable;

public 
OnMapStart()
{
    
decl String:map_name[32];
    
GetCurrentMap(map_namesizeof(map_name));
    if (
strcmp(map_name"de_dust") == ||
        
strcmp(map_name"de_dust2") == 0)
    {
        
g_bPluginEnable true;
    }



away000 04-03-2012 11:22

Re: [CSS] Plugin Only in a Specified Map
 
Thanks, that is what i want but why have Dust and Dust2? how i can do to map run only in Dust and not in Dust2? (for example)

TnTSCS 04-03-2012 11:26

Re: [CSS] Plugin Only in a Specified Map
 
what you want is StrEqual then...

PHP Code:

if(StrEqual(map_name"de_dust"false))
{
    
g_bPluginEnable true;


OR

Have your plugin use a CVar to enable (or disable) the plugin and use map configs

away000 04-03-2012 11:48

Re: [CSS] Plugin Only in a Specified Map
 
Quote:

Originally Posted by TnTSCS (Post 1681126)
what you want is StrEqual then...

PHP Code:

if(StrEqual(map_name"de_dust"false))
{
    
g_bPluginEnable true;


OR

Have your plugin use a CVar to enable (or disable) the plugin and use map configs

Thanks TnT but i got this....


X2AeonGameChooser.sp(23) : error 017: undefined symbol "map_name"
X2AeonGameChooser.sp(25) : error 017: undefined symbol "g_bPluginEnable"
X2AeonGameChooser.sp(25) : warning 215: expression has no effect

2 Errors.




Thanks mcpan

Quote:

Originally Posted by mcpan313 (Post 1681118)
PHP Code:

new bool:g_bPluginEnable;

public 
OnMapStart()
{
    
decl String:map_name[32];
    
GetCurrentMap(map_namesizeof(map_name));
    if (
strcmp(map_name"de_dust") == ||
        
strcmp(map_name"de_dust2") == 0)
    {
        
g_bPluginEnable true;
    }




But got this:


X2AeonGameChooser.sp(27) : warning 204: symbol is assigned a value that is never used: "g_bPluginEnable"
Header size: 2444 bytes
Code size: 3608 bytes
Data size: 4816 bytes
Stack/heap size: 16384 bytes; Total requirements: 27252 bytes

1 Warning.

TnTSCS 04-03-2012 11:50

Re: [CSS] Plugin Only in a Specified Map
 
well... you have to integrate that code snippit into your plugin :)

Are you asking for coding help, or SM help?


Here's my above suggestion in the code mcpan313 provided:
PHP Code:

new bool:g_bPluginEnable;

public 
OnMapStart()
{
    
decl String:map_name[32];
    
map_name[0] = '\0';

    
GetCurrentMap(map_namesizeof(map_name));

    if(
StrEqual(map_name"de_dust"false))
    {
        
g_bPluginEnable true;
    }



away000 04-03-2012 11:55

Re: [CSS] Plugin Only in a Specified Map
 
Any help would be awsome :D

About integrate that code into the plugin is my problem, i don't know how to do this....

TnTSCS 04-03-2012 12:05

Re: [CSS] Plugin Only in a Specified Map
 
if you want someone to alter a plugin to only be enabled on certain maps, then either post in that plugins thread or in the Requests And Suggestions section...

But since you started here, if you want, post the plugin (or link to the thread you got it from) and someone can probably oblige.


All times are GMT -4. The time now is 02:10.

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