
/* AMX Mod script.
*
* [SN*INFO] Redirection Plugin for AMX 0.5 by sonic (sonic@codet.de)
*
* (c) Copyright 2002, sonic
* This file is provided as is (no warranties).
*
*/

/*  put in server.cfg:
*
*	sn_re_pwfield < _re >         - setinfo pwfield name
*   sn_re_adminpw < password >    - bypass the redirection with this password
*   sn_re_maxppl < 19 >           - begin redirection when more the x ppl connected
*   sn_re_ip < IP:PORT >          - redirect to this server
*
*   default adminpw is "dontmoveme"  - setinfo "_re" "dontmoveme" on client config.cfg
*/

#include <amxmod>

public client_connect(id){
	new rr_maxppl = get_cvar_num("sn_re_maxppl")
	new rr_ip[64], rr_pwfield[32], rr_adminpw[32], pInfoPW[32]
	get_cvar_string("sn_re_ip",rr_ip,64)
	get_cvar_string("sn_re_pwfield",rr_pwfield,32)
	get_cvar_string("sn_re_adminpw",rr_adminpw,32)
	get_user_info(id,rr_pwfield,pInfoPW,32)
	if ( get_playersnum() >= rr_maxppl && !equal(rr_adminpw,pInfoPW) ) {
		client_cmd(id,"echo ^"Redirecting to %s^";connect %s",rr_ip,rr_ip)
	}
	return PLUGIN_CONTINUE
}

public plugin_init() {
	register_plugin("SN*Redirect","0.5","sonic@codet.de")
	register_cvar("sn_re_adminpw","dontmoveme")
	register_cvar("sn_re_pwfield","_re")
	register_cvar("sn_re_ip","")
	register_cvar("sn_re_maxppl","19")
	return PLUGIN_CONTINUE
}

