Skip to content

Commit

Permalink
Merge pull request #4772 from SOZ-Faut-etre-Sub/feat/no-fall-down
Browse files Browse the repository at this point in the history
feat(player): add a anti fall down script
  • Loading branch information
joelwurtz authored Sep 17, 2023
2 parents 44ee5ac + c8213f9 commit 3f22046
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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);
}
}
}
2 changes: 2 additions & 0 deletions resources/[soz]/soz-core/src/client/player/player.module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,6 +20,7 @@ import { ProgressProvider } from './progress.provider';
@Module({
providers: [
PlayerAnimationProvider,
PlayerAntiFallDownProvider,
PlayerDiseaseProvider,
PlayerEffectProvider,
PlayerHealthProvider,
Expand Down

0 comments on commit 3f22046

Please sign in to comment.