PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cromchat>
#define PLUGIN "Long Jump"
#define VERSION "1.0"
#define AUTHOR "Alex Winchester"
new bool:g_hasLongJump[33]
new Float:g_last_LongJump_time[33]
new g_LongJump_force, g_LongJump_height, g_LongJump_cooldown
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
g_LongJump_force = register_cvar("lj_longjump_force", "550")
g_LongJump_height = register_cvar("lj_longjump_height", "255")
g_LongJump_cooldown = register_cvar("lj_longjump_cooldown", "5.0")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_event("DeathMsg", "death", "a")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
CC_SetPrefix("&x07[LJ]")
}
// Reset on disconnection
public client_disconnected(id)
{
g_hasLongJump[id] = false
}
// Reset on death
public death()
{
g_hasLongJump[read_data(2)] = false
}
// Reset at round start (for everyone)
public event_round_start()
{
for (new i = 1; i <= 32; i++)
g_hasLongJump[i] = true
}
public Player_Spawn(id)
{
if (is_user_alive(id))
{
g_hasLongJump[id] = true
CC_SendMessage(id, "&x01You have recieved a Jump Pack. To use it, press duck and jump while moving forward.")
}
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
if (allow_LongJump(id))
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
velocity[2] = get_pcvar_float(g_LongJump_height)
set_pev(id, pev_velocity, velocity)
g_last_LongJump_time[id] = get_gametime()
}
return FMRES_IGNORED
}
// Check if the player can longjump
public bool: allow_LongJump(id)
{
if (!g_hasLongJump[id])
return false;
if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
return false;
static buttons
buttons = pev(id, pev_button)
if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))
return false;
static Float:cooldown
cooldown = get_pcvar_float(g_LongJump_cooldown)
if (get_gametime() - g_last_LongJump_time[id] < cooldown)
{
CC_SendMessage(id, "&x01Please wait &x07%i &x01seconds to do &x07leap &x01again!")
return false;
}
if(g_last_LongJump_time[id] == cooldown)
{
CC_SendMessage(id, "&x01Now you can do &x07leap &x01again!")
}
return true;
}
// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity));
}