Пользователь
- Сообщения
- 33
- Реакции
- 0
#include amxmodx
#include engine
#include reapi
#define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2) %1 |= (1 << (%2 & 31))
#define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31))
#define FALL_SPEED 65 // На сколько процентов замедлить падение
#define PARACHUTE_MDL "models/p_longjump.mdl" // Модель парашюта
new g_bitAlive, g_MdlIndex, g_Ent[33];
public plugin_init()
{
register_plugin("Parachute Lite [ReAPI]", "14.0 (edit)", "Leo_[BH]");
RegisterHookChain(RG_CBasePlayer_Spawn, "RG_Spawn_Post", 1);
RegisterHookChain(RG_CBasePlayer_Killed, "RG_Player_Killed", 1);
RegisterHookChain(RG_PM_AirMove, "PM_AirMove");
}
public plugin_precache()
{
g_MdlIndex = precache_model(PARACHUTE_MDL);
}
public client_disconnected(id)
{
clr_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
public RG_Spawn_Post(id)
{
if(is_user_alive(id))
{
set_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
}
public RG_Player_Killed(id)
{
clr_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
public PM_AirMove(id)
{
if(!get_bit(g_bitAlive, id))
return;
if(get_entvar(id, EntVars:var_button) & IN_USE)
{
static Float:velocity[3];
get_entvar(id, var_velocity, velocity);
if(velocity[2] < 0.0)
{
velocity[2] = (velocity[2] + 40.0 < -FALL_SPEED.0) ? velocity[2] + 40.0 : -FALL_SPEED.0;
set_pmove(pm_velocity, velocity);
set_entvar(id, var_sequence, ACT_WALK);
set_entvar(id, var_gaitsequence, ACT_IDLE);
if(!g_Ent[id])
{
g_Ent[id] = rg_create_entity("info_target");
set_entvar(g_Ent[id], var_modelindex, g_MdlIndex);
set_entvar(g_Ent[id], var_movetype, MOVETYPE_FOLLOW);
set_entvar(g_Ent[id], var_aiment, id);
}
}
}
else //if(get_entvar(id, EntVars:var_oldbuttons) & IN_USE)
{
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
}
#include amxmodx
#include engine
#include reapi
#define get_bit(%1,%2) (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2) %1 |= (1 << (%2 & 31))
#define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31))
#define FALL_SPEED 65 // На сколько процентов замедлить падение
#define PARACHUTE_MDL "models/p_longjump.mdl" // Модель парашюта
new g_bitAlive, g_MdlIndex, g_Ent[33];
public plugin_init()
{
register_plugin("Parachute Lite [ReAPI]", "14.0 (edit)", "Leo_[BH]");
RegisterHookChain(RG_CBasePlayer_Spawn, "RG_Spawn_Post", 1);
RegisterHookChain(RG_CBasePlayer_Killed, "RG_Player_Killed", 1);
RegisterHookChain(RG_CBasePlayer_PreThink, "RG_client_PreThink");
}
public plugin_precache()
{
g_MdlIndex = precache_model(PARACHUTE_MDL);
}
public client_disconnected(id)
{
clr_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
public RG_Spawn_Post(id)
{
if(is_user_alive(id))
{
set_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
}
public RG_Player_Killed(id)
{
clr_bit(g_bitAlive, id);
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
public RG_client_PreThink(id)
{
if(!get_bit(g_bitAlive, id))
return;
if(get_entvar(id, var_button) & IN_USE)
{
static Float:velocity[3];
get_entvar(id, var_velocity, velocity);
if(velocity[2] < 0.0)
{
velocity[2] = (velocity[2] + 40.0 < -FALL_SPEED.0) ? velocity[2] + 40.0 : -FALL_SPEED.0;
set_entvar(id, var_velocity, velocity);
set_entvar(id, var_sequence, ACT_WALK);
set_entvar(id, var_gaitsequence, ACT_IDLE);
if(!g_Ent[id])
{
g_Ent[id] = rg_create_entity("info_target");
set_entvar(g_Ent[id], var_modelindex, g_MdlIndex);
set_entvar(g_Ent[id], var_movetype, MOVETYPE_FOLLOW);
set_entvar(g_Ent[id], var_aiment, id);
}
}
}
else if(get_entvar(id, var_oldbuttons) & IN_USE)
{
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
if(get_entvar(id, var_flags) & FL_ONGROUND)
{
if(g_Ent[id])
{
remove_entity(g_Ent[id]);
g_Ent[id] = 0;
}
}
}