Raised This Month: $ Target: $400
 0% 

2 c4 at roundstart


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
katna
Senior Member
Join Date: May 2010
Old 08-11-2011 , 03:16   2 c4 at roundstart
Reply With Quote #1

i had a problem with c4 detection at round start to i tried to fix it. anyway
i need to save the c4 to a global varible at the roundstart event. The problem is at the round start its detect 2 weapon_c4 and 0.1 its detect only 1 ( only when mp_freezetime 0), when mp_freezetime is bigger then 0 then there is no problem with the c4

Code:
new ent, count
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "weapon_c4")))
{
     count++
}
	
ColorChat(0, "%d c4 detected", count)
katna is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-11-2011 , 03:52   Re: 2 c4 at roundstart
Reply With Quote #2

Quote:
Originally Posted by katna View Post
i had a problem with c4 detection at round start to i tried to fix it. anyway
i need to save the c4 to a global varible at the roundstart event. The problem is at the round start its detect 2 weapon_c4 and 0.1 its detect only 1 ( only when mp_freezetime 0), when mp_freezetime is bigger then 0 then there is no problem with the c4

Code:
new ent, count
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "weapon_c4")))
{
     count++
}
    
ColorChat(0, "%d c4 detected", count)
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

#define fm_find_ent_by_class(%1,%2) engfunc( EngFunc_FindEntityByString, %1, "classname", %2 )

new iC4ID

public plugin_init()
{
    
RegisterHam(Ham_Spawn"player""fwdPlayerSpawn");
}

public 
fwdPlayerSpawn()
{
    
iC4ID fm_find_ent_by_class(-1"weapon_c4");
    
    
server_print("C4 Index: %d"iC4ID);

This got it for me.. ent id 47 every time i would spawn with the bomb
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-11-2011 , 04:07   Re: 2 c4 at roundstart
Reply With Quote #3

Only 1 of the 2 c4 should have a player as owner (if pev_owner doesn't work, try m_pPlayer offset).

@Doc-Holiday
Player spawn is called many times, and it's too early to detect c4 ( c4 is given the same frame but after spawn, so, index you get is old c4, by chance new c4 had same index but it is not sure.

Code:
void CHalfLifeMultiplay::RestartRound()
{
    // [ .. ]

    @@ // HLTV Event ( New Round )
    MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
        WRITE_BYTE( 0 );                // 0 = all players
        WRITE_BYTE( 100 | 128 );        // 100 health + msg flag
    MESSAGE_END();

    MESSAGE_BEGIN( MSG_SPEC, gmsgHLTV );
        WRITE_BYTE( 0 );                // all players
        WRITE_BYTE( 0 );                // to default FOV value
    MESSAGE_END();

    // [ .. ]
    for ( int i = 1; i <= gpGlobals->maxClients; i++ )
    {
        CBasePlayer *pPlayer = CBasePlayer::Instance( i );
        
        if ( pPlayer && !FNullEnt( pPlayer->edict() ) )
        {
            pPlayer->m_iNumSpawns   = 0;
            pPlayer->m_bTeamChanged = false;
        
            if ( !unknowCall168() )
            {
                pPlayer->SyncRoundTimer();
            }
            
            switch ( m_iTeam )
            {
                case TEAM_CT :
                {
                    if ( !playerOffset222 )
                    {
                        pPlayer->AddAccount( m_iAccountCT, 1 );
                    }
                }
                case TEAM_TERRORIST :
                {
                    m_iNumEscapers++;
                    
                    if ( !playerOffset222 )
                    {
                        pPlayer->AddAccount( m_iAccountTerrorist, 1 );
                    }
                    
                    if ( m_bMapHasEscapeZone )
                    {
                        pPlayer->m_bNotKilled = false;
                    }
                }
            }
            
            if ( m_iTeam != TEAM_UNASSIGNED && m_iTeam != TEAM_SPECTATOR )
            {
                if ( m_bHasC4 )
                {
@@                    pPlayer->DropPlayerItem( "weapon_c4" );
                }
                
@@               pPlayer->RoundRespawn(); // spawns
            }
        }
    }
    
    CleanUpMap();
    
    if ( m_bMapHasBombTarget )
    {
@@        GiveC4(); // after spawns
    }
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
katna
Senior Member
Join Date: May 2010
Old 08-11-2011 , 04:56   Re: 2 c4 at roundstart
Reply With Quote #4

i will check owner, i'm not very familiar with offset. but what does the mp_freezetime has to do with it?
katna is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 08-11-2011 , 05:19   Re: 2 c4 at roundstart
Reply With Quote #5

PHP Code:
#define m_pPlayer 41
new id get_pdata_cbase(iC4Entm_pPlayer4
something like that Connor?
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-11-2011 , 06:06   Re: 2 c4 at roundstart
Reply With Quote #6

Quote:
Originally Posted by katna View Post
but what does the mp_freezetime has to do with it?
I have no idea, may be then roundstart happen the same frame as newround, and maybe c4 is still there but has flag FL_KILLME, you can also check that.

If( pev(iC4, pev_flags) & FL_KILLME ) should do the trick as well.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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 03:25.


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