diff --git a/resources/[soz]/soz-core/src/client/player/player.antifalldown.provider.ts b/resources/[soz]/soz-core/src/client/player/player.antifalldown.provider.ts new file mode 100644 index 0000000000..3e17094a65 --- /dev/null +++ b/resources/[soz]/soz-core/src/client/player/player.antifalldown.provider.ts @@ -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 { + 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); + } + } +} diff --git a/resources/[soz]/soz-core/src/client/player/player.module.ts b/resources/[soz]/soz-core/src/client/player/player.module.ts index fbb89fd50b..854eb60593 100644 --- a/resources/[soz]/soz-core/src/client/player/player.module.ts +++ b/resources/[soz]/soz-core/src/client/player/player.module.ts @@ -1,5 +1,6 @@ import { Module } from '../../core/decorators/module'; import { PlayerAnimationProvider } from './player.animation.provider'; +import { PlayerAntiFallDownProvider } from './player.antifalldown.provider'; import { PlayerDiseaseProvider } from './player.disease.provider'; import { PlayerEffectProvider } from './player.effect.provider'; import { PlayerHealthProvider } from './player.health.provider'; @@ -19,6 +20,7 @@ import { ProgressProvider } from './progress.provider'; @Module({ providers: [ PlayerAnimationProvider, + PlayerAntiFallDownProvider, PlayerDiseaseProvider, PlayerEffectProvider, PlayerHealthProvider,