/*
*
* AMX Mod X script
* wp_glow v1.1b
* Copyright 2008, Radiance
* This file is provided as is (no warranties)
*
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_MaxClients,mode,red,green=255,blue

public plugin_init()
{
	register_plugin("wp_glow","1.1b","Radiance")
	register_concmd("amx_wpglow_mode","cmd_wpglow_mode",ADMIN_LEVEL_A,"<0|1|2|3>")
	register_concmd("amx_wpglow_color","cmd_wpglow_color",ADMIN_LEVEL_A,"<red> <green> <blue>")
	register_forward(FM_SetModel,"fw_model")
}

public plugin_cfg()
{
	g_MaxClients=global_get(glb_maxClients)
}

public cmd_wpglow_mode(id,level,cid)
{
	if(!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED
	new arg[2]
	read_argv(1,arg,1)
	mode=str_to_num(arg)
	switch(mode)
	{
		case 0:client_print(id,print_console,"[AMXX] Weapon glow mode set to <disabed>.")
		case 1:client_print(id,print_console,"[AMXX] Weapon glow mode set to <team mode>.")
		case 2:client_print(id,print_console,"[AMXX] Weapon glow mode set to <random mode>.")
		case 3:client_print(id,print_console,"[AMXX] Weapon glow mode set to <custom color>.Use amx_wpglow_color.")
	}
	return PLUGIN_CONTINUE
}

public cmd_wpglow_color(id,level,cid)
{
	if(!cmd_access(id,level,cid,4))
		return PLUGIN_HANDLED
	if(mode!=3)
	{
		client_print(id,print_console,"[AMXX] <custom color> mode not enabled.")
	}
	new arg[4],arg2[4],arg3[4]
	read_argv(1,arg,3)
	read_argv(2,arg2,3)
	read_argv(3,arg3,3)
	red=clamp(str_to_num(arg),1,255);
	green=clamp(str_to_num(arg2),1,255);
	blue=clamp(str_to_num(arg3),1,255);
	return PLUGIN_CONTINUE
}

public fw_model(ent)
{
	if(!pev_valid(ent))
		return FMRES_IGNORED
	static id
	id=pev(ent,pev_owner)
	if(!(1<=id<=g_MaxClients))
		return FMRES_IGNORED
	switch(mode)
	{
		case 0:return FMRES_IGNORED
		case 1:
		{
			switch(get_user_team(id))
			{
				case 1:fm_set_rendering(ent,kRenderFxGlowShell,255,0,0,kRenderNormal,16)
				case 2:fm_set_rendering(ent,kRenderFxGlowShell,0,0,255,kRenderNormal,16)
			}
		}
		case 2:fm_set_rendering(ent,kRenderFxGlowShell,random_num(1,255),random_num(1,255),random_num(1,255),kRenderNormal,16)
		case 3:
		{
			fm_set_rendering(ent,kRenderFxGlowShell,red,green,blue,kRenderNormal,16)
		}
	}
	return FMRES_IGNORED
}

fm_set_rendering(ent,fx=kRenderFxNone,r=0,g=0,b=0,mode=kRenderNormal,amount=16)
{
	static Float:RenderColor[3] 
	RenderColor[0]=float(r)
	RenderColor[1]=float(g)
	RenderColor[2]=float(b)
	set_pev(ent,pev_renderfx,fx)
	set_pev(ent,pev_rendercolor,RenderColor)
	set_pev(ent,pev_rendermode,mode)
	set_pev(ent,pev_renderamt,float(amount))
}
