Привет всем, сделал класс человека с способностью неуязвимости на 10 секунд, но некорректно работает кулдаун и хотел бы поставить на кнопки ALT + E. вместо G (cmd drop). Кто поможет, буду благодарен)
C++:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <zp50_class_human>
#include <zp50_class_nemesis>
#include <zmvip>
#include <zp50_items>
#include <zombieplague>
#include <zp_level_system>
#define LVL_COUNT 20
// Invulnurable Attributes
new const humanclass1_name[] = "Invulnurable Human"
new const humanclass1_info[] = "[Invulnurability on ALT]"
new const humanclass1_models[][] = { "leet" }
const humanclass1_health = 150
const Float:humanclass1_speed = 1.0
const Float:humanclass1_gravity = 1.0
new g_human_invul
new godmode[33] = 0
new godmode_used[33] = 0
new godmode_cooldown[33]
new Float:alt_cooldown = 30.0
new Float:godmode_time = 10.0
new MsgSayText
public plugin_precache()
{
register_plugin("[ZP] Class: Human: Invulnurable", ZP_VERSION_STRING, "_RedGamer_")
register_clcmd("drop", "use_ability")
register_forward( FM_PlayerPreThink, "client_prethink")
register_logevent("roundStart", 2, "1=Round_Start")
g_human_invul = zp_class_human_register(humanclass1_name, humanclass1_info, humanclass1_health, humanclass1_speed, humanclass1_gravity)
new index
for (index = 0; index < sizeof humanclass1_models; index++)
zp_class_human_register_model(g_human_invul, humanclass1_models[index])
MsgSayText = get_user_msgid("SayText")
}
public client_prethink(id)
{
if (zp_class_human_get_current(id) == g_human_invul)
{
if (is_user_alive(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id) && (zp_class_human_get_current(id) == g_human_invul))
Action(id)
}
}
public Action(id)
{
if (godmode[id] == 1)
{
set_user_godmode(id, 1)
}
else
{
set_user_godmode(id, 0)
}
return PLUGIN_HANDLED
}
public roundStart()
{
for (new i = 1; i <= get_maxplayers(); i++)
{
godmode_cooldown[i] = floatround(alt_cooldown)
godmode_used[i] = 0
godmode[i] = 0
remove_task(i)
}
}
public ShowHUD(id)
{
if (is_user_alive(id))
{
godmode_cooldown[id] = godmode_cooldown[id] - 1
set_hudmessage(200, 100, 0, 0.80, 0.87, 0, 1.0, 1.1, 0.0, 0.0, -1)
show_hudmessage(id, "[Неуязвимость: %d]", godmode_cooldown[id])
}
else
{
remove_task(id)
}
}
public use_ability(id)
{
if (is_user_alive(id) && (zp_class_human_get_current(id) == g_human_invul) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id))
{
if (godmode_used[id] == 0)
{
set_user_rendering(id, kRenderFxGlowShell, 255, 165, 0, kRenderNormal, 0)
godmode[id] = 1
godmode_used[id] = 1
set_task(godmode_time, "godmode_disable", id)
godmode_cooldown[id] = floatround(alt_cooldown)
set_task(1.0, "ShowHUD", id, _, _, "a", godmode_cooldown[id])
set_user_godmode(id, 1)
client_print(id, print_chat, "[TEST] - Ability used")
}
}
}
public godmode_disable(id)
{
if ((zp_class_human_get_current(id) == g_human_invul) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id))
{
set_user_rendering(id)
godmode[id] = 0
set_task(alt_cooldown, "set_ability_godmode_cooldown", id)
set_user_godmode(id, 0)
}
}
public set_ability_godmode_cooldown(id)
{
if ((zp_class_human_get_current(id) == g_human_invul) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id))
{
godmode_used[id] = 0
}
}
public zp_fw_core_cure_pre(id)
{
if (zp_class_human_get_next(id) == g_human_invul)
{
if (zp_level(id) < LVL_COUNT)
{
zp_colored_print(id, "^x01[^x04ZP^x01] Вы не достигли ^x04%d ^x01уровня!", LVL_COUNT)
zp_class_human_set_next(id, 0)
}
else
{
zp_class_human_set_next(id, g_human_invul)
}
}
}
public zp_fw_core_cure_post(id)
{
if ((zp_class_human_get_current(id) == g_human_invul) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id))
{
godmode_cooldown[id] = floatround(alt_cooldown)
remove_task(id)
godmode[id] = 0
godmode_used[id] = 0
}
}
public zp_fw_core_infect_post(id)
{
remove_task(id)
}
zp_colored_print(target, const message[], any:...)
{
static buffer[512], i, argscount
argscount = numargs()
if (!target)
{
static player
for (player = 1; player <= get_maxplayers(); player++)
{
if (!is_user_connected(player))
continue;
static changed[5], changedcount
changedcount = 0
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
{
setarg(i, 0, player)
changed[changedcount] = i
changedcount++
}
}
vformat(buffer, charsmax(buffer), message, 3)
message_begin(MSG_ONE_UNRELIABLE, MsgSayText, _, player)
write_byte(player)
write_string(buffer)
message_end()
for (i = 0; i < changedcount; i++)
setarg(changed[i], 0, LANG_PLAYER)
}
}
else
{
vformat(buffer, charsmax(buffer), message, 3)
message_begin(MSG_ONE, MsgSayText, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}