Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
new bool:g_alive[33];
new bool:g_was_on_ground[33];
new bool:g_falling[33];
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);
RegisterHam(Ham_Killed, "player", "FwdPlayerDeath", 1);
RegisterHam(Ham_Player_PreThink, "player", "FwdPlayerPreThink");
}
public client_disconnect(client)
{
g_alive[client] = false;
}
public FwdPlayerSpawn(client)
{
if( is_user_alive(client) )
{
g_alive[client] = true;
g_falling[client] = false;
}
}
public FwdPlayerDeath(client)
{
g_alive[client] = false;
}
public FwdPlayerPreThink(client)
{
if( !g_alive[client] ) return;
if( g_falling[client] && pev(client, pev_movetype) != MOVETYPE_WALK )
{
g_falling[client] = false;
}
static Float:fall_origin[33][3];
new bool:on_ground = bool:(pev(client, pev_flags) & FL_ONGROUND);
if( on_ground && !g_was_on_ground[client] && g_falling[client] )
{
static Float:origin[3];
pev(client, pev_origin, origin);
new Float:distance = fall_origin[client][2] - origin[2];
if( distance > 0.0 )
{
client_print(client, print_chat, "You fell %f units!", distance);
}
}
else if( !on_ground && g_was_on_ground[client] )
{
g_falling[client] = true;
pev(client, pev_origin, fall_origin[client]);
}
g_was_on_ground[client] = on_ground;
}
__________________