PDA

View Full Version : How to load plugins base on port?


rsdtt
10-12-2014, 08:12
for example, in one srcds file
port 27015 is death server, load death.smx
port 27016 is hns server, load hns.smx

or can we prevent auto load plugins without modify sourcemod?

Oshizu
10-12-2014, 12:55
SMLib (https://forums.alliedmods.net/showthread.php?t=148387) provides you with Server_GetPort() function which will return server's port
So you could do stuff this way:

#include <smlib>

public OnAllPluginsLoaded()
{
new port = Server_GetPort()
if(port == 27016) // HNS
{
ServerCommand("sm plugins unload death.smx")
}
else // DEATHRUN
{
ServerCommand("sm plugins unload hns.smx")
}
}

Pelipoika
10-12-2014, 13:04
SMLib (https://forums.alliedmods.net/showthread.php?t=148387) provides you with Server_GetPort() function which will return server's port
So you could do stuff this way:

#include <smlib>

public OnPluginStart()
{
new port = Server_GetPort()
if(port == 27016) // HNS
{
ServerCommand("sm plugins unload death.smx")
}
else // DEATHRUN
{
ServerCommand("sm plugins unload hns.smx")
}
}


Except that instead of OnPluginStart you would use OnAllPluginsLoaded

Oshizu
10-12-2014, 13:19
Except that instead of OnPluginStart you would use OnAllPluginsLoaded

Yeah,
My bad :grrr:

KissLick
10-12-2014, 13:42
Or you can place plugins to disabled directory and load them according to the current game mode (via UMC or some map config plugin).

Oshizu
10-12-2014, 13:59
Or you can place plugins to disabled directory and load them according to the current game mode (via UMC or some map config plugin).

I used to do that myself sometime ago but it resulted somehow in plugins loading twice at times?

rsdtt
10-12-2014, 14:20
Or you can place plugins to disabled directory and load them according to the current game mode (via UMC or some map config plugin).

Yeah, I use this way for a long time, but it sometimes unload my plugins, I still cant get the problem.
So I want so ways to prevent auto load plugins, and just load my plugins list.
And now I try to lock it, I hope it is useful.

rsdtt
10-12-2014, 14:30
SMLib (https://forums.alliedmods.net/showthread.php?t=148387) provides you with Server_GetPort() function which will return server's port
So you could do stuff this way:

#include <smlib>

public OnAllPluginsLoaded()
{
new port = Server_GetPort()
if(port == 27016) // HNS
{
ServerCommand("sm plugins unload death.smx")
}
else // DEATHRUN
{
ServerCommand("sm plugins unload hns.smx")
}
}



Actually, I have a socket to get the server port should load which plugins, so it may delay, and it will load some code which should not load

h3bus
10-13-2014, 03:21
Another easy thing is to duplicate your SM folder, put the plugins you want for each server and specify sm_path in SRCDS start-up line.

Works fine for me!

friagram
10-13-2014, 05:07
Another easy thing is to duplicate your SM folder, put the plugins you want for each server and specify sm_path in SRCDS start-up line.

Works fine for me!

The only problem with this is that you can't have asynchronous updates, and if you have plugins or game modes that use resources outside of the sm directory (like tf/scripts for mvm) or you have different metamod addon configs (stipper source for maps), or even just server configs and map specific configs, this may not work out well for you.

rsdtt
10-13-2014, 11:29
The only problem with this is that you can't have asynchronous updates, and if you have plugins or game modes that use resources outside of the sm directory (like tf/scripts for mvm) or you have different metamod addon configs (stipper source for maps), or even just server configs and map specific configs, this may not work out well for you.

so I should write an ext load the other file or write a dll base on mms?

friagram
10-15-2014, 04:54
1 install per srcds instance is best

rsdtt
10-16-2014, 05:05
1 install per srcds instance is best

that must be a sad for me