AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Detect Distance (https://forums.alliedmods.net/showthread.php?t=121577)

padilha007 03-17-2010 10:18

[Solved] Detect Distance
 
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

Exolent[jNr] 03-17-2010 10:40

Re: Detect Distance
 
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; }

padilha007 03-17-2010 19:58

Re: Detect Distance
 
Tnx, works perfect. But who i can do to get door id?



Exolent[jNr] 03-18-2010 00:37

Re: Detect Distance
 
Edited code.

padilha007 03-18-2010 09:55

Re: Detect Distance
 
Tnx, works perfect ^^


All times are GMT -4. The time now is 08:49.

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