AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Server Redirect 1.1 [Last update: Februari 7, 2009] (https://forums.alliedmods.net/showthread.php?t=82886)

Brainstorm 12-31-2008 12:34

Server Redirect 1.1 [Last update: Februari 7, 2009]
 
1 Attachment(s)
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.


Background

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 serverredirect.inc 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.


Features

* 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).


Installation

Requirements: MySQL server + some admin tool like PHPMyAdmin.

Steps:
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:
Code:

   
    "serverredirect"
    {
        "driver"            "default"
        "host"                "127.0.0.1"
        "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

serverredirect.smx
* 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.

serverredirect_ads.smx
* 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

serverredirect_cmd.smx
* 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.



Troubleshooting

* 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.


Remarks

* 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})


Screenshots

http://www.red-snow.org/tf2/plugins/sr1.jpg

http://www.red-snow.org/tf2/plugins/sr2.jpg

http://www.red-snow.org/tf2/plugins/sr3.jpg




Changelog

Main plugin (serverredirect.smx)
1.1
! 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)

1.1
+ 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

SAMURAI16 12-31-2008 12:48

Re: Server Redirect
 
excellent
nice done

Nomarky 12-31-2008 13:31

Re: Server Redirect
 
Like the new features!

Nice:D

PStar 01-01-2009 00:35

Re: Server Redirect
 
Does it work with SQLite?

Brainstorm 01-01-2009 06:00

Re: Server Redirect
 
Well, SQLite files are stored locally so that'd make it hard to have multiple servers access the very same database, especially if you have multiple physical servers. Even if you'd manage to set it up (with forked L4D servers for example), I have no idea whether SQLite can handle multiple processes accessing the same database.

I can test it though :)

DJ Tsunami 01-01-2009 11:59

Re: Server Redirect
 
Hey Brainstorm, good to see you releasing some plugins :) I know you from GoT, so :)

PStar 01-01-2009 15:01

Re: Server Redirect
 
Would this wokr between games too? For exmaple from a CSS game you could conet to a TF2server if you have TF2 on your acount.

Mosalar 01-01-2009 16:05

Re: Server Redirect
 
Now if this could just be tied into a multi server 2 server chat feature...

Kenny Loggins 01-01-2009 16:20

Re: Server Redirect
 
You can use HLstatsX CE for that... It works great

zerak 01-01-2009 20:26

Re: Server Redirect
 
[req] sort them by their id instead of by there names when displaying to clients in the menu
edit: nvm will change sql query to sort tomorrow :)


All times are GMT -4. The time now is 16:37.

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