IsPointWithinColshape

From GTA Network Wiki
Jump to: navigation, search

IsPointWithinColshape
Server-Side Function

utilities-terminal.png Server-Side csharp.png C#

Checks if a Vector3 is within the bounds of a ColShape.

Syntax

bool NAPI.ColShape.IsPointWithinColshape(ColShape shape, Vector3 point);
  • shape: parameter input should be in ColShape type.
  • point: parameter input should be in Vector3 type.


NOTE: This function returns data in bool type.

Usage examples

Example: Kill a player if they walk into the area of a ColShape.

var shape = NAPI.ColShape.Create3DColShape(new Vector3(100.0f, 100.0f, 100.0f), new Vector3(200.0f, 200.0f, 200.0f), -1);

if(NAPI.ColShape.IsPointWithinColshape(shape, NAPI.Entity.GetEntityPosition(player)))
{
   NAPI.Player.SetPlayerHealth(player, -1);
}

This can also be written in OOP as:

var shape = NAPI.ColShape.Create3DColShape(new Vector3(100.0f, 100.0f, 100.0f), new Vector3(200.0f, 200.0f, 200.0f), -1);

if(shape.IsPointWithin(player.Postion)))
{
    player.Kill();
}

Changelog

Version Description
0.3.0.1 Release.

References