View Single Post
Author Message
Join Date: Aug 2007
Old 12-31-2008 , 12:34   Server Redirect 1.1 [Last update: Februari 7, 2009]
Reply With Quote #1

Server Redirect 1.1

Plugin description

This plugin provides players with the ability to connect to another gameserver by using the !servers command. This plugin differs from other similar plugins (Client Redirect v1.1a and Advanced Client Redirect) in that it has additional features such as displaying the current map and amount of players. Several native functions are provided to easily integrate with other plugins. An optional advertisement module can be activated to notify players of available servers.


I was looking for a way to advertise my servers to players and provide them with an easy way to switch to another server. Unhappy with the existing plugins, I decided to create my own. Based on comments on the other plugins I then expanded the code with some additional features.

How it works (players)

A player can type !servers in chat. A menu with a list of available servers is shown, including some basic information such as current map and current amount of players. The player selects a server and has to confirm (F3 by default). To help promote servers, you can choose to periodically display information about other servers.

How it works (admins)

This plugin uses a shared database to store server information. Each server with the plugin will periodically send a heartbeat to the database along with the current server status. Whenever a player wants to be redirected, this database is queried for a list of available servers. It is possible to filter out offline servers and/or the current server.

How it works (developers)

Include to get access to a number of native functions. Currently included are:
* Display the redirect menu to a specific user.
* Request a list of available servers.
Sample code is provided to show you how to use these functions.


* Allows users to find and connect to another server.
* Optionally exclude offline servers.
* Optionally exclude the current server.
* Allows you to incorporate additional information in the server description. Currently: current map, current amount of players, maximum amount of players.
* Can advertise servers which are currently online and available.
* Include file provided to help integrate with other plugins.
* Grouping of servers, to be able to use a single database for multiple games.
* Compensates for fake clients, such as SourceTV.

Game compatibility

* Tested successfully with Sourcemod 1.1 on TF2, CSS, DoD.
* Tested on Sourcemod 1.2 as well.
* Appears broken on L4D, the plugin works but redirecting does not work in this mod (F3 will just disconnect you).


Requirements: MySQL server + some admin tool like PHPMyAdmin.

1) Download the zip file below.
2) Use PHPMyAdmin or a similar tool to create a new database.
3) Use .sql file from the zip file to create the MySQL table with a some sample data. Take a look at the sample data and insert your own server in a similar fashion. Remember the ID of the server, you will need it in step 7.
4) Configure the database connection in sourcemod/configs/databases.cfg, like this:
        "driver"            "default"
        "host"                ""
        "database"            "serverredirect"
        "user"                "username"
        "pass"                "strongpassword"
        //"timeout"            "0"
        //"port"            "0"
5) Copy the contents from the zip file (/plugins directory and /translations directory) to your Sourcemod installation.
6) Load the plugins to ensure that /cfg/sourcemod/plugin.serverredirect.cfg gets created.
7) Edit the /cfg/sourcemod/plugin.serverredirect.cfg configuration file and set the correct value of the sm_redirect_serverid convar. This ID corresponds to the 'id' fields in the 'server' table in your database, which was set in step 3.
* Ensure that changes in your convars are picked up by the server, by executing /cfg/sourcemod/plugin.serverredirect.cfg. The plugin should function and send a heartbeat signal to the database. You can check this by looking at the contents of the database, you should see updated values. Also, the !servers command should work.

Optional installation steps

* In the database, you have to specify a 'groupnumber' (default value 1). use this field to group similar servers together by giving them the same group number. For example, put your TF2 servers in group 1 and your CSS servers in group 2. If you request the redirect menu from a TF2 server, it will only show servers from the same group (thus ignoring the CSS servers).
* Take a look at the various convars and adjust them to your needs.

Upgrading from 1.0 to 1.1

Upload the /plugins folder. There have been no changes in the translations, API or SQL database.

Convars and commands

* sm_redirect_serverid - set this variable to the ID of your server in the database. Be sure to set the variable or the plugin will seem not to be working.
* sm_redirect_showcurrent - boolean, set false to hide the current server from the redirect window. Default: true.
* sm_redirect_showoffline - boolean, set false to hide offline servers from the redirect menu. Default: true.
* sm_redirect_menusort - Indicates how menu items get sorted. 1 = by display name (default), 2 = by server ID
* sm_redirect_enableheartbeat - Whether to enable heartbeat signal for this server. If stopped, the server will be marked as offline.

* sm_redirect_ads_interval - interval at which servers will be advertised. The default value of 60 means that every 60 seconds an ad will be displayed.
* sm_redirect_ads_format - formatting message. Change this value to adjust the ad which is displayed. Use the variables {IP} and {NAME} to include the server description and ip address. You can also use {CURR} {MAX} and {MAP}.
* sm_redirect_ads_hideempty - when set, servers without players will not be advertised

* sm_redirect_list - As an admin, see the list of available redirect servers.
* sm_redirect_show <#userid|name> - Show the redirect menu to a specific user or group of users. You can use targetting groups such as @all, @blue, @red, etc.


* Ensure that the sm_redirect_serverid convar is set and that your config files do not reset this value to 0! If set the an incorrect value (such as 0), the plugin will not display any errors. If set to an incorrect value, the heartbeat will not work and the !servers command will be unable to show any servers. Related plugins (such as ads) will not work either.
* If the ads server is not displaying any ads, ensure that there are two or more servers in the group online. The ads plugin excludes any servers that are offline, as well as the current server. If there are not enough servers online, the ads module has nothing to display.


* A server is considered offline when no heartbeat has been received for two minutes or more. A heartbeat will be triggered every 30 seconds.
* Use the variables {MAP}, {CURR} and {MAX} in the server description. Take a look at the sample data in the database where this is used.
* This plugin was developed with Sourcemod 1.1.0 and MySQL 5.0.51. Other Mysql versions should work (4.1.1+ I think).
* Alternative commands to !servers: !server, !swapme.

Incorporates code parts from the following plugins:
* Advanced Client Redirect (the code to show the redirect window)
* Advertisements (to replace variables such as {MAP})



Main plugin (serverredirect.smx)
! Fixed settings not being applied properly
! Fixed package (proper lay-out and correct files)
! Fixed mysql script, commented the create database statement and fixed syntax.
? Now uses sv_maxvisibleplayers by default to determine max amount of players. Provides compatibility
with reserved slot plugins. If sv_visiblemaxplayers is not set (less than 0), it'll
use the maximum amount of player slots on the server.
+ Added sm_redirect_menusort to be able to choose how items get sorted.
+ Added sm_redirect_enableheartbeat tobe able to enable/disable the heartbeat. Can be used to (temporarily) disable
the plugin and avoid advertising the server.

1.0 - initial release

Ads (serverredirect_ads.smx)

+ Can prevent empty servers from being advertised by setting sm_redirect_ads_hideempty to 1
+ {MAP}, {CURR} and {MAX} can now be used in the sm_redirect_ads_format var.
+ Interval between ads can now be changed without having to reload the plugin.

1.0 - initial release
Attached Files
File Type: zip (32.7 KB, 8197 views)

Last edited by Brainstorm; 02-07-2009 at 11:49.
Brainstorm is offline