Kod:
#include <amxmodx>
#include <engine>
#include <reapi>
new const sz_model[] = "models/parasutnew3.mdl";
new g_ent[33], bool:g_alive[33], Float:g_gravity[33];
new sv_parachute, team;
public plugin_init() {
register_plugin("ReParachute", "1.0", "PurposeLess");
RegisterHookChain(RG_CBasePlayer_PreThink, "CBasePlayer_PreThink");
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", .post=true);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", .post=true);
bind_pcvar_num(create_cvar("sv_parachute", "1", _, _, true, 0.0, true, 1.0), sv_parachute);
team = register_cvar("sv_parachute_team", "0");
}
public plugin_precache()
{
precache_model(sz_model);
}
public CBasePlayer_Spawn(const id)
{
if(is_user_alive(id))
{
if(itsok(id))
{
g_alive[id] = true;
}
g_gravity[id] = 1.0;
}
}
itsok(const id)
{
new pcvar = get_pcvar_num(team);
switch(pcvar)
{
case 1: {
if(get_member(id, m_iTeam) == TEAM_TERRORIST)
{
return true;
}
}
case 2: {
if(get_member(id, m_iTeam) == TEAM_CT)
{
return true;
}
}
default:{
return true;
}
}
return false;
}
public CBasePlayer_Killed(const victim, const attacker)
{
#pragma unused attacker
g_alive[victim] = false;
if(g_ent[victim] > 0)
{
remove_entity(g_ent[victim]);
g_ent[victim] = 0;
}
}
public client_putinserver(id)
{
g_gravity[id] = 1.0;
}
public client_disconnected(id)
{
g_alive[id] = false;
if(g_ent[id] > 0)
{
remove_entity(g_ent[id]);
g_ent[id] = 0;
}
}
public CBasePlayer_PreThink(const id)
{
if(!(sv_parachute && g_alive[id]))
{
return HC_CONTINUE;
}
static Float:frame;
static flags; flags = get_entvar(id, var_flags);
static button; button = get_entvar(id, var_button);
static oldbuttons; oldbuttons = get_entvar(id, var_oldbuttons);
static Float:gravity; gravity = get_entvar(id, var_gravity);
if(g_ent[id] > 0 && (flags & FL_ONGROUND))
{
if(entity_get_int(g_ent[id], EV_INT_sequence) != 2)
{
entity_set_int(g_ent[id], EV_INT_sequence, 2);
entity_set_int(g_ent[id], EV_INT_gaitsequence, 1);
entity_set_float(g_ent[id], EV_FL_frame, 0.0);
entity_set_float(g_ent[id], EV_FL_fuser1, 0.0);
entity_set_float(g_ent[id], EV_FL_animtime, 0.0);
entity_set_float(g_ent[id], EV_FL_framerate, 0.0);
return HC_CONTINUE;
}
frame = entity_get_float(g_ent[id], EV_FL_fuser1) + 2.0;
entity_set_float(g_ent[id], EV_FL_fuser1, frame);
entity_set_float(g_ent[id], EV_FL_frame, frame);
if(frame > 254.0)
{
remove_entity(g_ent[id]);
g_ent[id] = 0;
}
}
//forum.csduragi.com
if(gravity == 0.1)
{
set_entvar(id, var_gravity, g_gravity[id]);
}
else
{
g_gravity[id] = get_entvar(id, var_gravity);
}
if(button & IN_USE)
{
static Float:velocity[3];
get_entvar(id, var_velocity, velocity);
if(velocity[2] < 0.0)
{
if(g_ent[id] < 1)
{
g_ent[id] = create_entity("info_target");
if(g_ent[id] > 0)
{
entity_set_string(g_ent[id], EV_SZ_model, sz_model);
entity_set_string(g_ent[id], EV_SZ_classname, "parachute");
entity_set_edict(g_ent[id], EV_ENT_aiment, id);
entity_set_edict(g_ent[id], EV_ENT_owner, id);
entity_set_int(g_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW);
entity_set_int(g_ent[id], EV_INT_sequence, 0);
entity_set_int(g_ent[id], EV_INT_gaitsequence, 1);
entity_set_float(g_ent[id], EV_FL_frame, 0.0);
entity_set_float(g_ent[id], EV_FL_fuser1, 0.0);
}
}
else if(g_ent[id] > 0)
{
velocity[2] = (velocity[2] + 40.0 < -100.0) ? velocity[2] + 40.0 : -100.0;
set_entvar(id, var_gravity, 0.1);
set_entvar(id, var_velocity, velocity);
set_entvar(id, var_sequence, 3);
set_entvar(id, var_gaitsequence, 1);
set_entvar(id, var_frame, 1.0);
set_entvar(id, var_framerate, 1.0);
if(entity_get_int(g_ent[id], EV_INT_sequence) == 0)
{
frame = entity_get_float(g_ent[id], EV_FL_fuser1) + 1.0;
entity_set_float(g_ent[id], EV_FL_fuser1, frame);
entity_set_float(g_ent[id], EV_FL_frame, frame);
if(frame > 100.0)
{
entity_set_int(g_ent[id], EV_INT_sequence, 1);
entity_set_int(g_ent[id], EV_INT_gaitsequence, 1);
entity_set_float(g_ent[id], EV_FL_frame, 0.0);
entity_set_float(g_ent[id], EV_FL_fuser1, 0.0);
entity_set_float(g_ent[id], EV_FL_animtime, 0.0);
entity_set_float(g_ent[id], EV_FL_framerate, 0.4);
}
}
}
}
else if(g_ent[id] > 0)
{
set_entvar(id, var_gravity, g_gravity[id]);
remove_entity(g_ent[id]);
g_ent[id] = 0;
}
}
else if(oldbuttons & IN_USE && g_ent[id] > 0)
{
set_entvar(id, var_gravity, g_gravity[id]);
remove_entity(g_ent[id]);
g_ent[id] = 0;
}
return HC_CONTINUE;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/