#include <amxmodx>
#include <engine>
#include <reapi>
new g_ForAll, g_szFlagParachute[32], pFallSpeed = 100
new cvar_for_all, cvar_flag, cvar_fall_speed
new bool:g_is_alive[33]
new bool:g_has_parachute[33]
public plugin_init()
{
register_plugin("Parachute [ReAPI]", "2.0", "Leo_[BH]")
cvar_for_all = register_cvar("parachute_all", "1")
cvar_flag = register_cvar("parachute_flag", "t")
cvar_fall_speed = register_cvar("parachute_fall_speed", "100")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
RegisterHookChain(RG_CBasePlayer_Spawn, "RG_Spawn_Post", 1);
RegisterHookChain(RG_CBasePlayer_Killed, "RG_Player_Killed", 0);
RegisterHookChain(RG_CBasePlayer_PreThink, "RG_client_PreThink");
}
public plugin_cfg()
{
server_cmd("exec addons/amxmodx/configs/parachute.cfg")
}
public event_round_start()
{
g_ForAll = get_pcvar_num(cvar_for_all)
pFallSpeed = get_pcvar_num(cvar_fall_speed)
get_pcvar_string(cvar_flag, g_szFlagParachute, 31)
}
public RG_client_PreThink(id)
{
if(!g_is_alive[id]) return;
if(!g_has_parachute[id]) return;
new Float:fallspeed = pFallSpeed * -1.0
new button = get_entvar(id, EntVars:var_button);
new oldbutton = get_entvar(id, EntVars:var_oldbuttons);
if (get_entvar(id, EntVars:var_gravity) == 0.1) set_entvar(id, EntVars:var_gravity, 1.0)
if (button & IN_USE)
{
new Float:velocity[3]
entity_get_vector(id, EV_VEC_velocity, velocity)
if (velocity[2] < 0.0)
{
set_entvar(id, EntVars:var_gravity, 0.1)
velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed
entity_set_vector(id, EV_VEC_velocity, velocity)
}
}
else if ((oldbutton & IN_USE))
{
set_entvar(id, EntVars:var_gravity, 1.0)
}
}
public client_putinserver(id)
{
recheck_flags(id)
}
public client_disconnect(id)
{
g_is_alive[id] = false
g_has_parachute[id] = false
}
public RG_Spawn_Post(id)
{
if(is_user_alive(id))
{
g_is_alive[id] = true
}
recheck_flags(id)
}
public RG_Player_Killed(victim, attacker)
{
g_is_alive[victim] = false
}
public recheck_flags(id)
{
if(g_ForAll)
{
g_has_parachute[id] = true
}
else
{
if(access_parachute(id))
{
g_has_parachute[id] = true
}
else
{
g_has_parachute[id] = false
}
}
}
stock bool:access_parachute(id)
{
new flags, u_flags[32]
flags = get_user_flags(id)
get_flags(flags, u_flags, 31)
return (containi(u_flags,g_szFlagParachute) != -1) ? true : false;
}