/*
			Half Life Leap
	
	
	Description : 
	
			This is usual half life's leap. It will be for free for those who like fun servers.
			Leap will be reset on Death or new round.
			
	
	
	Cvars :
	
			None
			
		
	
	Commands :
	
			say /leap - to get leap
			
	
	
	Changelog :
	
			23/01/2009 - v0.1 - First release

*/

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "Half-Life Leap"
#define VERSION "0.1"
#define AUTHOR "Fry!"

#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

new bool:g_hasLeap[33]

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /leap", "give_leap")
	
	register_event("DeathMsg", "death", "a")
	
}

public client_connect(id)
{
	g_hasLeap[id] = false
}

public client_disconnect(id)
{
	g_hasLeap[id] = false
}

public death()
{
	g_hasLeap[read_data(2)] = false
}

public give_leap(id)
{
	if (!is_user_alive(id))
		return PLUGIN_HANDLED
		
	if ( g_hasLeap[id] )
	{
		client_print(id, print_chat, "[AMXX] You already have Leap")
		return PLUGIN_HANDLED
	}
	
	fm_give_item(id, "item_longjump")
	
	return PLUGIN_CONTINUE
}

stock fm_give_item(index, const item[]) 
{
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
		return 0;

	new ent = fm_create_entity(item);
	if (!pev_valid(ent))
		return 0;

	new Float:origin[3];
	pev(index, pev_origin, origin);
	set_pev(ent, pev_origin, origin);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);

	new save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, index);
	if (pev(ent, pev_solid) != save)
		return ent;

	engfunc(EngFunc_RemoveEntity, ent);

	return -1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
