Raised This Month: $7 Target: $400
 1% 

Detect if player is in the water


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 02-14-2018 , 05:38   Detect if player is in the water
Reply With Quote #1

Title. Thanks
__________________
Airkish is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2018 , 06:07   Re: Detect if player is in the water
Reply With Quote #2

Try the below using CONTENTS_WATER. I forget if it works 100% for water but I've used it for in-wall and outside of map checking.
PHP Code:
new Float:fOrigin];
peviEntity pev_origin fOrigin );
if ( 
engfuncEngFunc_PointContents fOrigin ) == CONTENTS_SKY )
{


__________________

Last edited by Bugsy; 02-14-2018 at 06:11.
Bugsy is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-14-2018 , 06:57   Re: Detect if player is in the water
Reply With Quote #3

PHP Code:
/**
* 0 - Not in water
* 1 - Waiding
* 2 - Mostly submerged
* 3 - Completely submerged
*
* Type: integer
*/
pev_waterlevel
__________________
klippy is offline
Old 02-14-2018, 07:59
crashbandicoot
This message has been deleted by HamletEagle. Reason: Stop advertising your question in random threads
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 02-14-2018 , 16:36   Re: Detect if player is in the water
Reply With Quote #4

Quote:
Originally Posted by KliPPy View Post
PHP Code:
/**
* 0 - Not in water
* 1 - Waiding
* 2 - Mostly submerged
* 3 - Completely submerged
*
* Type: integer
*/
pev_waterlevel
so if pev_waterlevel > 0 player is in the water?
How do I actually use it, because I need to check if Killer is in the water. Thanks.
__________________
Airkish is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-14-2018 , 16:55   Re: Detect if player is in the water
Reply With Quote #5

Quote:
Originally Posted by Airkish View Post
so if pev_waterlevel > 0 player is in the water?
How do I actually use it, because I need to check if Killer is in the water. Thanks.
PHP Code:
new waterLevel pev(playerIdpev_waterlevel); 
Depends on what your definition of "in water" is. 0 is out of water, 4 is completely submerged as I've already posted.
__________________
klippy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2018 , 20:58   Re: Detect if player is in the water
Reply With Quote #6

Quote:
Originally Posted by Airkish View Post
so if pev_waterlevel > 0 player is in the water?
How do I actually use it, because I need to check if Killer is in the water. Thanks.
As KliPPy said, what is 'in the water'. If you mean standing knee-deep in water then pev_waterlevel returns 1, deeper = 2, fully in water is 3. If all you care about is in water at any level, a non-zero check is all you need (see below).
PHP Code:
if ( pevid pev_waterlevel ) )
{
    
//player is in water

__________________

Last edited by Bugsy; 02-14-2018 at 20:59.
Bugsy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 02-15-2018 , 05:24   Re: Detect if player is in the water
Reply With Quote #7

Hi
Is there a way to Detect if player killed by water ?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-15-2018 , 05:29   Re: Detect if player is in the water
Reply With Quote #8

Quote:
Originally Posted by abdobiskra View Post
Hi
Is there a way to Detect if player killed by water ?
Open your own topic.
__________________
klippy is offline
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 02-15-2018 , 05:51   Re: Detect if player is in the water
Reply With Quote #9

Yeah, here :
https://forums.alliedmods.net/showthread.php?t=305310
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
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 02:57.


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