Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
SCRIPT_START
{
LVAR_INT scplayer hVeh bCharInvalid bPlaneInvalid i
LVAR_FLOAT x y z planeX planeY planeZ
CONST_FLOAT AIR_RESISTENCE 0.04
CONST_FLOAT GRAVITY 0.17
CONST_FLOAT AIR_RESISTENCE_PLANE 0.00003
CONST_FLOAT GRAVITY_PLANE 0.00005
GET_PLAYER_CHAR 0 scplayer
WHILE TRUE
WAIT 0
IF IS_CHAR_IN_ANY_PLANE scplayer
//PRINT_STRING_NOW "START PLANE" 2000
STORE_CAR_CHAR_IS_IN_NO_SAVE scplayer hVeh
WHILE IS_CHAR_IN_ANY_PLANE scplayer
WAIT 0
ENDWHILE
timera = 0
timerb = 0
//PRINT_STRING_NOW "EXIT" 2000
IF DOES_VEHICLE_EXIST hVeh
GET_CAR_SPEED_VECTOR hVeh x y z
planeX = x / 3000.0
planeY = y / 3000.0
planeZ = z / 3000.0
bCharInvalid = FALSE
bPlaneInvalid = FALSE
WHILE TRUE
WAIT 0
IF x > 0.0
x -=@ AIR_RESISTENCE
IF x < 0.0
x = 0.0
ENDIF
ELSE
x +=@ AIR_RESISTENCE
IF x > 0.0
x = 0.0
ENDIF
ENDIF
IF y > 0.0
y -=@ AIR_RESISTENCE
IF y < 0.0
y = 0.0
ENDIF
ELSE
y +=@ AIR_RESISTENCE
IF y > 0.0
y = 0.0
ENDIF
ENDIF
z -=@ GRAVITY
IF planeX > 0.0
planeX -=@ AIR_RESISTENCE_PLANE
IF planeX < 0.0
planeX = 0.0
ENDIF
ELSE
planeX +=@ AIR_RESISTENCE_PLANE
IF planeX > 0.0
planeX = 0.0
ENDIF
ENDIF
IF planeY > 0.0
planeY -=@ AIR_RESISTENCE_PLANE
IF planeY < 0.0
planeY = 0.0
ENDIF
ELSE
planeY +=@ AIR_RESISTENCE_PLANE
IF planeY > 0.0
planeY = 0.0
ENDIF
ENDIF
planeZ -=@ GRAVITY_PLANE
//PRINT_FORMATTED_NOW "SET SPEED %.3f %.3f %.3f" 2000 x y z
IF IS_PLAYER_PLAYING 0
IF IS_CHAR_IN_AIR scplayer
AND NOT IS_CHAR_IN_ANY_CAR scplayer
AND NOT IS_CHAR_IN_WATER scplayer
//AND NOT IS_CURRENT_CHAR_WEAPON scplayer WEAPONTYPE_PARACHUTE
IF bCharInvalid = FALSE
SET_CHAR_VELOCITY scplayer x y z
ENDIF
ELSE
IF timera > 400 // min time to set hit the ground, because, wtf
//PRINT_FORMATTED_NOW "CHAR HIT GROUND!!!!! %.3f %.3f %.3f" 2000 x y z
bCharInvalid = TRUE
ENDIF
ENDIF
ELSE
bCharInvalid = TRUE
ENDIF
IF DOES_VEHICLE_EXIST hVeh
GET_DRIVER_OF_CAR hVeh i
IF i > 0
OR NOT IS_CAR_IN_AIR_PROPER hVeh
OR IS_CAR_IN_WATER hVeh
bPlaneInvalid = TRUE
//PRINT_FORMATTED_NOW "PLANE HIT GROUND!!!!! %.3f %.3f %.3f" 2000 x y z
ELSE
IF bPlaneInvalid = FALSE
APPLY_FORCE_TO_CAR hVeh planeX planeY planeZ 0.0 0.0 0.0
ENDIF
ENDIF
ELSE
bPlaneInvalid = TRUE
//PRINT_FORMATTED_NOW "PLANE HIT GROUND!!!!! %.3f %.3f %.3f" 2000 x y z
ENDIF
// To avoid some almost-infinite loop if plane takes too long to hit the ground
IF bCharInvalid = TRUE
AND timerb > 8000
BREAK
ENDIF
IF bPlaneInvalid = TRUE
AND bCharInvalid = TRUE
BREAK
ENDIF
ENDWHILE
ENDIF
ENDIF
ENDWHILE
}
SCRIPT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.