on Player Is InWater function

Kewun

  • Hero Member
  • Posts: 785
on Player Is InWater function
« on September 11th, 2016, 07:19 PM »
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

  • Sr. Member
  • Posts: 404

Kewun

  • Hero Member
  • Posts: 785
Re: on Player Is InWater function
« Reply #2, on September 11th, 2016, 07:24 PM »
well i trought about that
but there is many water places and im lazy to put all pos's ;c

vito

  • Sr. Member
  • Posts: 404
Re: on Player Is InWater function
« Reply #3, on September 11th, 2016, 11:11 PM »
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.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,804
.

aXXo

  • Full Member
  • Posts: 170
Re: on Player Is InWater function
« Reply #5, on September 13th, 2016, 08:20 PM »
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

  • LU Beta Tester
  • Posts: 245
Re: on Player Is InWater function
« Reply #6, on September 13th, 2016, 09:26 PM »Last edited on September 13th, 2016, 09:30 PM
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

  • Hero Member
  • Posts: 785
Re: on Player Is InWater function
« Reply #7, on September 14th, 2016, 04:15 AM »
Quote from aXXo on September 13th, 2016, 08:20 PM
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.
what is ray tracing? i never know

vito

  • Sr. Member
  • Posts: 404
Re: on Player Is InWater function
« Reply #8, on September 14th, 2016, 08:05 AM »Last edited on September 14th, 2016, 08:07 AM
Quote from Kewun on September 14th, 2016, 04:15 AM
what 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

  • Hero Member
  • Posts: 785
Re: on Player Is InWater function
« Reply #10, on September 15th, 2016, 08:18 PM »Last edited on September 15th, 2016, 08:22 PM
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

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,760