#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <zombieplague>

#define PLUGIN "[ZP] Armor Free"
#define VERSION "0.2"
#define AUTHOR "tii" 

//pcvar
new armor_value
 
public plugin_init() 
{
       register_plugin(PLUGIN, VERSION, AUTHOR)
       register_event("ResetHUD", "playerSpawn", "be") 
       armor_value = register_cvar("zp_armor", "200")

}

public playerSpawn(id)
{
       set_task(2.0, "shield", id)
}

public shield(id)
{
       if(is_user_alive(id) && !zp_get_user_zombie(id))
       set_user_armor(id,get_pcvar_num(armor_value))
       zp_colored_print(id, "^x04[ZP]^x01 You Now Have Armor")
}  

// Colored Print (zp_colored_print)
stock zp_colored_print(target, const message[], any:...)
{
	static g_msgSayText, maxplayers;
	if ( !g_msgSayText )
		g_msgSayText = get_user_msgid("SayText")
		
	if ( !maxplayers )
		maxplayers = get_maxplayers();
	
	static buffer[512], i, argscount;
	argscount = numargs();
	
	// Send to everyone
	if (!target)
	{
		static player;
		for (player = 1; player <= maxplayers; player++)
		{
			// Not connected
			if (!is_user_connected(player))
				continue;
			
			// Remember changed arguments
			static changed[5], changedcount; // [5] = max LANG_PLAYER occurencies
			changedcount = 0;
			
			// Replace LANG_PLAYER with player id
			for (i = 2; i < argscount; i++)
			{
				if (getarg(i) == LANG_PLAYER)
				{
					setarg(i, 0, player);
					changed[changedcount] = i;
					changedcount++;
				}
			}
			
			// Format message for player
			vformat(buffer, sizeof buffer - 1, message, 3);
			
			// Send it
			message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player);
			write_byte(player);
			write_string(buffer);
			message_end();
			
			// Replace back player id's with LANG_PLAYER
			for (i = 0; i < changedcount; i++)
				setarg(changed[i], 0, LANG_PLAYER);
		}
	}
	
	// Send to specific target
	else
	{
		// Format message for player
		vformat(buffer, sizeof buffer - 1, message, 3);
		
		// Send it
		message_begin(MSG_ONE, g_msgSayText, _, target);
		write_byte(target);
		write_string(buffer);
		message_end();
	}
}