AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fix bomb bug (https://forums.alliedmods.net/showthread.php?t=144200)

dFF 11-30-2010 08:39

Fix bomb bug
 
Sometimes after the bomb (c4) was planted and round is end the bomb is still count and explode..

Here is the code I will try to fix this:
PHP Code:

#include < amxmodx >
#include < engine >
#include < fakemeta >

#define m_C4 96
#define IsC4(%1) get_pdata_int( %1, m_C4 ) & ( 1<<8 )

new g_iBombPlantedOrDefused

public plugin_init() 
{
    new 
entity = -1
    
new iMapBomb

    
while( ( entity find_ent_by_classentity"func_bomb_target" ) ) > )
    {
        
iMapBomb true
    
}

    
entity = -1
    
    
while( ( entity find_ent_by_classentity"info_bomb_target" ) ) > )
    {
        
iMapBomb true
    
}

    if( 
iMapBomb )
    {
        
register_event"TextMsg""Event_RoundEnd""a""2&#Game_C""2&#Game_w" )
        
        
register_event"HLTV""Event_RoundEnd""a""1=0""2=0" )
        
register_logevent"Event_RoundEnd"2"1=Round_Start" )
        
        
register_event"SendAudio""Event_RoundEnd""a""2=%!MRAD_terwin""2=%!MRAD_ctwin""2=%!MRAD_rounddraw" )
        
register_logevent"Event_RoundEnd"2"1=Round_End" )
        
        
register_logevent"LogEvent_BombPlanted"3"2=Planted_The_Bomb" )
        
register_logevent"LogEvent_BombPlanted"3"2=Defused_The_Bomb" )
        
        
register_logevent"LogEvent_BombPlanted"6"3=Target_Saved" )
    }
    
    else
    {
        
pause"ad" )
        
g_iBombPlantedOrDefused false
        
return
    }
}

public 
Event_RoundEnd()
{
    if( 
g_iBombPlantedOrDefused )
    {
        static 
iC4
        iC4 
= -1
        
        
while( ( iC4 find_ent_by_classiC4"grenade" ) ) > )
        {
            if( 
IsC4iC4 ) > )
            {
                
remove_entityiC4 )
                
g_iBombPlantedOrDefused false
                
break
            }
        }
    }
}

public 
LogEvent_BombPlanted()
{
    
g_iBombPlantedOrDefused true


But sometimes server crash with this error:
FATAL ERROR (shutting down): NUM_FOR_EDICT: bad pointer

Exolent[jNr] 11-30-2010 12:48

Re: Fix bomb bug
 
Why don't you set it's explode time to 9999.0?

Code:
#define OFFSET_C4_EXPLODETIME   100 public Event_RoundEnd() {     if( g_iBombPlantedOrDefused )     {         static iC4         iC4 = -1                 while( ( iC4 = find_ent_by_class( iC4, "grenade" ) ) > 0 )         {             if( IsC4( iC4 ) > 0 )             {                 //remove_entity( iC4 )                 set_pdata_float( iC4, OFFSET_C4_EXPLODETIME, 9999.0 )                 g_iBombPlantedOrDefused = false                 break             }         }     } }

dFF 11-30-2010 13:00

Re: Fix bomb bug
 
Ok, I will try. Thanks.


All times are GMT -4. The time now is 11:16.

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