Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Handbrake Mod by Junior_Djjr - MixMods.com.br
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
SCRIPT_START
{
LVAR_INT scplayer scplayer2 car driver audiostream_up audiostream_down loaded locked useSec alwaysSecAnim model
LVAR_FLOAT audiostream_vol anim_speed dim_x fdummy minXsize
// Audiostream states
CONST_INT STATE_END -1
CONST_INT STATE_STOP 0
CONST_INT STATE_PLAY 1
CONST_INT STATE_PAUSE 2
CONST_INT STATE_RESUME 3
/////////////////////////////////////////////////
GET_PLAYER_CHAR 0 scplayer
IF NOT READ_FLOAT_FROM_INI_FILE "CLEO\Handbrake Mod.ini" "Settings" "Volume" audiostream_vol
audiostream_vol = 0.5
ENDIF
IF NOT READ_FLOAT_FROM_INI_FILE "CLEO\Handbrake Mod.ini" "Settings" "AnimSpeed" anim_speed
anim_speed = 10.0
ENDIF
IF NOT READ_INT_FROM_INI_FILE "CLEO\Handbrake Mod.ini" "Settings" "AlwaysSecAnim" alwaysSecAnim
alwaysSecAnim = FALSE
ENDIF
IF NOT READ_FLOAT_FROM_INI_FILE "CLEO\Handbrake Mod.ini" "Settings" "MinXsize" minXsize
minXsize = 0.9
ENDIF
useSec = alwaysSecAnim
/////////////////////////////////////////////////
WHILE TRUE
WAIT 0
IF IS_CHAR_IN_ANY_CAR scplayer
IF IS_BUTTON_PRESSED PAD1 RIGHTSHOULDER1 // Space
STORE_CAR_CHAR_IS_IN_NO_SAVE scplayer car
GET_CAR_MODEL car model
IF IS_THIS_MODEL_A_CAR model
GET_MODEL_DIMENSIONS model dim_x fdummy fdummy fdummy fdummy fdummy
ABS_LVAR_FLOAT dim_x
//PRINT_FORMATTED_NOW "%f" 1000 dim_x
IF dim_x > minXsize
GOSUB LoadResourcesIfNotLoaded
GET_DRIVER_OF_CAR car driver
IF driver = scplayer
IF alwaysSecAnim = FALSE
// because missions think that the char is outside the car when playing anim
READ_MEMORY 0xA476AC 4 FALSE (useSec) // onmission flag
ELSE
useSec = TRUE
ENDIF
GOSUB ApplyHandbrake
ENDIF
ENDIF
ENDIF
ENDIF
ELSE
GOSUB ReleaseResourcesIfLoaded
ENDIF
ENDWHILE
/////////////////////////////////////////////////
LoadResourcesIfNotLoaded:
IF loaded = FALSE
LOAD_3D_AUDIO_STREAM "CLEO\CLEO_SOUNDS\HandbrakeUp.mp3" audiostream_up
LOAD_3D_AUDIO_STREAM "CLEO\CLEO_SOUNDS\HandbrakeDown.mp3" audiostream_down
SET_AUDIO_STREAM_VOLUME audiostream_up audiostream_vol
SET_AUDIO_STREAM_VOLUME audiostream_down audiostream_vol
SET_PLAY_3D_AUDIO_STREAM_AT_CAR audiostream_up car
SET_PLAY_3D_AUDIO_STREAM_AT_CAR audiostream_down car
SET_AUDIO_STREAM_LOOPED audiostream_up OFF
SET_AUDIO_STREAM_LOOPED audiostream_down OFF
REQUEST_ANIMATION PPUSHBRAKE
LOAD_ALL_MODELS_NOW
loaded = TRUE
ENDIF
RETURN
ReleaseResourcesIfLoaded:
IF loaded = TRUE
REMOVE_AUDIO_STREAM audiostream_up
REMOVE_AUDIO_STREAM audiostream_down
REMOVE_ANIMATION PPUSHBRAKE
loaded = FALSE
ENDIF
RETURN
ApplyHandbrake:
SET_AUDIO_STREAM_STATE audiostream_up STATE_PLAY
WHILE IS_BUTTON_PRESSED PAD1 RIGHTSHOULDER1
IF useSec = TRUE
TASK_PLAY_ANIM_SECONDARY driver P_PUSH PPUSHBRAKE anim_speed (OFF OFF OFF OFF) -1
ELSE
TASK_PLAY_ANIM driver P_PUSH PPUSHBRAKE anim_speed (OFF OFF OFF OFF) -1
ENDIF
SET_CHAR_ANIM_CURRENT_TIME driver P_PUSH 0.5
SET_CHAR_ANIM_PLAYING_FLAG driver P_PUSH OFF
IF NOT IS_CHAR_IN_ANY_CAR scplayer
SET_CHAR_ANIM_CURRENT_TIME driver P_PUSH 1.0
SET_CHAR_ANIM_PLAYING_FLAG driver P_PUSH ON
RETURN
ENDIF
WAIT 0
ENDWHILE
SET_CHAR_ANIM_CURRENT_TIME driver P_PUSH 0.6
SET_CHAR_ANIM_PLAYING_FLAG driver P_PUSH ON
SET_AUDIO_STREAM_STATE audiostream_up STATE_STOP
SET_AUDIO_STREAM_STATE audiostream_down STATE_PLAY
RETURN
}
SCRIPT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment