Raised This Month: $ Target: $400
 0% 

[Solved] About entity distance.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-06-2013 , 10:38   [Solved] About entity distance.
Reply With Quote #1

Hi, currently i modifying an original tripmine plugin and port into ZombieMod, but how can i check distance between tripmine and other tripmine? i want to avoid player from planting the new tripmine in the planted tripmine's origin (stacking). Errkk how to explain.. see this screenshot.

[IMG]http://s17.************/k2x646ne7/2013_11_01_00005.png[/IMG]
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 11-07-2013 at 02:43. Reason: Found a stock on internet.
yokomo is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-06-2013 , 12:08   Re: [Help] About entity distance.
Reply With Quote #2

entity_range can help you
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-06-2013 , 12:46   Re: [Help] About entity distance.
Reply With Quote #3

Quote:
Originally Posted by NiHiLaNTh View Post
entity_range can help you
I know that native but how can i detect the range if more than 1 tripmine is there? i mean nearest.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 11-06-2013 at 12:46.
yokomo is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 11-06-2013 , 13:35   Re: [Help] About entity distance.
Reply With Quote #4

Code:
new mine = -1, Float:vecSrc[3], class[32];
vecSrc represents origin where next mine should be planted

const SEARCH_RADIUS = 15.0

while((mine=engfunc(EngFunc_FindEntityInSphere, mine, vecSrc, SEARCH_RADIUS))>0)
{
     entity_get_string(mine, EV_SZ_classname, class, charsmax(class));

     if( equal( class, "YOUR_MINE_CLASSNAME" ) )
     {
          /* mine has been already planted nearby */
          break;
      }
}
__________________


Last edited by NiHiLaNTh; 11-06-2013 at 13:37.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 11-06-2013 , 13:55   Re: [Help] About entity distance.
Reply With Quote #5

Not sure about this....
PHP Code:
#include <fakemeta>
#include <hamsandwich>

stock CanPlant(idFloat:vOrigin[3])
{
    new 
iEnt
    
while( ( iEnt engfunc(EngFunc_FindEntityInSphereget_maxplayers(), vOrigin100.0 /* ??? i really don't know */) ) )
    {
    
        
//new Float:vEntOrigin[3];
        //pev(iEnt, pev_origin, vEntOrigin)
        
        
if(!ExecuteHam(Ham_FVisibleidiEnt)) continue;
        
//if(!ExecuteHam(Ham_FVecVisible, id, vEntOrigin) ) continue;
        
        
new Float:vMins[3], Float:vMaxs[3];
        
        
pev(iEntpev_minsvMins);
        
pev(iEntpev_maxsvMaxs);
        
        new 
Float:vCheckOrigin[3]
        for(new 
i3i++, vCheckOrigin[0] = vOrigin[0],
        
vCheckOrigin[1] = vOrigin[1], vCheckOrigin[2] = vOrigin[2])
        {
            
vCheckOrigin[i] += vMins[i];
            if(
engfunc(EngFunc_PointContentsvCheckOrigin) == CONTENTS_SOLID)
            {
                return 
0;
            }
            
        }
        
        for(new 
i3i++, vCheckOrigin[0] = vOrigin[0],
        
vCheckOrigin[1] = vOrigin[1], vCheckOrigin[2] = vOrigin[2])
        {
            
vCheckOrigin[i] += vMaxs[i];
            if(
engfunc(EngFunc_PointContentsvCheckOrigin) == CONTENTS_SOLID)
            {
                return 
0;
            }
        }
    }
    
    return 
1;

__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-07-2013 , 02:41   Re: [Help] About entity distance.
Reply With Quote #6

Solved, found a stock on internet.

PHP Code:
IsOriginTooClose(const Float:origin[3])
{
    new 
bool:findentFloat:ent_origin[3]
    
find false
    ent 
= -1
    
while((ent engfunc(EngFunc_FindEntityByStringent"classname"ClassnameTripmine)))
    {
        
pev(entpev_originent_origin)
        if(
get_distance_f(originent_origin) <= 30.0)
        {
            
find true
            
break;
        }
    }
    
    if(!
find) return 0;
    
    return 
1;

__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo 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 23:18.


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