Just tested fastly a code. I hope you won't hate me. This code is enough to spawn and be able to touch an healthkit. No need to use FM_Touch, nor testing about the health or giving the item. By spawning this entity, the engine does what it needs.
Code:
#include <amxmodx>
#include <fakemeta>
new const gs_HealthKitClassname[] = "item_healthkit";
new gi_HealthKit;
public plugin_precache ()
{
precache_model ( "models/w_medkit.mdl" ); // --| Wolrd model.
precache_sound ( "items/smallmedkit1.wav" ); // --| Sound played on touch.
}
public plugin_init ()
{
register_event ( "DeathMsg", "Event_PlayerKilled", "a" );
gi_HealthKit = engfunc ( EngFunc_AllocString, gs_HealthKitClassname )
}
public Event_PlayerKilled ()
{
// --| Initialize variables.
static Float:vf_Origin[ 3 ], i_Healthkit;
// --| Get the victim's index. / Retrieve the current victim's origin.
pev ( read_data ( 2 ), pev_origin, vf_Origin );
// --| Create our health kit.
if ( ( i_Healthkit = engfunc ( EngFunc_CreateNamedEntity, gi_HealthKit ) ) )
{
// --| Set the entity to the current player's origin and spawn it!
set_pev ( i_Healthkit, pev_origin, vf_Origin );
dllfunc ( DLLFunc_Spawn, i_Healthkit );
}
}
Now, if you still want to add a screenfade, I recommend to use Ham_Touch. But I don't think it's really need since a sound is provided. Just my opinion.
__________________