Raised This Month: $ Target: $400
 0% 

[Solved] Detect Distance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
padilha007
Senior Member
Join Date: Jul 2008
Old 03-17-2010 , 10:18   [Solved] Detect Distance
Reply With Quote #1

I need to get the distance from the tr spawn and any other door.

PHP Code:
new b_Base[101];

public 
Spawns_To_Edit( )
{
    
// Entidades
    
new entityg_iBombFloat:g_Varg_iCount;
    
    
// Colocar
    
g_Var float(get_pcvar_num(g_iRadius))
    
    
// Origens
    
new Float:DROrigin[3];
    new 
Float:PLOrigin[3];
    
    while ((
entity find_ent_by_class(g_iBomb"info_player_deathmatch")))
    {
        
peventitypev_originDROrigin )
        
        while ((
g_iBomb find_ent_by_class(entity"func_door")))
        {
            
pevg_iBomb pev_originDROrigin )
            
            if ( 
get_distance_fDROriginPLOrigin ) <= g_Var )
            {
                for(new 
i=1;<= 100;i++)
                {
                    if( !
g_Base[i] && fnEntCount(g_iBomb ) == )
                    {
                        
g_Base[i] = g_iBomb;    
                        
g_iCount++;
                    }
                }
            }
        }
    }
    
    
client_print(0print_chat"[Debug] %d"g_iCount);
}

fnEntCount(entity)
{
    new 
iCount 0

    
for(new i=1;<= 100;i++)
    {
        if( 
g_Base[i] == entity )
            
iCount++
    }

    return 
iCount

Tnx
__________________


Last edited by padilha007; 03-18-2010 at 09:56.
padilha007 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-17-2010 , 10:40   Re: Detect Distance
Reply With Quote #2

Code:
new Float:fRadius = get_pcvar_float( g_iRadius ); new iDoors[ 128 ]; new iFound; new i, iDoor; new iIndex; new iCount; new iSpawn = -1; while( ( iSpawn = find_ent_by_class( iSpawn, "info_player_deathmatch" ) ) ) {     if( ( iFound = find_sphere_class( iSpawn, "func_door",          fRadius, iDoors, sizeof( iDoors ) ) ) > 0     ||  ( iFound = find_sphere_class( iSpawn, "func_door_rotating", fRadius, iDoors, sizeof( iDoors ) ) ) > 0 )     {         if( !( iIndex = GetBaseIndex( iSpawn ) )         &&  ( iIndex = GetEmptyBaseIndex( ) ) > 0 )         {             g_Base[ iIndex ] = iSpawn;             iCount++;                         for( i = 0; i < iFound; i++ )             {                 iDoor = iDoors[ i ];                 // iDoor is a door entity within the range of iSpawn, the spawn entity             }         }     }         client_print( 0, print_chat, "[Debug] %d", iCount ); } // ... GetBaseIndex( iEntity ) {     for( new i = 1; i <= 100; i++ )     {         if( g_Base[ i ] == iEntity )         {             return i;         }     }         return 0; } GetEmptyBaseIndex( ) {     for( new i = 1; i <= 100; i++ )     {         if( !is_valid_ent( g_Base[ i ] ) )         {             return i;         }     }         return 0; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 03-18-2010 at 00:37.
Exolent[jNr] is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 03-17-2010 , 19:58   Re: Detect Distance
Reply With Quote #3

Tnx, works perfect. But who i can do to get door id?


__________________

padilha007 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-18-2010 , 00:37   Re: Detect Distance
Reply With Quote #4

Edited code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 03-18-2010 , 09:55   Re: Detect Distance
Reply With Quote #5

Tnx, works perfect ^^
__________________

padilha007 is offline
Reply


Thread Tools
Display Modes

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 08:49.


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