I took Crow Zombie's fly and modified it to make it fly for x seconds and then cooldown x seconds but the problem is when I press the button to activate the fly ability, he is trying to fly but is not flying continue for x seconds.
If I remove coldown then I must to press buton continue for many times to make it fly is like have multiple jump. Please anyone help with this. Thank you.
PHP Code:
new g_zclass_crow, cvar_fly_speed
new g_cooldown[33]
new Float:g_fly_time[33]
new i_cooldown_time[33]
new g_maxplayers
new g_infections[33]
new Float:g_flPlayerGravity[ 33 ]
// Zombie Attributes
new const zclass_name[] = { "Crow" } // name
new const zclass_info[] = { "Press E to fly" } // description
new const zclass_model[] = { "zombimod_crow" } // model
new const zclass_clawmodel[] = { "v_knife_crow.mdl" } // claw model
const zclass_health = 5000 // health
const zclass_speed = 360 // speed
const Float:zclass_gravity = 0.68 // gravity
const Float:zclass_knockback = 0.0 // knockback
new Float:g_fly_time_standart = 10.0 //first fly time
new Float:g_fly_cooldown_standart = 20.0 //cooldown time
public plugin_init()
{
register_plugin("[ZP] Zombie Class: Crow", "1.1", "v3x, Roadrage, 93()|29!/<")
register_logevent("roundStart", 2, "1=Round_Start")
g_maxplayers = get_maxplayers()
register_clcmd("drop", "use_ability_one")
}
public plugin_precache()
{
cvar_fly_speed = register_cvar("zp_crow_fly_speed", "360")
g_zclass_crow = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
public roundStart(id)
{
for (new i = 1; i <= g_maxplayers; i++)
{
i_cooldown_time[i] = floatround(g_fly_cooldown_standart)
g_cooldown[i] = 0
remove_task(i)
}
}
public client_connect(id)
{
remove_task(id)
}
public client_disconnect(id)
{
remove_task(id)
}
public use_ability_one(id)
{
if(zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_crow)
{
if(is_user_alive(id) && g_cooldown[id] == 0)
{
new Float:fAim[3], Float:fVelocity[3]
VelocityByAim(id, get_pcvar_num(cvar_fly_speed), fAim)
fVelocity[0] = fAim[0];
fVelocity[1] = fAim[1];
fVelocity[2] = fAim[2];
set_user_velocity(id , fVelocity);
set_task(g_fly_time[id],"RemoveFly",id)
set_task(g_fly_cooldown_standart,"reset_cooldown",id)
g_cooldown[id] = 1
i_cooldown_time[id] = floatround(g_fly_cooldown_standart)
}
}
}
public RemoveFly(id)
{
if(zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_crow)
{
g_flPlayerGravity[ id ] = zclass_gravity
set_pev( id, pev_gravity, g_flPlayerGravity )
}
}
public reset_cooldown(id)
{
if(zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_crow)
{
g_cooldown[id] = 0
new text[100]
format(text,99,"^x04[ZP]^x01 Your ability ^x04[Fly]^x01 is ready. Press ^x04G^x01")
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)
write_byte(id)
write_string(text)
message_end()
}
}
public zp_user_infected_post(id, infector)
{
if ((zp_get_user_zombie_class(id) == g_zclass_crow) && !zp_get_user_nemesis(id))
{
new text[100]
new note_cooldown = floatround(g_fly_cooldown_standart)
new note_flytime = floatround(g_fly_time_standart)
format(text,99,"^x04[ZP]^x01 To use your ability press ^x04G^x01. Cooldown:^x04 %d ^x01seconds. Fly time: ^x04%d^x01 seconds.",note_cooldown,note_flytime)
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)
write_byte(id)
write_string(text)
message_end()
i_cooldown_time[id] = floatround(g_fly_cooldown_standart)
remove_task(id)
g_fly_time[id] = g_fly_time_standart
g_cooldown[id] = 0
g_infections[id] = 0
g_fly_time[infector] = g_fly_time[infector] + 1;
infections_hud(infector)
}
}
public infections_hud(id)
{
if (is_user_alive(id) && (zp_get_user_zombie_class(id) == g_zclass_crow) && !zp_get_user_nemesis(id))
{
new i_fly_time = floatround(g_fly_time[id])
new text[100]
format(text,99,"^x04[ZP]^x01 Your fly time is^x04 %d ^x01seconds.",i_fly_time)
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)
write_byte(id)
write_string(text)
message_end()
}
}
// Set entity's rendering type (from fakemeta_util)
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
static Float:color[3]
color[0] = float(r)
color[1] = float(g)
color[2] = float(b)
set_pev(entity, pev_renderfx, fx)
set_pev(entity, pev_rendercolor, color)
set_pev(entity, pev_rendermode, render)
set_pev(entity, pev_renderamt, float(amount))
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
P.S.: Don't ask me to fix this, I am really a low scripter.
I really need help with this. I am able to pay or send a Boost SMS for your server 2€ worth.