Hi!
I've been having problems to achieve the following. I've got a zombie class that can jump twice in the air (multijump style). The problem is that if you use the mouse wheel to jump (as many players do), then the multijump thing gets bugged because it is like you did your second jump way too fast. So I tried to make it so you should wait some time to be able to use your next jump and avoid such issue (couldn't think of another way to fix it yet). I haven't found anything related to this... I'd appreciate any help.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <zombieplague>
new _gJumpCount[33]
new cvar_multi_jump_amount
new g_zclass_jumper
new g_canjump[33]
new const zclass_name[] = {"Tight"}
new const zclass_info[] = {"Doble Salto"}
new const zclass_model[] = {"zombie_tight"}
new const zclass_clawmodel[] = {"v_knife_tight.mdl"}
const zclass_health = 1500
const zclass_speed = 200
const Float:zclass_gravity = 1.0
const Float:zclass_knockback = 1.0
public plugin_init()
{
register_plugin("[ZP] Zombie Class: Jumper", "1.0", "zmd94")
RegisterHam(Ham_Player_Jump, "player", "fw_PlayerJump", 0)
cvar_multi_jump_amount = register_cvar("zp_multi_jump_amount", "1")
}
public plugin_precache()
{
g_zclass_jumper = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
public fw_PlayerJump(id)
{
if(!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id))
{
return HAM_IGNORED
}
if(zp_get_user_zombie_class(id) == g_zclass_jumper)
{
new Flags = pev(id, pev_flags)
if( Flags & FL_WATERJUMP || pev(id, pev_waterlevel) >= 2 || !(get_pdata_int(id, 246) & IN_JUMP) )
{
return HAM_IGNORED
}
if(Flags & FL_ONGROUND)
{
_gJumpCount[id] = 0
return HAM_IGNORED
}
if (!_gJumpCount[id]) // this is what I added
set_task(2.0, "can_jump", id)
if(get_pcvar_num(cvar_multi_jump_amount))
{
if( get_pdata_float(id, 251) < 500 && ++_gJumpCount[id] <= get_pcvar_num(cvar_multi_jump_amount))
{
if (g_canjump[id]) // and this check
{
new Float:fVelocity[3]
pev(id, pev_velocity, fVelocity)
fVelocity[2] = 268.328157
set_pev(id, pev_velocity, fVelocity)
g_canjump[id] = false // and this
return HAM_HANDLED
}
}
}
}
return HAM_IGNORED
}
public can_jump(id) g_canjump[id] = true