From a3ebfc85370ba876f4e310c693738b6f721ab2a9 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 21 Apr 2023 01:34:45 +1000 Subject: [PATCH] update points syntax and add new functions Still had the deprecated syntax documented. --- docs/ox_lib/Points/Lua/Client.md | 61 +++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/docs/ox_lib/Points/Lua/Client.md b/docs/ox_lib/Points/Lua/Client.md index c949e1f9..c355cd93 100644 --- a/docs/ox_lib/Points/Lua/Client.md +++ b/docs/ox_lib/Points/Lua/Client.md @@ -2,16 +2,36 @@ Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates. -```lua -lib.points.new(coords, distance, data) -``` +### CPoint +A table representing a point, with the following properties. + +* id: `number` * coords: `vector3` * distance: `number` -* data: `table` + * The distance for the player to be "inside" a point (i.e. the point's radius). +* currentDistance: `number` + * The players current distance from the centre of the point. +* isClosest?: `boolean` +* remove: `function()` + * Removes the point from the points registry. + +### lib.points.new ```lua -local point = lib.points.new(playerCoords, 5, { +lib.points.new(data) +``` + +* data: `table` + * coords: `vector3` + * distance: `number` + +**Returns:** CPoint + +```lua +local point = lib.points.new({ + coords = GetEntityCoords(cache.ped), + distance = 5, dunak = 'nerd', }) @@ -27,14 +47,37 @@ function point:nearby() DrawMarker(2, self.coords.x, self.coords.y, self.coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 200, 20, 20, 50, false, true, 2, nil, nil, false) if self.currentDistance < 1 and IsControlJustReleased(0, 38) then - print('inside marker', self.id) - print(self.dunak) + print('inside marker', self.id, 'dunak is a '.. self.dunak) end end ``` -Points can be deleted by using the remove method. +### lib.points.getAllPoints + +Get a table of all points created in the resource. ```lua -point:remove() +lib.points.getAllPoints() ``` + +**Return:** `table` + +### lib.points.getNearbyPoints + +Get an array of all points in range of the player. + +```lua +lib.points.getNearbyPoints() +``` + +**Return:** `CPoint[]` + +### lib.points.getClosestPoint + +Get the data for the closest point to the player. + +```lua +lib.points.getClosestPoint() +``` + +**Returns:** `CPoint`