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 :)

Kenny Loggins 01-03-2009 15:22

Re: Server Redirect
 
What a great plugin... This works great!! About the only thing people compain about is the adverts show empty servers.. I myself like that option but maybe a convar at some point might be a good idea.

sishgupta 01-05-2009 21:48

Re: Server Redirect
 
Hey, im installing this on my 5 pubs and it seems to be very very good.

However, there seems to be an issue where the plugin isnt loading the plugin.serverredirect.cfg. The values are set in the cfg but when I check from console it says they are still at default.

The weird thing is it seems to work eventually, but on a freshly restarted server it doesnt work. I'm confused. There are no logs that seem to be helping to troubleshoot.

sishgupta 01-05-2009 22:31

Re: Server Redirect
 
1 Attachment(s)
I've attached the fix, all i did was add

Code:

AutoExecConfig(true, "plugin.serverredirect");
to the onpluginstart function

Kenny Loggins 01-06-2009 01:43

Re: Server Redirect
 
Nice... Ya I only had that problem on CS:S and i just added the variables to the server.cfg but this will take care of that now..

I have run a server for a long time and have seen a lot of plugins but this one if just great :) now players are aware of other server that we run where as before they may have never found out on their own..

A+ job

This is on about 18 of my servers now.

Molli 01-09-2009 23:37

Re: Server Redirect
 
:| I am sure its great plugin but installation is not for newbie...

1.
"Use database.sql to create the (mysql) database insert sample data. Once the database has been created, add your servers to the 'server' table, similar to the sample row"

what that means? :)

2.
"serverredirect"
{
"driver" "default"
"host" "127.0.0.1" <---my server ip here?
"database" "serverredirect"
"user" "username" <---? need what username?
"pass" "strongpassword" <---? need what pass?
//"timeout" "0"
//"port" "0"
}

3. its only says now:
[REDIRECT] Sorry, I was unable to determine which servers are currently available.

I know these database things might easy to others but i hate install this kind of plugins...

Antithasys 01-10-2009 02:20

Re: Server Redirect
 
Mite want to work on that directory structure of the .zip file too. Not an easy copy.

DJ Tsunami 01-10-2009 07:07

Re: Server Redirect
 
You can import database.sql in phpMyAdmin so it creates a database and tables for you. Then in sourcemod/configs/databases.cfg you put your MySQL server's ip, username and password. If you don't know how to use phpMyAdmin I'm afraid you're out of luck, maybe Brainstorm can make the plugin create the table itself.

sishgupta 01-10-2009 20:34

Re: Server Redirect
 
Quote:

Originally Posted by Molli (Post 741429)
:| I am sure its great plugin but installation is not for newbie...

1.
"Use database.sql to create the (mysql) database insert sample data. Once the database has been created, add your servers to the 'server' table, similar to the sample row"

what that means? :)

2.
"serverredirect"
{
"driver" "default"
"host" "127.0.0.1" <---my server ip here?
"database" "serverredirect"
"user" "username" <---? need what username?
"pass" "strongpassword" <---? need what pass?
//"timeout" "0"
//"port" "0"
}

3. its only says now:
[REDIRECT] Sorry, I was unable to determine which servers are currently available.

I know these database things might easy to others but i hate install this kind of plugins...

You are right, it is a very complicated plugin, as far as plugins go.
I didnt think it was very hard to install, but it did take me a good hour to get it going on my 6 public servers.

You need to have an SQL database for your server in order to use this plugin.

zerak 01-11-2009 07:48

Re: Server Redirect
 
source is missing the include file (.inc)

DJ Tsunami 01-11-2009 08:10

Re: Server Redirect
 
Do you mean that include file that's in the include folder? Although granted, it should be in scripting/include.

zerak 01-11-2009 08:12

Re: Server Redirect
 
yep that one, easy to create but I am lazy :p

SaintK 01-12-2009 09:33

Re: Server Redirect
 
Hi,

I tried to compile everything on my install (1.1) but i get presented with the following errors;

Code:

Compiling serverredirect_cmds.sp ...SourcePawn Compiler 1.1.0
Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC

serverredirect_cmds.sp(38) : error 017: undefined symbol "LIB_REDIR"
serverredirect_cmds.sp(43) : error 017: undefined symbol "LIB_REDIR"
serverredirect_cmds.sp(51) : error 017: undefined symbol "LIB_REDIR"
serverredirect_cmds.sp(61) : error 035: argument type mismatch (argument 1)
serverredirect_cmds.sp(100) : error 035: argument type mismatch (argument 1)

5 Errors.
Compiling serverredirect.sp ...SourcePawn Compiler 1.1.0


SaintK 01-12-2009 11:58

Re: Server Redirect
 
Hi,

I used the compiled file included in your download for now.

I have a request. The plugin doesn't remove the reserved slots from the maximum allowed players, so the servers now always show that they would have room availible. Would it be possible to strip the reserved slots from the total amount of slots on the server?

canuck 01-24-2009 10:21

Re: Server Redirect
 
I would like to thank brainstorm for the plugin, but I am having an issue.

I have set sm_redirect_serverid properly in all my servers. But it keeps changing to 0. I have set the values in multiple areas (server.cfg, autoexec.cfg and also the cfgs provided with the plugin). It will work if I manually set it in rcon through HLSW, but loses its ID on mapchanges.

Any help would be appreciated.


marrr 01-24-2009 11:11

Re: Server Redirect
 
I would like to use this plugin but for some reason when i import datbase.sql i get an error.

KeLcO 01-28-2009 03:59

Re: Server Redirect
 
Hi,

Same here, i get an error when im import the database.sql!

DJ Tsunami 01-28-2009 06:28

Re: Server Redirect
 
Good luck getting any help without actually posting the error.

mauirixxx 01-28-2009 17:04

Re: Server Redirect
 
the final line of the .sql script is what I assume you 2 are erroring on, as it doesn't have the final ";" to tell MySQL the script is done.

In all honesty, I didn't even use that insert statement, I just used the create table stuff and was on my way.

My question is this: I have 3 servers, on 3 different boxes. Now, should I have the "serverredirect" database info connect to a "master" mysql database, or should I have each server connect to it's own local DB, with the same info copied to each DB?

Also, when I hit F3 to accept the redirect, it directs me like it should - only when I join the new server, the redirect option is still showing, prompting me to hit F3 again. The 2nd time I accept (which redirects me to the server I already wanted to and did in fact join), the redirect window finally closes.

Thoughts?

Kenny Loggins 01-28-2009 19:29

Re: Server Redirect
 
Quote:

Originally Posted by sishgupta (Post 739097)
I've attached the fix, all i did was add

Code:

AutoExecConfig(true, "plugin.serverredirect");
to the onpluginstart function


I can't get this to compile.. Web or with compile.exe

NoNameYan 01-29-2009 01:46

Re: Server Redirect
 
great job!!

but there have some problom for this plugin..

1. SM1.2 can't compile
2. If server no people and server list will be offline
3. left 4 dead can't swap to another server (it will may it disconnect)

can you fix this problom?

thx

tcviper 01-30-2009 05:32

Re: Server Redirect
 
A Sourcebans auto integration would be handy to match server id's ;)

Also:
sm_redirect_ads_format "Also available: {NAME} | {MAP} | {CURR} ({IP}) - Say !servers to switch servers."

{MAP} and {CURR} doesnt show it just shows {MAP} and {CURR} ingame.

DJ Tsunami 01-30-2009 13:51

Re: Server Redirect
 
Seems the code is indeed missing {MAP}, {CURR} and {MAX} for advertisements. Weird, because it does have them on the GoT server.

mauirixxx 01-30-2009 14:05

Re: Server Redirect
 
It worked fine when I set it up 2 days ago to. Here's one of my entries in my database:

Code:

H^S 3v3 | {MAP} | {CURR}/{MAX}
In game it displays correctly, eg:

Code:

H^S 3v3 | de_dust | 6/14
Maybe there was a secret update or something? I dunno ....

bzz0 02-01-2009 17:04

Re: Server Redirect
 
Great plugin, but no support :( The problem with reserved slots not counting still there

Brainstorm 02-01-2009 17:56

Re: Server Redirect
 
Haven't been in this topic for a while indeed. I'll think I can fix at least some of the problems:

* Package it a little different (scripting file)
* Fix SQL script? Clarify installation.
* Reserved slots: need to see how I can obtain the amount of reserved slots and subtract them. And there are several plugins for reserved slots.
* The code for {MAP} and such should work? It's the FormatServerName() function in the code.
* Sourcebans integration: nice idea :) Need to find some info on this.
* Compile for 1.2: will check this
* L4D: I can test this as well.
* server id resetting to 0: this could happen on the first map (can fix that) or if it's set in a config file.
* Filter out empty servers and choose sort mode.

I'm not sure why the redirect window ('F3') window remains active sometimes. It is built into the client, so having to press F3 twice is likely to be impossible to fix.

DJ Tsunami 02-03-2009 07:42

Re: Server Redirect
 
3) I think all reserved slot packages use sv_visiblemaxplayers.
4) It's in FormatServerName, but not in FormatAdText. So it works for the menu, but not for the advertisements.

mauirixxx 02-03-2009 15:04

Re: Server Redirect
 
while this plugin works awesome - I have 3 server sharing the same database - I did notice the following error on startup:

Code:

[SM] Unable to load plugin "serverredirect_cmds.smx": Could not find required plugin "serverredir"
So I downloaded serverredirect.smx, renamed it to serverredir.smx, and reuploaded it - so now I have both serverredirect.smx and serverredir.smx on the game server.

That gave the following error:

Code:

[SM] Native "CreateNative" reported: Fatal error creating dynamic native!
[SM] Displaying call stack trace for plugin "serverredirect.smx":
[SM]  [0]  Line 577, E:\TF2\files\sourcemod\plugins\mine\serverredirect.sp::AskPluginLoad()
[SM] Unable to load plugin "serverredirect_cmds.smx": Could not find required plugin "serverredir"
[SM] Unable to load plugin "serverredir.smx": Could not find required plugin "serverredir"
[SM] Native "LoadServerRedirectListFiltered" reported: Plugin owning this native is currently paused.
[SM] Displaying call stack trace for plugin "serverredirect_ads.smx":
[SM]  [0]  Line 105, E:\TF2\files\sourcemod\plugins\mine\serverredirect_ads.sp::Timer_AdsUpdate()

This is being ran on a CS Source server btw, under Linux. If I do the download/rename/upload combo on the serverredirect_ads.smx - I get a segfault. :D

If I leave it the way it was, I get the first code block in my SM error logs, but as far as I can tell the plugin works.

But nobody likes errors. Help?

Brainstorm 02-03-2009 16:15

Re: Server Redirect
 
Is this on Sourcemod 1.1 or 1.2?

mauirixxx 02-03-2009 16:18

Re: Server Redirect
 
SM 1.1

sishgupta 02-03-2009 23:48

Re: Server Redirect
 
Quote:

Originally Posted by Kenny Loggins (Post 751928)
I can't get this to compile.. Web or with compile.exe

Yeah it wont compile for me either (fubar in the upload?), but if you add the line in manually it should work. This should fix the issue that people are having where the server uses serverid 0.


try this one that ive put on my own site:
http://tf2f.sishgupta.com/serverredirect.sp


and to whoever asked, i just used a new table in my sourcemod database instead of creating a new DB alltogether

also the map, curr, max variable do indeed work fine for me


All times are GMT -4. The time now is 11:54.

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