#define NEW_LED "sprites/ledglow_blue.spr"
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "C4 Led Replacement"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"
new g_iFhMessageBegin, g_iFhWriteByte, g_iFhWriteShort
new g_iLedSprite, g_iNewLed
public plugin_precache()
{
g_iLedSprite = precache_model("sprites/ledglow.spr")
g_iNewLed = precache_model(NEW_LED)
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
if( engfunc( EngFunc_FindEntityByString , FM_NULLENT , "classname" , "func_bomb_target" )
|| engfunc( EngFunc_FindEntityByString , FM_NULLENT , "classname" , "info_bomb_target" ) )
{
register_event("HLTV", "DisableForwards", "a", "1=0", "2=0")
register_logevent("DisableForwards", 2, "1=Round_End")
register_logevent("EnableForwards", 3, "2=Planted_The_Bomb")
}
}
public DisableForwards()
{
if( UnregisterForward(FM_MessageBegin, g_iFhMessageBegin) )
{
UnregisterForward(FM_WriteByte, g_iFhWriteByte)
UnregisterForward(FM_WriteShort, g_iFhWriteShort)
}
}
public EnableForwards()
{
RegisterForward(FM_MessageBegin, "MessageBegin", g_iFhMessageBegin)
}
public MessageBegin(MSG_DEST, iMsgId)
{
if( MSG_DEST == MSG_PVS && iMsgId == SVC_TEMPENTITY )
{
RegisterForward(FM_WriteByte, "WriteByte", g_iFhWriteByte)
}
}
public WriteByte( iByte )
{
UnregisterForward(FM_WriteByte, g_iFhWriteByte)
if( iByte == TE_GLOWSPRITE )
{
RegisterForward(FM_WriteShort, "WriteShort", g_iFhWriteShort)
}
}
public WriteShort( iShort )
{
UnregisterForward(FM_WriteShort, g_iFhWriteShort)
if( iShort == g_iLedSprite )
{
write_short(g_iNewLed)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
RegisterForward(iFM_Type, szHandler[], &iForward, iPost = 0)
{
if( !iForward )
{
iForward = register_forward(iFM_Type, szHandler, iPost)
return 1
}
return 0
}
UnregisterForward(iFM_Type, &iForward, iPost = 0)
{
if( iForward )
{
unregister_forward(iFM_Type, iForward, iPost)
iForward = 0
return 1
}
return 0
}