Skip to content

Commit

Permalink
feat(natives/streaming): examples and updated natives for switch tran…
Browse files Browse the repository at this point in the history
…sition
  • Loading branch information
spacevx committed Nov 23, 2023
1 parent 58e12b6 commit 68efcbd
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 65 deletions.
15 changes: 0 additions & 15 deletions MISC/SetCloudHatOpacity.md

This file was deleted.

45 changes: 45 additions & 0 deletions MISC/SetCloudsAlpha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
ns: MISC
aliases: ["0xF36199225D6D8C86", "_SET_CLOUD_HAT_OPACITY"]
---
## SET_CLOUDS_ALPHA

```c
// 0xF36199225D6D8C86
void SET_CLOUDS_ALPHA(float opacity);
```
Allows modification of the cloud intensity when the player is in a switch state [`IS_PLAYER_SWITCH_IN_PROGRESS`](#_0xD9D2CFFF49FAB35F).
You can set the player in a switch state with [`SWITCH_TO_MULTI_FIRSTPART`](#_0xAAB3200ED59016BC).
## Parameters
* **opacity**: The opacity value to set for clouds.
## Examples
```lua
-- Check if the player is in a Switch "state"
if IsPlayerSwitchInProgress() then
-- If the player is in a Switch state, set the clouds opacity to 1.0
SetCloudsAlpha(1.0)
end
```

```javascript
// Check if the player is in a Switch "state"
if (IsPlayerSwitchInProgress()) {
// If the player is in a Switch state, set the clouds opacity to 1.0
SetCloudsAlpha(1.0);
}
```

```csharp
using static CitizenFX.Core.Native.API;
// Check if the player is in a Switch "state"
if (IsPlayerSwitchInProgress()) {
// If the player is in a Switch state, set the clouds opacity to 1.0
SetCloudsAlpha(1f);
}
```
34 changes: 33 additions & 1 deletion STREAMING/GetPlayerSwitchState.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
ns: STREAMING
aliases: ["0x470555300D10B2A5"]
---
## GET_PLAYER_SWITCH_STATE

Expand All @@ -8,5 +9,36 @@ ns: STREAMING
int GET_PLAYER_SWITCH_STATE();
```


## Return value
- Returns 5 if the player is in the air (in a state of switch).
- Returns 12 if the player is either not in the air or if the switch is completed.

## Examples
```lua
local stateSwitch = GetPlayerSwitchState()
if stateSwitch == 5 then
-- Player is in the air
elseif stateSwitch == 12 then
-- Player is not in the air or switch is completed
end
```

```javascript
const stateSwitch = GetPlayerSwitchState();
if (stateSwitch == 5) {
// Player is in the air
} else if (stateSwitch == 12) {
// Player is not in the air or switch is completed
}
```

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

int stateSwitch = GetPlayerSwitchState();
if (stateSwitch == 5) {
// Player is in the air
} else if (stateSwitch == 12) {
// Player is not in the air or switch is completed
}
```
16 changes: 0 additions & 16 deletions STREAMING/SwitchInPlayer.md

This file was deleted.

33 changes: 0 additions & 33 deletions STREAMING/SwitchOutPlayer.md

This file was deleted.

51 changes: 51 additions & 0 deletions STREAMING/SwitchToMultiFirstpart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
ns: STREAMING
aliases: ["0xAAB3200ED59016BC", "_SWITCH_OUT_PLAYER"]
---
## SWITCH_TO_MULTI_FIRSTPART

```c
// 0xAAB3200ED59016BC 0xFB4D062D
void SWITCH_TO_MULTI_FIRSTPART(Ped ped, int flags, int switchType);
```
```
Doesn't act normally when used on Mount Chiliad.
```
You can check if the player is in a Switch state with [`IS_PLAYER_SWITCH_IN_PROGRESS`](#_0xD9D2CFFF49FAB35F).
## Parameters
* **ped**: The Ped (player character) for which the switch is initiated.
* **flags**: Flags control various functionalities: 0 for normal behavior, 1 for no transition, and 255 for Switch IN.
* **switchType**: Specifies the type of switch (0 - 3): 0 for 1 step towards ped, 1 for 3 steps out from ped, 2 for 1 step out from ped, and 3 for 1 step towards ped.
## Examples
```lua
-- Check if the player is in a Switch "state"
if not IsPlayerSwitchInProgress() then
-- If the player is not already in a Switch state, initiate a Switch
SwitchToMultiFirstPart(PlayerPedId(), 0, 1)
-- In this case, switchType is set to 1, which means "3 steps out from ped"
end
```

```javascript
// Check if the player is in a Switch "state"
if (!IsPlayerSwitchInProgress()) {
// If the player is not already in a Switch state, initiate a Switch
SwitchToMultiFirstPart(PlayerPedId(), 0, 1);
// In this case, switchType is set to 1, which means "3 steps out from ped" according to the documentation
}
```

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

// Check if the player is in a Switch "state"
if (!IsPlayerSwitchInProgress()) {
// If the player is not already in a Switch state, initiate a Switch
SwitchToMultiFirstPart(API.PlayerPedId(), 0, 1);
// In this case, switchType is set to 1, which means "3 steps out from ped" according to the documentation
}
```
48 changes: 48 additions & 0 deletions STREAMING/SwitchToMultiSecondpart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
ns: STREAMING
aliases: ["0xD8295AF639FD9CB8", "_SWITCH_IN_PLAYER"]
---
## SWITCH_TO_MULTI_SECONDPART

```c
// 0xD8295AF639FD9CB8 0x2349373B
void SWITCH_TO_MULTI_SECONDPART(Ped ped);
```
After using [`SWITCH_TO_MULTI_FIRSTPART`](#_0xAAB3200ED59016BC) , use this native to smoothly return the camera to the player's character.
## Parameters
* **ped**:
## Examples
```lua
RegisterCommand("switchPlayer", function()
if IsPlayerSwitchInProgress() then return end
local ped = PlayerPedId()
SwitchToMultiFirstPart(ped, 0, 1)
Citizen.Wait(5000)
SwitchToMultiSecondPart(ped)
end, false)
```

```javascript
RegisterCommand("switchPlayer", () => {
if (IsPlayerSwitchInProgress()) return;
const ped = PlayerPedId();
SwitchToMultiFirstPart(ped, 0, 1);
Delay(5000); // Delay doesn't exist, you have to make it yourself
SwitchToMultiSecondPart(ped);
}, false);
```

```csharp
using static CitizenFX.Core.Native.API;
RegisterCommand("switchPlayer", new Action<int, List<object>, string>(async (user, args, raw) =>
{
if (IsPlayerSwitchInProgress()) return;
Ped ped = PlayerPedId();
SwitchToMultiFirstPart(ped, 0, 1);
await Delay(5000);
SwitchToMultiSecondPart(ped);
}), false);
```

0 comments on commit 68efcbd

Please sign in to comment.