Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(boat/anchor): update anchor natives #1193

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 61 additions & 15 deletions VEHICLE/CanAnchorBoatHere.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,61 @@
---
ns: VEHICLE
aliases: ["0x2467A2D807D37CA3","_GET_BOAT_ANCHOR","_CAN_BOAT_BE_ANCHORED"]
---
## CAN_ANCHOR_BOAT_HERE

```c
// 0x26C10ECBDA5D043B 0xE97A4F5E
BOOL CAN_ANCHOR_BOAT_HERE(Vehicle vehicle);
```

## Parameters
* **vehicle**:

## Return value
---
ns: VEHICLE
aliases: ["0x2467A2D807D37CA3","_GET_BOAT_ANCHOR","_CAN_BOAT_BE_ANCHORED"]
---
## CAN_ANCHOR_BOAT_HERE

```c
// 0x26C10ECBDA5D043B 0xE97A4F5E
BOOL CAN_ANCHOR_BOAT_HERE(Vehicle boat);
```

Checks if a boat can be anchored at its present position without possibly intersecting collision later.

```
NativeDB Introduced: v323
```

## Parameters
* **boat**: The boat to check.

## Return value
Returns `true` if the boat can be safely anchored at its current position, `false` otherwise.

## Examples
```lua
local boat = GetVehiclePedIsIn(PlayerPedId(), false)
if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end

if CanAnchorBoatHere(boat) then
print("It's safe to anchor the boat here")
else
print("It's not safe to anchor the boat at this location")
end
```

```js
const boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return;

if (CanAnchorBoatHere(boat)) {
console.log("It's safe to anchor the boat here");
} else {
console.log("It's not safe to anchor the boat at this location");
}
```

```cs
using static CitizenFX.Core.Native.API;

int boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return;

if (CanAnchorBoatHere(boat))
{
Debug.WriteLine("It's safe to anchor the boat here");
}
else
{
Debug.WriteLine("It's not safe to anchor the boat at this location");
}
```
61 changes: 61 additions & 0 deletions VEHICLE/CanAnchorBoatHereIgnorePlayers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
ns: VEHICLE
aliases: ["_CAN_BOAT_BE_ANCHORED_2", "_CAN_ANCHOR_BOAT_HERE_2"]
---
## CAN_ANCHOR_BOAT_HERE_IGNORE_PLAYERS

```c
// 0x24F4121D07579880
BOOL CAN_ANCHOR_BOAT_HERE_IGNORE_PLAYERS(Vehicle boat);
```

Checks if a boat can be anchored at its present position, ignoring any players standing on the boat.

```
NativeDB Introduced: v678
```

## Parameters
* **boat**: The boat to check.

## Return value
Returns `true` if the boat can be safely anchored at its current position (ignoring players on the boat), `false` otherwise.

## Examples
```lua
local boat = GetVehiclePedIsIn(PlayerPedId(), false)
if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end

if CanAnchorBoatHereIgnorePlayers(boat) then
print("It's safe to anchor the boat here, ignoring players on the boat")
else
print("It's not safe to anchor the boat at this location, even ignoring players")
end
```

```js
const boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return;

if (CanAnchorBoatHereIgnorePlayers(boat)) {
console.log("It's safe to anchor the boat here, ignoring players on the boat");
} else {
console.log("It's not safe to anchor the boat at this location, even ignoring players");
}
```

```cs
using static CitizenFX.Core.Native.API;

int boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return;

if (CanAnchorBoatHereIgnorePlayers(boat))
{
Debug.WriteLine("It's safe to anchor the boat here, ignoring players on the boat");
}
else
{
Debug.WriteLine("It's not safe to anchor the boat at this location, even ignoring players");
}
```
19 changes: 0 additions & 19 deletions VEHICLE/CanAnchorBoatHere_2.md

This file was deleted.

25 changes: 25 additions & 0 deletions VEHICLE/IsBoatAnchored.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
ns: VEHICLE
aliases: ["0xB0AD1238A709B1A2", "_IS_BOAT_ANCHORED_AND_FROZEN"]
---
## IS_BOAT_ANCHORED

```c
// 0xB0AD1238A709B1A2
BOOL IS_BOAT_ANCHORED(Vehicle boat);
```

Checks if a boat is currently anchored.

This native is a getter for [SET_BOAT_ANCHOR](#_0x75DBEC174AEEAD10).


```
NativeDB Introduced: v573
```

## Parameters
* **boat**: The boat to check.

## Return value
Returns `true` if the boat is currently anchored, `false` otherwise.
19 changes: 0 additions & 19 deletions VEHICLE/IsBoatAnchoredAndFrozen.md

This file was deleted.

99 changes: 85 additions & 14 deletions VEHICLE/SetBoatAnchor.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,85 @@
---
ns: VEHICLE
---
## SET_BOAT_ANCHOR

```c
// 0x75DBEC174AEEAD10 0xA3906284
void SET_BOAT_ANCHOR(Vehicle vehicle, BOOL toggle);
```

## Parameters
* **vehicle**:
* **toggle**:

---
ns: VEHICLE
---
## SET_BOAT_ANCHOR

```c
// 0x75DBEC174AEEAD10 0xA3906284
void SET_BOAT_ANCHOR(Vehicle boat, BOOL toggle);
```

Sets the anchor state for a boat.

```
NativeDB Introduced: v323
```

**Note**: You might want to check if you can use your anchor before with [CAN_ANCHOR_BOAT_HERE](#_0x26C10ECBDA5D043B).

## Parameters
* **boat**: The target boat.
* **toggle**: Set the anchor state `true` deploys the anchor, false `raises` it.

## Examples
```lua
local boat = GetVehiclePedIsIn(PlayerPedId(), false)
if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end

-- Check if we can anchor the boat here
if CanAnchorBoatHere(boat) then
-- Deploy the boat's anchor
SetBoatAnchor(boat, true)

-- Wait for 10 seconds
Wait(10000)

-- Raise the boat's anchor
SetBoatAnchor(boat, false)
else
print("Cannot anchor the boat at this location")
end
```

```js
const boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return;

// Check if we can anchor the boat here
if (CanAnchorBoatHere(boat)) {
// Deploy the boat's anchor
SetBoatAnchor(boat, true);

// Wait for 10 seconds
await new Promise(resolve => setTimeout(resolve, 10000));

// Raise the boat's anchor
SetBoatAnchor(boat, false);
} else {
console.log("Cannot anchor the boat at this location");
}
```

```cs
using CitizenFX.Core;
using static CitizenFX.Core.Native.API;

int boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return;

// Check if we can anchor the boat here
if (CanAnchorBoatHere(boat))
{
// Deploy the boat's anchor
SetBoatAnchor(boat, true);

// Wait for 10 seconds
await BaseScript.Delay(10000);

// Raise the boat's anchor
SetBoatAnchor(boat, false);
}
else
{
Debug.WriteLine("Cannot anchor the boat at this location");
}
```
16 changes: 0 additions & 16 deletions VEHICLE/SetBoatFrozenWhenAnchored.md

This file was deleted.

51 changes: 51 additions & 0 deletions VEHICLE/SetBoatLowLodAnchorDistance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
ns: VEHICLE
aliases: ["0xE842A9398079BD82","_SET_BOAT_ANCHOR_BUOYANCY_COEFFICIENT", "_SET_BOAT_MOVEMENT_RESISTANCE"]
---
## SET_BOAT_LOW_LOD_ANCHOR_DISTANCE

```c
// 0xE842A9398079BD82 0x66FA450C
void SET_BOAT_LOW_LOD_ANCHOR_DISTANCE(Vehicle boat, float value);
```

Sets the distance from the player at which anchored boats switch between high and low LOD (Level of Detail) buoyancy mode.

```
NativeDB Introduced: v323
```

## Parameters
* **boat**: The target boat.
* **value**: The distance at which the LOD switch occurs. Set to `-1.0` to reset the LOD distance to the default value.

## Examples

```lua
local boat = GetVehiclePedIsIn(PlayerPedId(), false)
if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end

-- Set the low LOD anchor distance to 100 units
SetBoatLowLodAnchorDistance(boat, 100.0)
print("Set low LOD anchor distance to 100 units")
```

```js
const boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return;

// Set the low LOD anchor distance to 100 units
SetBoatLowLodAnchorDistance(boat, 100.0);
console.log("Set low LOD anchor distance to 100 units");
```

```cs
using static CitizenFX.Core.Native.API;

int boat = GetVehiclePedIsIn(PlayerPedId(), false);
if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return;

// Set the low LOD anchor distance to 100 units
SetBoatLowLodAnchorDistance(boat, 100.0f);
Debug.WriteLine("Set low LOD anchor distance to 100 units");
```
15 changes: 0 additions & 15 deletions VEHICLE/SetBoatMovementResistance.md

This file was deleted.

Loading
Loading