/* AMX Mod script.
*
* Autocam by Bolchevique
* This file is provided as is (no warranties).
*
*  This plugin set the mp_forcechasecam to "2" if
*  there players on-lan (same ip)
*  thx to Rav, PsychoGuard and karma_k
*/

#include <amxmod>

public auto_cam(){
	new players[32], pnum
	new i, j, lan
	new ips[32][16]

	get_players(players, pnum);
	//array of ips
	for(i = 0; i < pnum; ++i){
		get_user_ip(players[i],ips[i],16,1);
	}

	for(i = 0; i < pnum;i++){
		for(j=i+1;j<=pnum;j++){
			if (equal(ips[i],ips[j])){
				lan = 1;
				break;break
			}
		}
	}
	//set the mp_forcechasecam to 0 or 2
	if (lan == 0)
	set_cvar_num("mp_forcechasecam",0)
	else
	set_cvar_num("mp_forcechasecam",2)
	return PLUGIN_CONTINUE
}
public client_putinserver(id){
	auto_cam()
}
public client_disconnect(id){
	auto_cam()
}
public plugin_init() {
	register_plugin("Auto forcechasecam","0.6","Bolchevique")
	return PLUGIN_CONTINUE
}
