#include <amxmodx>
#include <amxmisc>
#include <halomod>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "HaloMod StickNades"
#define VERSION HALOVERSION
#define AUTHOR "Soccdoodcss"

new pOn

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	RegisterHam(Ham_Touch, "grenade", "onTouch")
	
	pOn = register_cvar("halo_stickynades", "1", FCVAR_SERVER)
}

public onTouch(nade, id)
{
	if(is_user_alive(id))
	{
		new model[33]
		
		pev(nade, pev_model, model, 32)
		
		if((!equal(model, "models/w_hegrenade.mdl") &&
		!equal(model, "models/w_hegrenade_halo.mdl")) ||
		!get_pcvar_num(pOn) ||
		!is_halo_on())
		return HAM_HANDLED
		
		set_pev(nade, pev_aiment, id)
		set_pev(nade, pev_movetype, MOVETYPE_FOLLOW)
		set_pev(nade, pev_sequence, 0)
	}
	return HAM_HANDLED
}
