on Player Is InWater function

Started by Kewun, Sep 11, 2016, 06:19 PM

Previous topic - Next topic

Kewun

I dont have any idea how to do the function onPlayerIsInWater

this is called if player is drowning in the water  " swimming like"

anyone help me ?

vito

maybe check his Pos.z (exclude one area in the little havana)

Kewun

well i trought about that
but there is many water places and im lazy to put all pos's ;c

vito

Water level is same for whole map, just few places below water (I know only one actually). So you need to make an exception in the code and all be fine.
Try also to test http://wiki.vc-mp.org/wiki/OnPlayerActionChange action's list is not documented anywhere so I don't know maybe you will find something about water there.

.

Quote from: vito on Sep 11, 2016, 10:11 PMaction's list is not documented anywhere so I don't know maybe you will find something about water there.

There isn't. Although, I'm not sure if they've added any new ones. I'm always behind on these things so don't take my word for it.
.

aXXo

Should be achievable with Ray Tracing
Trace a ray between ( player.Pos.X, player.Pos.Y, player.Pos.Z + 5) and ( player.Pos.X, player.Pos.Y, -10 ) with flags only detecting collisions with objects and buildings.

Check the entity it collides with.
If the entity is Sea bed, coastal rocks or some submerged ship means the player is in or hovering above water.

Though, vito's suggestion is also reliable and easier to implement.

Murdock

#6
I believe there's an internal function in VC for this that returns whether the player is in water, but it would need the devs to sync that flag and add it as attribute to the squirrel plugin (player.InWater, vehicle.InWater, object.InWater)

If any devs are alive willing to look into this, here are the OPcodes for the functions:
04AD IS_CHAR_IN_WATER
0521 IS_CHAR_DROWNING_IN_WATER
02BF IS_CAR_IN_WATER
04E7 IS_OBJECT_IN_WATER

Kewun

Quote from: aXXo on Sep 13, 2016, 07:20 PMShould be achievable with Ray Tracing
Trace a ray between ( player.Pos.X, player.Pos.Y, player.Pos.Z + 5) and ( player.Pos.X, player.Pos.Y, -10 ) with flags only detecting collisions with objects and buildings.

Check the entity it collides with.
If the entity is Sea bed, coastal rocks or some submerged ship means the player is in or hovering above water.

Though, vito's suggestion is also reliable and easier to implement.

what is ray tracing? i never know

vito

#8
Quote from: Kewun on Sep 14, 2016, 03:15 AMwhat is ray tracing? i never know
Its like a virtual bullet shotted from Vector#1 to Vector#2. If it will hit something between #1 and #2 you can read what and where.

Kewun

i dont know how.. maybe a little example ? ;c

Kewun

#10
so a timer which checks player.Pos.z if i understand good

ill try then

edit: forgot about onPlayerMove il try that too

EK.IceFlake

Check his animation if it is drowning animation == he is in water