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(natives/interior): update interiors natives/examples #1104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
47 changes: 44 additions & 3 deletions INTERIOR/ActivateInteriorEntitySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,52 @@ aliases: ["0x55E86AF2712B36A1","_ENABLE_INTERIOR_PROP"]
void ACTIVATE_INTERIOR_ENTITY_SET(int interior, char* entitySetName);
```

Activates the entity set with the specified name in the given interior. If you want to disable a entity set, use [`DEACTIVATE_INTERIOR_ENTITY_SET`](#_0x420BD37289EEE162).

```
More info: http://gtaforums.com/topic/836367-adding-props-to-interiors/
NativeDB Introduced: v323
```

## Parameters
* **interior**:
* **entitySetName**:
* **interior**: The index of the interior.
* **entitySetName**: The name of the entity set to activate.

## Examples
```lua
-- Get the interior id for the casino penthouse
local interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641)

-- Activate certain entity sets for the casino penthouse
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open')
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open')
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro')
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter')
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03')
ActivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02')
```
```javascript
// Get the interior id for the casino penthouse
const interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);

// Activate certain entity sets for the casino penthouse
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03');
ActivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02');
```
```csharp
using static CitizenFX.Core.Native.API;

// Get the interior id for the casino penthouse
int interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);

// Activate certain entity sets for the casino penthouse
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter');
ActivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03');
ActivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02');
```
48 changes: 46 additions & 2 deletions INTERIOR/DeactivateInteriorEntitySet.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,52 @@ aliases: ["0x420BD37289EEE162","_DISABLE_INTERIOR_PROP"]
void DEACTIVATE_INTERIOR_ENTITY_SET(int interior, char* entitySetName);
```

Deactivates the entity set with the specified name in the given interior.

```
NativeDB Introduced: v323
```

## Parameters
* **interior**:
* **entitySetName**:
* **interior**: The index of the interior.
* **entitySetName**: The name of the entity set to deactivate.

## Examples
```lua
-- Get the interior id for the casino penthouse
local interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641)

-- Deactivate certain entity sets for the casino penthouse
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open')
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open')
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro')
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter')
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03')
DeactivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02')
```
```javascript
// Get the interior id for the casino penthouse
const interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);

// Deactivate certain entity sets for the casino penthouse
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03');
DeactivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02');
```
```csharp
using static CitizenFX.Core.Native.API;

// Get the interior id for the casino penthouse
int interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);

// Deactivate certain entity sets for the casino penthouse
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Spa_Bar_Open');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Media_Bar_Open');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Arcade_Retro');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Bar_Clutter');
DeactivateInteriorEntitySet(interiorID, 'Set_Pent_Clutter_03');
DeactivateInteriorEntitySet(interiorID, 'Set_pent_bar_light_02');
```
35 changes: 35 additions & 0 deletions INTERIOR/DisableMetroSystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
ns: INTERIOR
aliases: ["0x9E6542F0CE8E70A3"]
---
## DISABLE_METRO_SYSTEM

```c
// 0x9E6542F0CE8E70A3 0x5EF9C5C2
void DISABLE_METRO_SYSTEM(BOOL toggle);
```

Completely disables the metro system in the game.

```
NativeDB Introduced: v323
```

## Parameters
* **toggle**: A boolean value indicating whether to disable (`true`) or enable (`false`) the metro system.

## Examples
```lua
-- Disable metro system
DisableMetroSystem(true)
```
```javascript
// Disable metro system
DisableMetroSystem(true);
```
```csharp
using static CitizenFX.Core.Native.API;

// Disable metro system
DisableMetroSystem(true);
```
27 changes: 25 additions & 2 deletions INTERIOR/EnableExteriorCullModelThisFrame.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,33 @@ aliases: ["0xA97F257D0151A6AB","_HIDE_MAP_OBJECT_THIS_FRAME"]
void ENABLE_EXTERIOR_CULL_MODEL_THIS_FRAME(Hash mapObjectHash);
```

Culls exterior objects from rendering (G-buffer only) based on the model name hash. Primarily used in multiplayer apartments to hide the exterior shell of buildings. This native needs to be called every frame.

```
This is the native that is used to hide the exterior of GTA Online apartment buildings when you are inside an apartment.
NativeDB Introduced: v323
```

## Parameters
* **mapObjectHash**:
* **mapObjectHash**: The hash of the model name to cull

## Examples
```lua
CreateThread(function()
local buildingTopHash = GetHashKey("hei_kt1_08_buildingtop_a")
local emissiveHash = GetHashKey("hei_kt1_08_kt1_emissive_ema")
while (true) do
EnableExteriorCullModelThisFrame(buildingTopHash)
EnableExteriorCullModelThisFrame(emissiveHash)
Wait(0)
end
end)
```
```javascript
const buildingTopHash = GetHashKey("hei_kt1_08_buildingtop_a");
const emissiveHash = GetHashKey("hei_kt1_08_kt1_emissive_ema");

setTick(() => {
EnableExteriorCullModelThisFrame(buildingTopHash);
EnableExteriorCullModelThisFrame(emissiveHash);
});
```
14 changes: 0 additions & 14 deletions INTERIOR/EnableScriptCullModelThisFrame.md

This file was deleted.

50 changes: 50 additions & 0 deletions INTERIOR/EnableShadowCullModelThisFrame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
ns: INTERIOR
aliases: ["0x50C375537449F369", "_ENABLE_SCRIPT_CULL_MODEL_THIS_FRAME"]
---
## ENABLE_SHADOW_CULL_MODEL_THIS_FRAME

```c
// 0x50C375537449F369
void ENABLE_SHADOW_CULL_MODEL_THIS_FRAME(cs_type(Any) Hash mapObjectHash);
```

Culls exterior objects from rendering (cascade shadows only) based on the model name hash. Primarily used in multiplayer apartments to hide the exterior structure of buildings. This native needs to be called every frame and is generally used with [`ENABLE_EXTERIOR_CULL_MODEL_THIS_FRAME`](#_0xA97F257D0151A6AB).

```
NativeDB Introduced: v323
```

## Parameters
* **mapObjectHash**: The hash of the model name to cull from shadow rendering.

## Examples
```lua
CreateThread(function()
local buildingTopHash = GetHashKey("hei_kt1_08_buildingtop_a")
local emissiveHash = GetHashKey("hei_kt1_08_kt1_emissive_ema")
while (true) do
-- hei_kt1_08_buildingtop_a
EnableExteriorCullModelThisFrame(buildingTopHash)
EnableShadowCullModelThisFrame(buildingTopHash)
-- hei_kt1_08_kt1_emissive_ema
EnableExteriorCullModelThisFrame(emissiveHash)
EnableShadowCullModelThisFrame(emissiveHash)

Wait(0)
end
end)
```
```javascript
const buildingTopHash = GetHashKey("hei_kt1_08_buildingtop_a");
const emissiveHash = GetHashKey("hei_kt1_08_kt1_emissive_ema");

setTick(() => {
// hei_kt1_08_buildingtop_a
EnableExteriorCullModelThisFrame(buildingTopHash);
EnableShadowCullModelThisFrame(buildingTopHash);
// hei_kt1_08_kt1_emissive_ema
EnableExteriorCullModelThisFrame(emissiveHash);
EnableShadowCullModelThisFrame(emissiveHash);
});
```
38 changes: 36 additions & 2 deletions INTERIOR/IsInteriorEntitySetActive.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,43 @@ aliases: ["0x35F7DD45E8C0A16D","_IS_INTERIOR_PROP_ENABLED"]
BOOL IS_INTERIOR_ENTITY_SET_ACTIVE(int interior, char* entitySetName);
```

Determines whether the specified entity set is active within the given interior.

```
NativeDB Introduced: v323
```

## Parameters
* **interior**:
* **entitySetName**:
* **interior**: The index of the interior.
* **entitySetName**: The name of the entity set to check.

## Return value
A boolean value indicating whether the entity set is active (`true`) or not (`false`).

## Examples
```lua
-- Check if the entity set `Set_Pent_Spa_Bar_Open` (casino penthouse) is active or not
local interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641)
local entitySet = "Set_Pent_Spa_Bar_Open"
local isInteriorSetActive = IsInteriorEntitySetActive(interiorID, entitySet)

print("Entity Set Active: " .. isInteriorSetActive)
```
```javascript
// Check if the entity set `Set_Pent_Spa_Bar_Open` (casino penthouse) is active or not
const interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);
const entitySet = "Set_Pent_Spa_Bar_Open";
const isInteriorSetActive = IsInteriorEntitySetActive(interiorID, entitySet);

console.log(`Entity Set Active: ${isInteriorSetActive}`);
```
```csharp
using static CitizenFX.Core.Native.API;

// Check if the entity set `Set_Pent_Spa_Bar_Open` (casino penthouse) is active or not
int interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641);
string entitySet = "Set_Pent_Spa_Bar_Open";
bool isInteriorSetActive = IsInteriorEntitySetActive(interiorID, entitySet);

Debug.WriteLine($"Entity Set Active: {isInteriorSetActive}");
```
17 changes: 0 additions & 17 deletions INTERIOR/N_0x9e6542f0ce8e70a3.md

This file was deleted.

29 changes: 28 additions & 1 deletion INTERIOR/PinInteriorInMemory.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,33 @@ aliases: ["0x2CA429C029CCF247","_LOAD_INTERIOR"]
void PIN_INTERIOR_IN_MEMORY(int interior);
```

Instructs the interior system to load the specified interior into memory.

```
NativeDB Introduced: v323
```

## Parameters
* **interior**:
* **interior**: The index of the interior.

## Examples
```lua
CreateThread(function()

local interiorCoords = vector3(976.6364, 70.29476, 115.1641)
-- Coordinates of the interior
local interiorID = GetInteriorAtCoords(interiorCoords.x, interiorCoords.y, interiorCoords.z)

-- Load the interior into memory
PinInteriorInMemory(interiorID)

-- Wait until the interior is ready
repeat
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be best do do something below this while loop to show why you should wait?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like this?

CreateThread(function()
    -- Coordinates of the interior
    local interiorID = GetInteriorAtCoords(976.6364, 70.29476, 115.1641)
    
    -- Load the interior into memory
    PinInteriorInMemory(interiorID)
    
    -- Wait until the interior is ready
    repeat
        Wait(0)
    until IsInteriorReady(interiorID)
    
    -- Teleport the player to the interior
    local playerPed = PlayerPedId()
    SetEntityCoords(playerPed, 976.6364, 70.29476, 115.1641)
end)

Wait(0)
until IsInteriorReady(interiorID)

-- Since the interior is ready, we can now teleport the player to the interior
local playerPed = PlayerPedId()
SetEntityCoords(playerPed, interiorCoords.x, interiorCoords.y, interiorCoords.z)
end)
```
Loading