Raised This Month: $ Target: $400
 0% 

get water entity index where player is swimming.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-22-2013 , 15:38   Re: get water entity index where player is swimming.
Reply With Quote #1

Can traceline touch the water?
.Dare Devil. is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-22-2013 , 15:41   Re: get water entity index where player is swimming.
Reply With Quote #2

Have you tried any of these ways:
1. register_touch("player", "func_water", "func");
2.
PHP Code:
#include <amxmodx>
#include <engine>

public client_PreThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE;
    
    if(
entity_get_int(idEV_INT_flags) & FL_INWATER)
    {
        new 
Float:FlVecOrigin[3];
        
entity_get_vector(idEV_VEC_originFlVecOrigin);
        
        new 
ent = -1;
        while((
ent find_ent_in_sphere(entFlVecOrigin36.0)) != 0)
        {
            new 
szClassname[15];
            
entity_get_string(entEV_SZ_classnameszClassnamecharsmax(szClassname));
            if(
equal(szClassname"func_water"))
            {
                
// do what you want, the index is ent ^^ :D
            
}
        }
    }
    return 
PLUGIN_CONTINUE;

didoWEE is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-22-2013 , 16:21   Re: get water entity index where player is swimming.
Reply With Quote #3

Quote:
Originally Posted by didoWEE View Post
Have you tried any of these ways:
1. register_touch("player", "func_water", "func");
2.
PHP Code:
#include <amxmodx>
#include <engine>

public client_PreThink(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE;
    
    if(
entity_get_int(idEV_INT_flags) & FL_INWATER)
    {
        new 
Float:FlVecOrigin[3];
        
entity_get_vector(idEV_VEC_originFlVecOrigin);
        
        new 
ent = -1;
        while((
ent find_ent_in_sphere(entFlVecOrigin36.0)) != 0)
        {
            new 
szClassname[15];
            
entity_get_string(entEV_SZ_classnameszClassnamecharsmax(szClassname));
            if(
equal(szClassname"func_water"))
            {
                
// do what you want, the index is ent ^^ :D
            
}
        }
    }
    return 
PLUGIN_CONTINUE;

register_touch is not working even when i set to water entity entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)

2. way is working i think but its bad, i see more ways to do that but they are ...
one way is to create solid entity for valve hammer and place it where water is.
water have a name
and that solid ent have water name in targename.
it will give me more work but it is better to cpu i think.
traceline is also one way but i dont remember that can traceline catch water entity.
.Dare Devil. is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-22-2013 , 16:41   Re: get water entity index where player is swimming.
Reply With Quote #4

Quote:
Originally Posted by .Dare Devil. View Post
register_touch is not working even when i set to water entity entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)

2. way is working i think but its bad, i see more ways to do that but they are ...
one way is to create solid entity for valve hammer and place it where water is.
water have a name
and that solid ent have water name in targename.
it will give me more work but it is better to cpu i think.
traceline is also one way but i dont remember that can traceline catch water entity.
Code:
// Used by the traceresult() native.
enum
{
	TR_AllSolid,			// (int) if true, plane is not valid
	TR_StartSolid,		// (int) if true, the initial point was in a solid area
	TR_InOpen,		// (int)
	TR_InWater,	// (int)
	TR_Fraction,			// (float) time completed, 1.0 = didn't hit anything
	TR_EndPos,			// (vector) final position
	TR_PlaneDist,		// (float)
	TR_PlaneNormal,		// (vector) surface normal at impact
	TR_Hit,				// (entity) entity the surface is on
	TR_Hitgroup			// (int) 0 == generic, non zero is specific body part
};
should do


Code:
#include <amxmodx> #include <engine> public client_PreThink(id) {     if(!is_user_alive(id)) return PLUGIN_CONTINUE           if(entity_get_int(id, EV_INT_flags) & FL_INWATER) {         new entlist[1]         if (find_sphere_class(id, "func_water", 1.0, entlist, sizeof(entlist))) {              //stuff         }     }     return PLUGIN_CONTINUE }

Last edited by jimaway; 04-22-2013 at 16:53.
jimaway is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-22-2013 , 16:44   Re: get water entity index where player is swimming.
Reply With Quote #5

Quote:
Originally Posted by jimaway View Post
Code:
// Used by the traceresult() native.
enum
{
	TR_AllSolid,			// (int) if true, plane is not valid
	TR_StartSolid,		// (int) if true, the initial point was in a solid area
	TR_InOpen,		// (int)
	TR_InWater,	// (int)
	TR_Fraction,			// (float) time completed, 1.0 = didn't hit anything
	TR_EndPos,			// (vector) final position
	TR_PlaneDist,		// (float)
	TR_PlaneNormal,		// (vector) surface normal at impact
	TR_Hit,				// (entity) entity the surface is on
	TR_Hitgroup			// (int) 0 == generic, non zero is specific body part
};
thanks!
.Dare Devil. 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 10:57.


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