self.Entity:WaterLevel() > 0 doesn't work

Hi, it seems that WaterLevel doesn’t seem to work anymore. Is there another way of detecting the entity is in the water?

Example is what you want.

:O, so he broke it again? :frowning:

Ok thanks. What do i use if there out of water CONTENTS_EMPTY ?

Could just do “!=” or an else to determine that. Not sure about CONTENTS_EMPTY.

If you’re really curious, put this in console:

lua_run_cl print(util.PointContents(LocalPlayer():GetPos()))


0 = Out of water
1 = 1/3rd in water
2 = 2/3rd in water
3 = completly in water

That’s what it’s supposed to return…

Point is it doesn’t

Works fine for me

How are you using it?

if self:WaterLevel() > 0.3 then
self.Damage = 200

Works fine.

Yep, works fine using the water levels (0, 1, 2, 3).

Oh so its 0.# . I thought it was just an interger.

It is an integer. It seems to work correctly only on players and NPCs though, so if you are using it for a SENT, it might be the reason why it doesn’t work.

Oh ok. That will be why. Im running it on a SENT.

Yea it used to only work on Players and NPCs, then Garry applied a fix without anyone knowing about it, and now it’s broken again it seems if it doesn’t work anymore on sents again…

Wish Garry could keep something working once he fixed it for the 1st time…

For the record, I’m using this in two different SEnts and it’s working fine in both.
[lua]if (self:WaterLevel() >= 1) then //We are in water
//stuff here

Woo. Finally got it working