#include <amxmodx>
#include <reapi>
new pFallSpeed;
new bool:g_is_alive[33];
public plugin_init()
{
register_plugin("Parachute for All [ReAPI]", "3.0", "Leo_[BH] & SWAT");
pFallSpeed = register_cvar("sv_parachute_speed", "70");
RegisterHookChain(RG_CBasePlayer_PreThink, "RG_client_PreThink", true);
RegisterHookChain(RG_CBasePlayer_Killed, "RG_Player_Killed", false);
RegisterHookChain(RG_CBasePlayer_Spawn, "RG_Spawn_Post", true);
}
public client_disconnected(id)
{
g_is_alive[id] = false;
}
public RG_Spawn_Post(id)
{
if(is_user_alive(id))
{
g_is_alive[id] = true;
}
}
public RG_Player_Killed(victim, attacker)
{
g_is_alive[victim] = false;
}
public RG_client_PreThink(id)
{
if(!g_is_alive[id]) return;
static button; button = get_entvar(id, EntVars:var_button);
static oldbutton; oldbutton = get_entvar(id, EntVars:var_oldbuttons);
static Float:fallspeed; fallspeed = get_pcvar_num(pFallSpeed) * -1.0;
if(get_entvar(id, EntVars:var_gravity) == 0.1) set_entvar(id, EntVars:var_gravity, 1.0);
if(button & IN_USE)
{
static Float:velocity[3]
get_entvar(id, EntVars:var_velocity, velocity);
if (velocity[2] < 0.0)
{
set_entvar(id, EntVars:var_sequence, 3);
set_entvar(id, EntVars:var_gaitsequence, 1);
set_entvar(id, EntVars:var_frame, 1.0);
set_entvar(id, EntVars:var_framerate, 1.0);
set_entvar(id, EntVars:EntVars:var_gravity, 0.1);
velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed;
set_entvar(id, EntVars:var_velocity, velocity);
}
}
else if((oldbutton & IN_USE))
{
set_entvar(id, EntVars:var_gravity, 1.0);
}
}