Try..
PHP Code:
/*
[ZP] Extra Item : Leap
(For Zombies Only)
by Fry!
Description :
Do you want leap further? Now You can, for zombies are one special ability "Leap".
It's now possible to upgrade your current leap to more stronger force, meanwhile it's possible
upgrade to 1st level...
Cvars :
zp_leap_cost "9" - How much it costs.
zp_leap_force "550" - How far zombie will jump
zp_leap_height "255" - How high zombie will jump
zp_leap_cooldown "5.0" - How long cooldown will be before you can use long jump again
Chat commands :
say leap - to buy it via chat
Credits :
Locks - for his Long Jump Plugin
bmann_420 - for helping again ^^
Mercylezz - for helping me with delay (thanks to him fixed one error and converted to fakemeta)
Changelog :
20/09/2008 - v1.0 - first release
25/09/2008 - v1.1 - fixed that plugin not working only ammo packs waste.
27/09/2008 - v1.2 - fixed that when have bought a jump pack it show to all players.
04/10/2008 - v1.3 - added delay between long jump, force and height.
08/10/2008 - v1.4 - fixed delay not working between jumps.
12/10/2008 - v1.5 - fixed this last error and converted all to fakemeta
15/11/2008 - v1.5.3 - added cvar how much it will cost, optimized code, changed plugin name.
20/02/2009 - v1.5.7 - removed toggle cvar, changed chat function, changed plugin name, optimized code.
15/09/2009 - v1.5.8 -
- Fixed : Cooldown, could waste ammo packs if you already had leap.
- Changed : removed comments, chat command to ' leap '.
- Added : Upgraded version for leap and hud message for leap to see how far you can jump.
26/12/2009 - v1.5.8 - Updated @ web (To remind myself)
*/
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#define PLUGIN "[ZP] Extra Item : Leap"
#define VERSION "1.5.8"
#define AUTHOR "Fry!"
new g_item_name[] = "Leap Pack"
new g_item_name2[] = "Leap Upgrade"
new g_itemid_leap, g_itemid_leap_upgrade, g_leap_cost, g_leap_force, g_leap_height, g_leap_cooldown
new bool:g_hasLeap[33], bool:g_hasLeapUpgrade[33]
new Float:g_last_Leap[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("zp_extra_leap",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
g_leap_cost = register_cvar("zp_leap_cost", "9")
g_leap_force = register_cvar("zp_leap_force", "550")
g_leap_height = register_cvar("zp_leap_height", "255")
g_leap_cooldown = register_cvar("zp_leap_cooldown", "5.0")
g_itemid_leap = zp_register_extra_item(g_item_name, get_pcvar_num(g_leap_cost), ZP_TEAM_HUMAN)
g_itemid_leap_upgrade = zp_register_extra_item(g_item_name2, get_pcvar_num(g_leap_cost) * 2, ZP_TEAM_HUMAN)
register_clcmd("say leap", "buy_leap")
register_event("DeathMsg", "death", "a")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_PlayerPostThink, "fw_PlayerPostThink", 1)
}
public client_connect(id)
{
g_hasLeap[id] = false
g_hasLeapUpgrade[id] = false
}
public client_disconnect(id)
{
g_hasLeap[id] = false
g_hasLeapUpgrade[id] = false
}
public death()
{
g_hasLeap[read_data(2)] = false
}
public zp_user_humanized_post(id)
{
g_hasLeap[id] = false
g_hasLeapUpgrade[id] = false
}
public event_round_start()
{
for (new i = 1; i <= 32; i++)
{
g_hasLeap[i] = false
g_hasLeapUpgrade[i] = false
}
}
public zp_extra_item_selected(player, itemid)
{
if (g_hasLeap[player] && g_hasLeapUpgrade[player])
{
zp_set_user_ammo_packs(player, zp_get_user_ammo_packs(player) + get_pcvar_num(g_leap_cost))
client_print(player, print_center, "[ZP] You already has Upgraded Leap!")
return PLUGIN_HANDLED
}
if (itemid == g_itemid_leap)
{
g_hasLeap[player] = true
g_hasLeapUpgrade[player] = false
show_leap_status(player)
client_print(player, print_chat,"[ZP] You have bought a Jump Pack. To use it, press duck and jump while moving forward.")
}
if (itemid == g_itemid_leap_upgrade)
{
g_hasLeap[player] = false
g_hasLeapUpgrade[player] = true
//show_leap_status(player)
client_print(player, print_chat, "[ZP] You just Upgraded your Leap")
}
return PLUGIN_HANDLED
}
public buy_leap(id)
{
if (g_hasLeap[id])
{
client_print(id, print_chat, "[ZP] You have already purchased a leap.")
return PLUGIN_HANDLED
}
if (!is_user_alive(id))
{
client_print(id, print_chat, "[ZP] You can't buy Jump Pack because You are dead.")
return PLUGIN_HANDLED
}
if (zp_get_user_zombie(id))
{
client_print(id, print_chat, "[ZP] You can't buy Jump Pack because You are not a human.")
return PLUGIN_HANDLED
}
new money = zp_get_user_ammo_packs(id)
new cost = get_pcvar_num(g_leap_cost)
if (money < cost)
{
client_print(id, print_chat, "[ZP] You don't have enough ammo packs to buy a jumppack. (%i needed).", cost)
return PLUGIN_HANDLED
}
g_hasLeap[id] = true
g_hasLeapUpgrade[id] = false
zp_set_user_ammo_packs(id, money - cost)
show_leap_status(id)
client_print(id, print_chat, "[ZP] You have bought a Jump Pack. To use it, press duck and jump while moving forward.")
return PLUGIN_HANDLED
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
if (allow_LongJump(id))
{
if (g_hasLeap[id])
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_leap_force), velocity)
velocity[2] = get_pcvar_float(g_leap_height)
set_pev(id, pev_velocity, velocity)
g_last_Leap[id] = get_gametime()
}
}
return FMRES_IGNORED
}
public fw_PlayerPostThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
if (allow_LongJump(id))
{
if (g_hasLeapUpgrade[id])
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_leap_force) + 125, velocity)
velocity[2] = get_pcvar_float(g_leap_height) + 65
set_pev(id, pev_velocity, velocity)
g_last_Leap[id] = get_gametime()
}
}
return FMRES_IGNORED
}
allow_LongJump(id)
{
if (!g_hasLeap[id] && !g_hasLeapUpgrade[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
if (get_gametime() - g_last_Leap[id] < get_pcvar_float(g_leap_cooldown))
return false
return true
}
public show_leap_status(id)
{
if (g_hasLeap[id])
{
set_hudmessage(100, 0, 150, -1.0, 1.0, 0, 6.0, 1.0, 0.1, 0.2)
show_hudmessage(id, "Your Max Leap Force is %i", get_pcvar_num(g_leap_force))
}
else if (g_hasLeapUpgrade[id])
{
set_hudmessage(200, 100, 0, -1.0, 1.0, 0, 6.0, 1.0, 0.1, 0.2)
show_hudmessage(id, "Your Max Leap Force is %i + 125", get_pcvar_num(g_leap_force))
}
set_task(0.1, "show_leap_status", id)
return PLUGIN_HANDLED
}
stock fm_get_speed(entity)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity))
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/