Classic way is using register_message.
I don't like this way when it's possible to do another way.
PHP Code:
/* Copyright © 2008, ConnorMcLeod
Bomb Tests is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bomb Tests; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "C4 Remover"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"
new g_iPlanter
new gmsgSendAudio
new g_iFhMessageBegin, g_iFhWriteString
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" ) )
{
pause("ad")
return
}
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_event("BarTime", "Event_BarTime_Stop_Planting", "be", "1=0")
RegisterHam(Ham_Killed, "player", "Player_Killed", 1)
register_logevent("Logevent_Round_End", 2, "1=Round_End")
register_event("BarTime", "Event_BarTime_Planting", "be", "1=3")
register_logevent("LogEvent_Planted_The_Bomb", 3, "2=Planted_The_Bomb")
gmsgSendAudio = get_user_msgid("SendAudio")
}
public Event_HLTV_New_Round()
{
Planting( false )
}
public Event_BarTime_Stop_Planting(id)
{
if( g_iPlanter == id )
{
Planting( false )
}
}
public Player_Killed(id)
{
if( g_iPlanter == id )
{
Planting( false )
}
}
public Logevent_Round_End()
{
Planting( false )
}
Planting( bool:bState )
{
if( bState )
{
if( !g_iFhMessageBegin )
{
g_iFhMessageBegin = register_forward(FM_MessageBegin, "MessageBegin")
}
return
}
g_iPlanter = 0
if( g_iFhMessageBegin )
{
unregister_forward(FM_MessageBegin, g_iFhMessageBegin)
g_iFhMessageBegin = 0
}
if( g_iFhWriteString )
{
unregister_forward(FM_WriteString, g_iFhWriteString)
g_iFhWriteString = 0
}
}
public Event_BarTime_Planting(id)
{
if( get_user_weapon(id) == CSW_C4 )
{
g_iPlanter = id
Planting( true )
}
}
public LogEvent_Planted_The_Bomb()
{
new iEnt = engfunc( EngFunc_FindEntityByString , FM_NULLENT , "classname" , "grenade" )
while( iEnt )
{
if( get_pdata_int(iEnt, 96) & (1<<8) )
{
engfunc( EngFunc_RemoveEntity, iEnt )
break
}
iEnt = engfunc( EngFunc_FindEntityByString , iEnt , "classname" , "grenade" )
}
g_iPlanter = 0
// Send what you want to send here
}
public MessageBegin(MSG_DEST, iMsgId)
{
if( iMsgId == gmsgSendAudio && !g_iFhWriteString )
{
g_iFhWriteString = register_forward(FM_WriteString, "WriteString")
}
}
public WriteString(const szString[])
{
if( Equal(szString, "%!MRAD_BOMBPL") )
{
write_string("%")
return FMRES_SUPERCEDE
}
if( Equal(szString, "#Bomb_Planted") )
{
write_string(" ")
Planting( false )
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
Equal(const szA[], const szB[])
{
static a, i ; i = 0
a = szA[i]
do
{
if( a != szB[i])
return 0
}
while( (a = szA[++i]) )
return 1
}
__________________