#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <zombieplague>

#define PLUGIN "[CSO:Zombies No Choisshair]"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r"

new HideWeapon, humanize[33], g_maxplayers

enum (+= 100)
{
	TASK_NOCROSS
}

#define ID_NOCROSS (taskid - TASK_NOCROSS)

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)	
	
	HideWeapon = get_user_msgid("HideWeapon")
	RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	
	g_maxplayers = get_maxplayers()
}

public fw_PlayerSpawn_Post(id)
{
	if(!zp_get_user_zombie(id) && humanize[id])
	{
		remove_task(id+TASK_NOCROSS)
		message_begin(MSG_ONE_UNRELIABLE, HideWeapon, _, id)
		write_byte(1>>6)
		message_end()
	}
}

public fw_PlayerKilled(victim, attacker, shouldgib)
{
	remove_task(victim+TASK_NOCROSS)
	message_begin(MSG_ONE_UNRELIABLE, HideWeapon, _, victim)
	write_byte(1>>6)
	message_end()
}

public zp_user_infected_post(id, infector, nemesis)
{
	set_task(0.00000000000000000000000000000000000000000000000000001, "bugfix", id+TASK_NOCROSS, _, _, "b")
	humanize[id] = true;
	message_begin(MSG_ONE_UNRELIABLE, HideWeapon, _, id)
	write_byte(1<<6)
	message_end()
	set_task(5.0, "ForMinLags", id+TASK_NOCROSS)
}

public zp_user_humanized_post(id, survivor)
{
	remove_task(id+TASK_NOCROSS)
	message_begin(MSG_ONE_UNRELIABLE, HideWeapon, _, id)
	write_byte(1>>6)
	message_end()
}

public bugfix(taskid)
{
	static id
	(taskid > g_maxplayers) ? (id = ID_NOCROSS) : (id = taskid);
	
	humanize[id] = true;
	message_begin(MSG_ONE_UNRELIABLE, HideWeapon, _, id)
	write_byte(1<<6)
	message_end()
}

public ForMinLags(taskid)
{
	static id
	(taskid > g_maxplayers) ? (id = ID_NOCROSS) : (id = taskid);
	
	remove_task(id+TASK_NOCROSS)
}