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

plugin by map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bobthebuilder
SourceMod Donor
Join Date: Dec 2010
Location: Randers/Denmark/Earth
Old 03-08-2012 , 14:03   plugin by map
Reply With Quote #1

do anyone know if there is a plugin that load plugins when there is a specific map on the server? lets say i want to run both a mini game server and a jail server on one server. when maps starts with ba and jb it loads hosties and when the maps starts with mg it loads my mini game plugin. that way you can have 2 servers in one. if its not made can anyone do it? that would help me alot..

to those who properly will write "learn to use the search funtion!" i allready did! could not find anyting.


Thanks for reading this!
Bobthebuilder
bobthebuilder is offline
Send a message via Skype™ to bobthebuilder
Doodil
Senior Member
Join Date: Mar 2012
Old 03-08-2012 , 14:37   Re: plugin by map
Reply With Quote #2

Code:
public OnPluginStart()
{
    decl String:mapname[30];
    GetCurrentMap(mapname,sizeof(mapname));
    if ((StrContains(mapname,"ba_",false))==0 || StrContains(mapname,"jb_",false))
    {
        ServerCommand("sm plugins load PLUGINNAME");
    }
    if (StrContains(mapname,"mg_",false)==0)
    {
        ServerCommand("sm plugins load PLUGINNAME");
    }
}
Should pretty much do the trick. The plugin loads on every mapchange and the first thing it does is to check the current mapname and if it includes "ba_" or "jb_" it does whatever you after the first if clause, and if it includes "mg_" it does whatever you write after the second if clause.

Haven't tested it myself but it should work, you just need to know which plugins to load/commands to execute and write them in there.



Edit: Messed up StrEquals and StrContains, should work now

Last edited by Doodil; 03-08-2012 at 15:20.
Doodil is offline
bobthebuilder
SourceMod Donor
Join Date: Dec 2010
Location: Randers/Denmark/Earth
Old 03-08-2012 , 14:41   Re: plugin by map
Reply With Quote #3

awesome thanks! what if i want to load more then one plugin? then the code would be? right?
Quote:
public OnPluginStart()
{
decl String:mapname[30];
GetCurrentMap(mapname,sizeof(mapname));
if ((StrEqual(mapname,"ba_",false)) || StrEqual(mapname,"jb_",false))
{
ServerCommand("sm plugins load PLUGINNAME");
ServerCommand("sm plugins load PLUGINNAME");
}
if (StrEqual(mapname,"mg_",false))
{
ServerCommand("sm plugins load PLUGINNAME");
ServerCommand("sm plugins load PLUGINNAME");
}
}

Last edited by bobthebuilder; 03-08-2012 at 14:41.
bobthebuilder is offline
Send a message via Skype™ to bobthebuilder
Doodil
Senior Member
Join Date: Mar 2012
Old 03-08-2012 , 14:45   Re: plugin by map
Reply With Quote #4

thats right, make sure that the other plugins do not load automatically though. also remove whitespaces in your plugin names (if there are any) or change the command to:

Code:
ServerCommand("sm plugins load \"PLUGINNAME WITH WHITESPACE\"");
You can pretty much put any command you would write into the server console into the ServerCommand() function. just make sure that if the server command is:

Code:
kick "Player with name"
the function looks like:

Code:
ServerCommand("kick \"Player with name\"");
Doodil is offline
bobthebuilder
SourceMod Donor
Join Date: Dec 2010
Location: Randers/Denmark/Earth
Old 03-08-2012 , 15:13   Re: plugin by map
Reply With Quote #5

awww i am a bit confused. can i add you on steam or skype?
bobthebuilder is offline
Send a message via Skype™ to bobthebuilder
Doodil
Senior Member
Join Date: Mar 2012
Old 03-08-2012 , 15:15   Re: plugin by map
Reply With Quote #6

go ahead:

http://steamcommunity.com/profiles/76561197966076421
Doodil is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-08-2012 , 19:03   Re: plugin by map
Reply With Quote #7

o'boy..
can just done with map configs with SM commands for loading plugins from ...disabled/ folder, then server config to unload.
- Depends would plugin(s) work like that way after mapchange... crash ? (know better when test)
- *edit best way is use plugin cvars enable/disable

Last edited by Bacardi; 03-09-2012 at 02:53.
Bacardi is offline
Hawkeye-
Senior Member
Join Date: Jan 2009
Old 03-08-2012 , 19:30   Re: plugin by map
Reply With Quote #8

Somethign that may help you (based of code Berni wrote originally)

PHP Code:
#define PUSH 1
#define STOPWATCH 2
#define CTF 3
#define PAYLOAD 4
#define PAYLOADRACE 5
#define KOTH 6
#define ARENA 7
#define TC 8

new g_iMapType 0// Stores the Map Type as a numeric value for easy reference with switch statements
new String:g_sMapName[36];    // Stores the current mapname various functions like STV

/*
---------------------------------------------------------------------------------------------------------------------------------------------------------------
DetectMap

Routine is designed to detect the map type and set a variable used by other features of MatchMod
---------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
DetectMap() {
    
// This routine detects the map type, original function written by Berni
    
new iEnt = -1bool:bAttackPoint false;
    
GetCurrentMap(g_sMapNamesizeof(g_sMapName));
    if (
strncmp(g_sMapName"cp_"3false) == 0) {
        new 
iTeam;
        while ((
iEnt FindEntityByClassname(iEnt"team_control_point")) != -1) {
            
iTeam GetEntProp(iEntProp_Send"m_iTeamNum");
            
/**
            * If there is a blu CP or a neutral CP, then it's not an attack/defend map
            *
            **/
            
if (iTeam != RED) {
                
g_iMapType STOPWATCH;
                break;
            }
        }
        if (!
bAttackPoint) {
            
g_iMapType PUSH;
        }
    }
    else if (
strncmp(g_sMapName"bball_"6false) == 0) {
        
g_iMapType CTF;
    }
    else if (
strncmp(g_sMapName"ctf_"4false) == 0) {
        
g_iMapType CTF;
    }
    else if (
strncmp(g_sMapName"koth_"5false) == 0) {
        
g_iMapType KOTH;
    }
    else if (
strncmp(g_sMapName"pl_"3false) == 0) {
        
g_iMapType PAYLOAD;
    }
    else if (
strncmp(g_sMapName"plr_"4false) == 0) {
        
g_iMapType PAYLOADRACE;
    }
    else if (
strncmp(g_sMapName"arena_"6false) == 0) {
        
g_iMapType ARENA;
    }
    else if (
strncmp(g_sMapName"tc_"3false) == 0) {
        
g_iMapType TC;
    }
    else {
        
// In the event we don't know assume PUSH gametype
        
g_iMapType PUSH;
    }

I use this to determine the map type and then set a flag I can leverage. you could simply modify the code on each map type to do whatever you need or add new game modes or whatever.
Hawkeye- is offline
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:43.


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