2004-02-21 19:36:35 +00:00
|
|
|
/* AMX Mod X
|
|
|
|
* Slots Reservation Plugin
|
2004-02-01 18:45:44 +00:00
|
|
|
*
|
2004-02-21 19:36:35 +00:00
|
|
|
* by the AMX Mod X Development Team
|
|
|
|
* originally developed by OLO
|
2006-01-07 00:54:40 +00:00
|
|
|
* Updated by Marticus
|
2004-02-01 18:45:44 +00:00
|
|
|
*
|
2004-02-21 19:36:35 +00:00
|
|
|
* This file is part of AMX Mod X.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the author gives permission to
|
|
|
|
* link the code of this program with the Half-Life Game Engine ("HL
|
|
|
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
|
|
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
|
|
|
* respects for all of the code used other than the HL Engine and MODs
|
|
|
|
* from Valve. If you modify this file, you may extend this exception
|
|
|
|
* to your version of the file, but you are not obligated to do so. If
|
|
|
|
* you do not wish to do so, delete this exception statement from your
|
|
|
|
* version.
|
2006-01-07 00:54:40 +00:00
|
|
|
*
|
2006-02-27 09:22:03 +00:00
|
|
|
* Changelog:
|
|
|
|
*
|
|
|
|
* Sun Feb 26 16:19:05 EST 2006 - Marticus
|
|
|
|
* -Set cvar defaults to 0 because the plugin is enabled by default
|
|
|
|
*
|
|
|
|
* Fri Feb 24 15:29:21 EST 2006 - Marticus
|
|
|
|
* -Added plugin_cfg and moved get cvars to it
|
|
|
|
* -Created global for reserved slots
|
|
|
|
* -Now checks for one or more reserved slots before attempting to hide them
|
|
|
|
* -Fixed whitespace.
|
|
|
|
*
|
|
|
|
* Thu Dec 22 12:41:25 EST 2005 - Marticus
|
|
|
|
* -Added documentation and cleaned up the code
|
|
|
|
* -Created amx_hideslots cvar to replace #define HIDE_RESERVED_SLOTS
|
|
|
|
* -Removed ackSignal *sigh* and the horribly coded setVisibleSlots function
|
|
|
|
* -Removed client disconnect
|
|
|
|
* -Created global variable gPlayerLimit to be used in both functions
|
|
|
|
* -Moved set cvar sv_visiblemaxplayers to plugin_init
|
|
|
|
* -Enjoy!
|
|
|
|
*
|
2006-01-07 00:54:40 +00:00
|
|
|
* Notes:
|
|
|
|
* sv_visiblemaxplayers is a steam cvar which hides given number of slots
|
|
|
|
* from clients. This is only useful to those who wish to have hidden reserved
|
|
|
|
* slots. With 1 reserved slot, max players 17, this cvar can be used to make
|
|
|
|
* the server appear to have only 16 available slots. The client can use the gui
|
|
|
|
* to "auto join" when a slot is available. Players who know they have access
|
|
|
|
* to that reserved slot can connect using the console command "connect".
|
|
|
|
*
|
|
|
|
* This plugin was designed to check players with reservation slots and kick
|
|
|
|
* those who do not have one. With the revised hidden slot feature, all other
|
|
|
|
* players can use their client's very useful auto join feature.
|
|
|
|
*
|
2004-02-01 18:45:44 +00:00
|
|
|
*/
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-03-05 19:35:38 +00:00
|
|
|
#include <amxmodx>
|
2004-03-07 14:30:53 +00:00
|
|
|
#include <amxmisc>
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2006-02-27 09:22:03 +00:00
|
|
|
new gPlayerLimit, gReservedSlots
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_init()
|
|
|
|
{
|
|
|
|
register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team")
|
|
|
|
register_dictionary("adminslots.txt")
|
|
|
|
register_dictionary("common.txt")
|
2006-01-07 00:54:40 +00:00
|
|
|
|
2006-02-27 09:22:03 +00:00
|
|
|
register_cvar("amx_reservation", "0")
|
2004-11-20 21:34:22 +00:00
|
|
|
|
2006-01-07 00:54:40 +00:00
|
|
|
/* Provide server admin with cvar to hide slots, 0 or 1 -Marticus */
|
2006-02-27 09:22:03 +00:00
|
|
|
register_cvar("amx_hideslots", "0")
|
|
|
|
}
|
2004-03-27 22:13:41 +00:00
|
|
|
|
2006-02-27 09:22:03 +00:00
|
|
|
public plugin_cfg()
|
|
|
|
{
|
|
|
|
/* Get configured number of reserved slots */
|
2006-03-06 15:27:30 +00:00
|
|
|
gReservedSlots = get_cvar_num("amx_reservation")
|
2006-02-27 09:22:03 +00:00
|
|
|
|
2006-01-07 00:54:40 +00:00
|
|
|
/* The maximum number of players after reserved slot(s) */
|
2006-02-27 09:22:03 +00:00
|
|
|
gPlayerLimit = get_maxplayers() - gReservedSlots
|
2006-01-07 00:54:40 +00:00
|
|
|
|
2006-02-27 09:22:03 +00:00
|
|
|
/* Set server cvar sv_visiblemaxplayers to new player limit to hide
|
|
|
|
the reserved slot(s). Do this only if there are one or more
|
|
|
|
reserved slots. */
|
|
|
|
if ( ( get_cvar_num("amx_hideslots") == 1 ) && gReservedSlots >= 1 )
|
2006-01-07 00:54:40 +00:00
|
|
|
set_cvar_num("sv_visiblemaxplayers", gPlayerLimit)
|
2004-08-03 20:11:16 +00:00
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public client_authorized(id)
|
|
|
|
{
|
2006-01-07 00:54:40 +00:00
|
|
|
new userid = get_user_userid(id)
|
|
|
|
new reason[64]
|
2006-02-27 09:22:03 +00:00
|
|
|
format(reason, 63, "[AMXX] %L", id, "DROPPED_RES")
|
2006-01-07 00:54:40 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
new players = get_playersnum(1)
|
|
|
|
|
2006-01-07 00:54:40 +00:00
|
|
|
/* Check if player took a reserved slot on a full
|
|
|
|
server and kick if they have no slot reservation */
|
|
|
|
if ((players > gPlayerLimit) && (!access(id, ADMIN_RESERVATION)))
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2006-03-13 14:35:26 +00:00
|
|
|
server_cmd("kick #%d ^"%s^"", userid, reason)
|
|
|
|
return PLUGIN_CONTINUE
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
2006-02-27 09:22:03 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
return PLUGIN_CONTINUE
|
2006-03-06 15:27:30 +00:00
|
|
|
}
|