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/ped): improve documentation for SET_PED_MIN_GROUND_TIME_FOR_STUNGUN #1183

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
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
81 changes: 77 additions & 4 deletions PED/SetPedMinGroundTimeForStungun.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,84 @@ ns: PED
void SET_PED_MIN_GROUND_TIME_FOR_STUNGUN(Ped ped, int ms);
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved
```

Overwrites the minimum time the ped will stay on the ground for after being stunned. Setting this while the ped is stunned will not alter the duration of the current stun (but will still effect future stunns).
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved

Unlike what this native's name suggests, it also effects the time for other "weapons", such as WEAPON_ELECTRIC_FENCE.
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved

Passing a negative value (usually -1) into the second parameter (ms) will reset the ground time back to default (ground time will then depend on the weapon that inflicts the stun).
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved

## Parameters
* **ped**: The ped to set the min ground time for
* **ms**: The minimum time in milliseconds
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved

## Examples
```lua
-- This sets the minimum stun ground time for the player's ped to 10 seconds (and re-applies it if the player's ped changes)

local currentPed = 0
CreateThread(function()
while true do
local playerPed = PlayerPedId()

-- Checks if the player ped has changed
if currentPed ~= playerPed then
currentPed = playerPed

-- Sets the minimum stun ground time to 10 seconds
SetPedMinGroundTimeForStungun(currentPed, 10000)
end

Wait(1000)
end
end)
```
Ped will stay on the ground after being stunned for at lest ms time. (in milliseconds)

```js
// This sets the minimum stun ground time for the player's ped to 10 seconds (and re-applies it if the player's ped changes)

let currentPed = 0;
Delay = (ms) => new Promise(res => setTimeout(res, ms));

setTick(async () => {
const playerPed = PlayerPedId();

// Checks if the player ped has changed
if (currentPed != playerPed) {
currentPed = playerPed;

// Sets the minimum stun ground time to 10 seconds
SetPedMinGroundTimeForStungun(currentPed, 10000);
};

await Delay(1000);
});
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved
```

## Parameters
* **ped**:
* **ms**:
```cs
// This sets the minimum stun ground time for the player's ped to 10 seconds (and re-applies it if the player's ped changes)

using static CitizenFX.Core.Native.API;
// ...

private int currentPed = 0;

public Main()
{
Tick += OnTick;
}

private async Task OnTick()
{
var playerPed = Game.PlayerPed.Handle;
MadsLeander marked this conversation as resolved.
Show resolved Hide resolved

// Checks if the player ped has changed
if (currentPed != playerPed)
{
currentPed = playerPed;

// Sets the minimum stun ground time to 10 seconds
SetPedMinGroundTimeForStungun(currentPed, 10000);
}

await BaseScript.Delay(1000);
}
Loading