-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4772 from SOZ-Faut-etre-Sub/feat/no-fall-down
feat(player): add a anti fall down script
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
resources/[soz]/soz-core/src/client/player/player.antifalldown.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Provider } from '../../core/decorators/provider'; | ||
import { Tick } from '../../core/decorators/tick'; | ||
import { Vector3 } from '../../shared/polyzone/vector'; | ||
|
||
@Provider() | ||
export class PlayerAntiFallDownProvider { | ||
@Tick(5000) | ||
private async checkAntiFallDown(): Promise<void> { | ||
const position = GetEntityCoords(PlayerPedId(), true) as Vector3; | ||
// Force height to 5000 to get the correct ground Z | ||
const [, groundZ] = GetGroundZFor_3dCoord(position[0], position[1], 5000, false); | ||
|
||
if (position[2] > 1000) { | ||
return; | ||
} | ||
|
||
if (position[2] - groundZ < -10) { | ||
SetPedCoordsKeepVehicle(PlayerPedId(), position[0], position[1], groundZ + 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters