You know, it would really help if you put those
examples of how to use a cooldown into your actual code
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "fR4gn0tiX!"
new Float:gCooldown[33], cvarCooldown
stock register_saycmd(saycommand[], function[], flags = -1, info[])
{
static sTemp[64]
formatex(sTemp, sizeof sTemp - 1, "say /%s", saycommand)
register_clcmd(sTemp, function, flags, info)
formatex(sTemp, sizeof sTemp - 1, "say .%s", saycommand)
register_clcmd(sTemp, function, flags, info)
formatex(sTemp, sizeof sTemp - 1, "say_team /%s", saycommand)
register_clcmd(sTemp, function, flags, info)
formatex(sTemp, sizeof sTemp - 1, "say_team .%s", saycommand)
register_clcmd(sTemp, function, flags, info)
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("gacocxleba", "v1.0 by fR4gn0tiX!", FCVAR_SERVER|FCVAR_SPONLY)
register_concmd("amx_respawn", "cmd_gacocxleba", ADMIN_SLAY, "< saxeli | #userid > - Respawn player")
register_saycmd("respawn", "cl_gacocxleba", ADMIN_SLAY, "Respawn yourself")
cvarCooldown = register_cvar("revive_cooldown", "5.0", FCVAR_SPONLY)
}
public cmd_gacocxleba(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Argument[32]
read_argv(1, Argument, 31)
new Target = cmd_target(id, Argument, CMDTARGET_ALLOW_SELF | CMDTARGET_OBEY_IMMUNITY)
if (Target)
{
if (is_user_alive(Target))
{
new saxeli[32]
get_user_name(Target, saxeli, 31)
console_print(id, "%s is already alive!", saxeli)
return PLUGIN_HANDLED
}
new Float:cooldownTime = get_pcvar_float(cvarCooldown)
new Float:currentTime = get_gametime()
if (gCooldown[Target] > currentTime)
{
client_print(id, print_console, "Please wait another %i seconds before attempting to revive this player.", floatround(gCooldown[Target] - currentTime))
return PLUGIN_HANDLED
}
gCooldown[Target] = currentTime + cooldownTime
ExecuteHamB(Ham_CS_RoundRespawn, Target)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public cl_gacocxleba(id)
{
if (is_user_alive(id))
{
client_print(id, print_chat, "You are already alive!")
return PLUGIN_HANDLED
}
new Float:cooldownTime = get_pcvar_float(cvarCooldown)
new Float:currentTime = get_gametime()
if (gCooldown[id] > currentTime)
{
client_print(id, print_chat, "Please wait another %i seconds before attempting to revive yourself.", floatround(gCooldown[id] - currentTime))
return PLUGIN_HANDLED
}
gCooldown[id] = currentTime + cooldownTime
ExecuteHamB(Ham_CS_RoundRespawn, id)
return PLUGIN_HANDLED
}
Untested. Cooldown is on target (i.e. player can only
be revived once per cooldown). Change cooldown time with cvar revive_cooldown.