PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <tsfun>
new bool:g_bCloakEnabled[33]
new g_iLastRender[33]
public plugin_init()
{
register_plugin("Shadow Cloak", "1.0", "Spunky")
register_clcmd("say /cloak", "cmd_cloak")
}
public client_disconnect(id)
{
g_bCloakEnabled[id] = false
g_iLastRender[id] = 0
}
public client_PostThink(id)
{
if (!is_user_alive(id))
return PLUGIN_CONTINUE
else if (!g_bCloakEnabled[id])
return PLUGIN_CONTINUE
static Float:fpVelocity[3]
entity_get_vector(id, EV_VEC_velocity, fpVelocity)
new Float:fpSpeed = fpVelocity[0] + fpVelocity[1] + fpVelocity[2]
new iModifier = fpSpeed != 0.0 ? 1 : -1
new Float:fpRenderAmount = float((g_iLastRender[id] = clamp(g_iLastRender[id] + iModifier, 0, 255)) + 50)
static iDummy
new iWeapon = ts_getuserwpn(id, iDummy, iDummy, iDummy, iDummy)
switch (iWeapon)
{
case TSW_KATANA, TSW_KUNG_FU, TSW_CKNIFE, TSW_SKNIFE, TSW_TKNIFE:
fpRenderAmount -= 50.0
}
entity_set_int(id, EV_INT_renderfx, kRenderFxGlowShell)
entity_set_vector(id, EV_VEC_rendercolor, Float:{0.0, 0.0, 0.0})
entity_set_int(id, EV_INT_rendermode, kRenderTransAlpha)
entity_set_float(id, EV_FL_renderamt, fpRenderAmount)
return PLUGIN_CONTINUE
}
public cmd_cloak(id)
{
if (!is_user_alive(id))
return PLUGIN_HANDLED
else if (!g_bCloakEnabled[id])
{
g_bCloakEnabled[id] = true
g_iLastRender[id] = 0
client_print(id, print_chat, "Cloak enabled.")
}
else
{
g_bCloakEnabled[id] = false
client_print(id, print_chat, "Cloak disabled.")
}
return PLUGIN_HANDLED
}
This doesn't seem to work but I can't for the life of me figure out why. It should work absolutely fine. I can't see anything wrong with it. When you enable the cloak, they're supposed to slowly fade out for as long as they're standing still. When they move, they fade in. I know it's been done before (and not much differently than this) but I want to know why this won't work.
And if you're wondering, yes, the code is mostly Hawk552's.