Raised This Month: $ Target: $400
 0% 

[CS]Bomb Events Help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-20-2008 , 16:17   Re: [CS]Bomb Events Help
Reply With Quote #5

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_iFhMessageBeging_iFhWriteString

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    if( !
engfuncEngFunc_FindEntityByString FM_NULLENT "classname" "func_bomb_target" )
    &&  !
engfuncEngFunc_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()
{
    
Plantingfalse )
}

public 
Event_BarTime_Stop_Planting(id)
{
    if( 
g_iPlanter == id )
    {
        
Plantingfalse )
    }
}

public 
Player_Killed(id)
{
    if( 
g_iPlanter == id )
    {
        
Plantingfalse )
    }
}

public 
Logevent_Round_End()
{
    
Plantingfalse )
}

Plantingbool:bState )
{
    if( 
bState )
    {
        if( !
g_iFhMessageBegin )
        {
            
g_iFhMessageBegin register_forward(FM_MessageBegin"MessageBegin")
        }
        return
    }

    
g_iPlanter 0

    
if( g_iFhMessageBegin )
    {
        
unregister_forward(FM_MessageBeging_iFhMessageBegin)
        
g_iFhMessageBegin 0
    
}
    if( 
g_iFhWriteString )
    {
        
unregister_forward(FM_WriteStringg_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 engfuncEngFunc_FindEntityByString FM_NULLENT "classname" "grenade" )
    while( 
iEnt )
    {
        if( 
get_pdata_int(iEnt96) & (1<<8) )
        {
            
engfuncEngFunc_RemoveEntityiEnt )
            break
        }
        
iEnt engfuncEngFunc_FindEntityByString iEnt "classname" "grenade" )
    }
    
g_iPlanter 0
    
// Send what you want to send here
}

public 
MessageBegin(MSG_DESTiMsgId)
{
    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(" ")
        
Plantingfalse )
        return 
FMRES_SUPERCEDE
    
}

    return 
FMRES_IGNORED
}

Equal(const szA[], const szB[])
{
    static 
a0

    a 
szA[i]
    do
    {
        if( 
!= szB[i])
            return 
0
    
}
    while( (
szA[++i]) )

    return 
1

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode