mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
move ox_lib modules to subdirectory
This commit is contained in:
1 parent
97b129e0fa
commit
ba094e1fb3
42 files changed
+1
-1
No files matched your search
@@ -0,0 +1,46 @@
|
||||
# Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
```ts
|
||||
Point<T>({coords, distance, onEnter, onExit, nearby, args})
|
||||
```
|
||||
|
||||
* coords: `number[]`
|
||||
* distance: `number`
|
||||
* onEnter?: `function`
|
||||
* onExit?: `function`
|
||||
* nearby?: `function`
|
||||
* args?: `T`
|
||||
|
||||
```ts
|
||||
import { Point, cache } from '@overextended/ox_lib/client'
|
||||
|
||||
function nearby(this: Point<{dunak: string}>) {
|
||||
// @ts-ignore
|
||||
DrawMarker(2, this.coords.x, this.coords.y, this.coords.z, 0, 0, 0, 0, 180, 0, 1, 1, 1, 200, 20, 20, 50, false, true, 2, false, null, null, false)
|
||||
|
||||
if (this.currentDistance && this.currentDistance < 1 && IsControlJustReleased(0, 38)) {
|
||||
console.log('Inside marker', this.id)
|
||||
console.log(this.args?.dunak)
|
||||
}
|
||||
}
|
||||
|
||||
const point = new Point({
|
||||
coords: GetEntityCoords(cache.ped, false),
|
||||
distance: 5,
|
||||
nearby: nearby,
|
||||
args: {
|
||||
dunak: 'nerd'
|
||||
}
|
||||
})
|
||||
|
||||
point.onEnter = () => {
|
||||
console.log('Entered range of point', point.id)
|
||||
}
|
||||
|
||||
point.onExit = () => {
|
||||
console.log('Left range of point', point.id)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
### CPoint
|
||||
|
||||
A table representing a point, with the following properties.
|
||||
|
||||
* id: `number`
|
||||
* coords: `vector3`
|
||||
* distance: `number`
|
||||
* 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
|
||||
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',
|
||||
})
|
||||
|
||||
function point:onEnter()
|
||||
print('entered range of point', self.id)
|
||||
end
|
||||
|
||||
function point:onExit()
|
||||
print('left range of point', self.id)
|
||||
end
|
||||
|
||||
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, false, nil, nil, false)
|
||||
|
||||
if self.currentDistance < 1 and IsControlJustReleased(0, 38) then
|
||||
print('inside marker', self.id, 'dunak is a '.. self.dunak)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
### lib.points.getAllPoints
|
||||
|
||||
Get a table of all points created in the resource.
|
||||
|
||||
```lua
|
||||
lib.points.getAllPoints()
|
||||
```
|
||||
|
||||
**Return:** `table<number, CPoint>`
|
||||
|
||||
### 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`
|
||||
Reference in new issue
Block a user