AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [CS]Bomb Events Help (https://forums.alliedmods.net/showthread.php?t=82282)

fang 12-20-2008 10:45

[CS]Bomb Events Help
 
How would one go and hook the planting of a bomb(After the planting bar finishes), remove it, remove the "The bomb has been planted" text, and then execute an event? I've never needed to do this until now so I'm not quite sure how to go and do it. D:

ConnorMcLeod 12-20-2008 11:24

Re: [CS]Bomb Events Help
 
First read this :
http://forums.alliedmods.net/showthread.php?t=40164

After you have caught the planted logevent, find the bomb entity and remove it.
Also, hook TestMsg message and block the sentence you wish.

fang 12-20-2008 11:28

Re: [CS]Bomb Events Help
 
Ohh... :oops: Ty

ConnorMcLeod 12-20-2008 16:17

Re: [CS]Bomb Events Help
 
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



fang 12-20-2008 16:26

Re: [CS]Bomb Events Help
 
Oh! Okay I see now. Thanks connorr :o
+Karma'd!

ConnorMcLeod 12-20-2008 16:59

Re: [CS]Bomb Events Help
 
Quote:

Originally Posted by Dores (Post 730532)
Correct me if I'm wrong...:crab:


Exolent[jNr] 12-20-2008 17:07

Re: [CS]Bomb Events Help
 
This isn't using register_message(), it is hooking when message_begin is used.
So, the parameters of message_begin are passed.

Starsailor 12-29-2008 22:13

Re: [CS]Bomb Events Help
 
PHP Code:

#include <csx>

forward bomb_planting(planter);
forward bomb_planted(planter);
forward bomb_explode();
forward bomb_defusing(defuser);
forward bomb_defused(defuser);

public 
bomb_planting(id) { 

// your code here

}

public 
bomb_planted(id) { 

// your code here

}

public 
bomb_explode(id) { 

// your code here

}
public 
bomb_defuse(id) { 

// your code here

}

public 
bomb_defusing(id) { 

// your code here





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

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