Skip to content

Instantly share code, notes, and snippets.

@JuniorDjjr
Created November 23, 2020 23:06
Show Gist options
  • Save JuniorDjjr/c29916a26e0b48da0224669b3f0916f0 to your computer and use it in GitHub Desktop.
Save JuniorDjjr/c29916a26e0b48da0224669b3f0916f0 to your computer and use it in GitHub Desktop.
// by Junior_Djjr - MixMods.com.br
// You need: https://forum.mixmods.com.br/f141-gta3script-cleo/t5206-como-criar-scripts-com-cleoplus
SCRIPT_START
{
LVAR_INT i j scplayer hGuitar hCase hCaseObject bPlaying bWalking bWithCase iState hSong iSongId iTotalSongs hSpeakerObject hChar iFindProgress
LVAR_FLOAT f x y z fRandX fRandY fOriginX fOriginY fOriginZ fCaseX fCaseY fCaseZ fSpeakerX fSpeakerY fSpeakerZ
CONST_INT GUITAR_MODEL 14696
CONST_INT CASE_MODEL 14697
CONST_INT SPEAKER_MODEL 1840
CONST_INT STATE_STOP 0
CONST_INT STATE_PLAY 1
CONST_INT STATE_PAUSE 2
CONST_INT STATE_RESUME 3
CONST_INT REACTION_NONE 0
CONST_INT REACTION_IGNORE 1
CONST_INT REACTION_LOOK 2
CONST_INT REACTION_CASE 3
CONST_INT REACTION_ROTATECASE 4
CONST_FLOAT MIN_OBJS_RADIUS -1.5
CONST_FLOAT MAX_OBJS_RADIUS 1.5
WAIT 1000
GET_LABEL_POINTER Buffer i
iTotalSongs = 1
WHILE iTotalSongs < 1000
STRING_FORMAT i "CLEO\CJ Guitar\Song%i.mp3" iTotalSongs
IF DOES_FILE_EXIST $i
++iTotalSongs
ELSE
BREAK
ENDIF
ENDWHILE
--iTotalSongs
IF iTotalSongs = 0
PRINT_HELP CJGUIT3
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
GET_PLAYER_CHAR 0 scplayer
iSongId = 1
WHILE TRUE
WAIT 0
IF bPlaying = FALSE
IF TEST_CHEAT ImaRockstar
PRINT_HELP CHEAT1
IF bWithCase = FALSE
WAIT 1000
GOSUB CreatePlayerCase
PRINT_HELP CJGUIT2
ELSE
GOSUB DeletePlayerCase
ENDIF
ENDIF
ENDIF
IF bWithCase = TRUE
IF IS_CURRENT_CHAR_WEAPON scplayer WEAPONTYPE_PARACHUTE
SET_RENDER_OBJECT_VISIBLE hCase FALSE
ELSE
SET_RENDER_OBJECT_VISIBLE hCase TRUE
ENDIF
IF GOSUB ToggleCommand
IF NOT IS_CHAR_DEAD scplayer
AND NOT HAS_CHAR_BEEN_ARRESTED scplayer
AND IS_PLAYER_PLAYING 0
AND NOT IS_ON_CUTSCENE
AND NOT IS_CHAR_IN_ANY_CAR scplayer
AND IS_CHAR_STOPPED scplayer
IF bPlaying = FALSE
GET_CHAR_COORDINATES scplayer fOriginX fOriginY fOriginZ
i = 0
WHILE i < 50
GENERATE_RANDOM_FLOAT_IN_RANGE MIN_OBJS_RADIUS MAX_OBJS_RADIUS (fRandX)
GENERATE_RANDOM_FLOAT_IN_RANGE MIN_OBJS_RADIUS MAX_OBJS_RADIUS (fRandY)
GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS scplayer fRandX fRandY 0.0 (fCaseX fCaseY fCaseZ)
GET_GROUND_Z_FOR_3D_COORD fCaseX fCaseY fCaseZ (fCaseZ)
fCaseZ += 0.1
IF IS_LINE_OF_SIGHT_CLEAR (fOriginX fOriginY fOriginZ) (fCaseX fCaseY fCaseZ) 1 1 0 0 0
AND fCaseZ > 0.2
AND NOT LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer fCaseX fCaseY fCaseZ 1.5
BREAK
ENDIF
++i
ENDWHILE
IF i < 50
WHILE i < 50
GENERATE_RANDOM_FLOAT_IN_RANGE MIN_OBJS_RADIUS MAX_OBJS_RADIUS (fRandX)
GENERATE_RANDOM_FLOAT_IN_RANGE MIN_OBJS_RADIUS MAX_OBJS_RADIUS (fRandY)
GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS scplayer fRandX fRandY fOriginZ (fSpeakerX fSpeakerY fSpeakerZ)
GET_GROUND_Z_FOR_3D_COORD fSpeakerX fSpeakerY fSpeakerZ (fSpeakerZ)
fSpeakerZ += 0.1
GET_DISTANCE_BETWEEN_COORDS_2D fCaseX fCaseY fSpeakerX fSpeakerY f
IF IS_LINE_OF_SIGHT_CLEAR (fOriginX fOriginY fOriginZ) (fSpeakerX fSpeakerY fSpeakerZ) 1 1 0 0 0
AND f > 0.7
AND fSpeakerZ > 0.2
AND NOT LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer fSpeakerX fSpeakerY fSpeakerZ 1.0
BREAK
ENDIF
++i
ENDWHILE
IF i < 50
IF IS_MODEL_IN_CDIMAGE GUITAR_MODEL
AND IS_MODEL_IN_CDIMAGE SPEAKER_MODEL
REQUEST_ANIMATION CJ_GUITAR
REQUEST_MODEL GUITAR_MODEL
REQUEST_MODEL SPEAKER_MODEL
timera = 0
WHILE NOT HAS_MODEL_LOADED GUITAR_MODEL
OR NOT HAS_MODEL_LOADED SPEAKER_MODEL
OR NOT HAS_ANIMATION_LOADED CJ_GUITAR
WAIT 0
IF timera > 4000
BREAK
ENDIF
ENDWHILE
IF timera <= 4000
AND NOT IS_CHAR_DEAD scplayer
AND NOT HAS_CHAR_BEEN_ARRESTED scplayer
AND IS_PLAYER_PLAYING 0
AND NOT IS_ON_CUTSCENE
AND NOT IS_CHAR_IN_ANY_CAR scplayer
TASK_TOGGLE_DUCK scplayer FALSE
CREATE_RENDER_OBJECT_TO_CHAR_BONE scplayer GUITAR_MODEL 3 (-0.1 0.2 0.0) (0.0 0.0 0.0) (hGuitar)
TASK_PLAY_ANIM_SECONDARY scplayer CJ_GUITAR_PLAY CJ_GUITAR 4.0 1 0 0 0 -1
GOSUB SetPlayerPlayingControls
GOSUB DeletePlayerCase
fCaseZ -= 0.08
CREATE_OBJECT_NO_SAVE CASE_MODEL fCaseX fCaseY fCaseZ FALSE FALSE (hCaseObject)
SET_OBJECT_ROTATION hCaseObject 250.0 90.0 0.0
fSpeakerZ -= 0.07
CREATE_OBJECT_NO_SAVE SPEAKER_MODEL fSpeakerX fSpeakerY fSpeakerZ FALSE FALSE (hSpeakerObject)
//GET_CLOSEST_CHAR_NODE fSpeakerX fSpeakerY fSpeakerZ (x y z)
//GET_ANGLE_FROM_TWO_COORDS fSpeakerX fSpeakerY x y (f)
GET_CHAR_HEADING scplayer (f)
f -= 90.0
SET_OBJECT_HEADING hSpeakerObject f
iSongId = 1
timera = 0
timerb = 0
GOSUB PlaySong
IF iTotalSongs > 1
PRINT_HELP CJGUIT6
ENDIF
ELSE
PRINT_HELP CJGUIT5
ENDIF
ELSE
//PRINT_HELP CJGUIT5
ENDIF
ELSE
PRINT_HELP CJGUIT4
ENDIF
ELSE
PRINT_HELP CJGUIT4
ENDIF
ENDIF
ENDIF
ENDIF
ELSE
IF bPlaying = TRUE
i = FALSE
IF GOSUB ToggleCommand
i = TRUE
ENDIF
IF i = TRUE // because GOSUB doesn't work with AND/OR
OR IS_CHAR_DEAD scplayer
OR HAS_CHAR_BEEN_ARRESTED scplayer
OR NOT IS_PLAYER_PLAYING 0
OR IS_ON_CUTSCENE
OR IS_CHAR_IN_ANY_CAR scplayer
OR NOT LOCATE_CHAR_DISTANCE_TO_OBJECT scplayer hCaseObject 200.0
DELETE_RENDER_OBJECT hGuitar
MARK_MODEL_AS_NO_LONGER_NEEDED GUITAR_MODEL
MARK_MODEL_AS_NO_LONGER_NEEDED SPEAKER_MODEL
DELETE_OBJECT hCaseObject
DELETE_OBJECT hSpeakerObject
GOSUB CreatePlayerCase
REMOVE_ANIMATION CJ_GUITAR
GOSUB ResetPlayerPlayingControls
REMOVE_AUDIO_STREAM hSong
hSong = 0
ELSE
// Player process playing
GET_AUDIO_STREAM_STATE hSong iState
IF iState < 0
OR IS_BUTTON_JUST_PRESSED PAD1 DPADUP
IF NOT IS_BUTTON_JUST_PRESSED PAD1 DPADUP
OR iTotalSongs > 1
++iSongId
IF iSongId > iTotalSongs
iSongId = 1
ENDIF
GOSUB PlaySong
ENDIF
ENDIF
IF IS_BUTTON_JUST_PRESSED PAD1 DPADDOWN
--iSongId
IF iSongId < 1
iSongId = iTotalSongs
ENDIF
GOSUB PlaySong
ENDIF
GET_AUDIO_SFX_VOLUME (f)
SET_AUDIO_STREAM_VOLUME hSong f
GET_PED_POINTER scplayer i
READ_STRUCT_OFFSET i 0x534 4 i
IF i > 1
IF bWalking = FALSE
TASK_PLAY_ANIM_SECONDARY scplayer CJ_GUITAR_PLAY_WALK CJ_GUITAR 4.0 1 0 0 0 -1
bWalking = TRUE
timera = 0
ENDIF
ELSE
IF timera > 1000
IF bWalking = TRUE
TASK_PLAY_ANIM_SECONDARY scplayer CJ_GUITAR_PLAY CJ_GUITAR 4.0 1 0 0 0 -1
bWalking = FALSE
ENDIF
ENDIF
ENDIF
IF NOT IS_CHAR_PLAYING_ANIM scplayer CJ_GUITAR_PLAY_WALK
AND NOT IS_CHAR_PLAYING_ANIM scplayer CJ_GUITAR_PLAY
TASK_PLAY_ANIM_SECONDARY scplayer CJ_GUITAR_PLAY_WALK CJ_GUITAR 4.0 1 0 0 0 -1
IF timera > 100
SET_AUDIO_STREAM_STATE hSong STATE_PAUSE
timerb = 0
ENDIF
ELSE
timera = 0
IF iState = STATE_PAUSE
AND timerb > 500
SET_AUDIO_STREAM_STATE hSong STATE_RESUME
ENDIF
ENDIF
IF iState = STATE_PLAY
OR iState = STATE_RESUME
iFindProgress = 0
WHILE GET_ANY_CHAR_NO_SAVE_RECURSIVE iFindProgress (iFindProgress hChar)
IF NOT IS_CHAR_IN_ANY_CAR hChar
AND NOT IS_CHAR_DEAD hChar
AND NOT IS_CHAR_SCRIPT_CONTROLLED hChar
GET_PED_TYPE hChar i
IF i = 4 // male
OR i = 5 // female
OR i = 8 // grove street families
IF LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hChar 15.0
i = REACTION_NONE
IF GET_EXTENDED_CHAR_VAR hChar AUTO 1 i
ELSE
INIT_EXTENDED_CHAR_VARS hChar AUTO 1
ENDIF
IF NOT i = REACTION_IGNORE
IF i = REACTION_NONE
IF NOT IS_CHAR_DOING_ANY_IMPORTANT_TASK hChar INCLUDE_ANIMS_PRIMARY
GET_CHAR_RANDOM_SEED hChar j
GENERATE_RANDOM_INT_IN_RANGE_WITH_SEED j 0 100 (j)
IF j >= 75
OPEN_SEQUENCE_TASK i
SET_NEXT_DESIRED_MOVE_STATE 4
TASK_GOTO_CHAR_OFFSET -1 scplayer 10000 3.0 0.0
TASK_TURN_CHAR_TO_FACE_CHAR -1 scplayer
TASK_LOOK_AT_CHAR -1 scplayer 6000
TASK_STAND_STILL -1 5000
CLOSE_SEQUENCE_TASK i
PERFORM_SEQUENCE_TASK hChar i
CLEAR_SEQUENCE_TASK i
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_LOOK
ELSE
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_IGNORE
ENDIF
ENDIF
ELSE
IF i = REACTION_LOOK
IF LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hChar 6.0
GET_SCRIPT_TASK_STATUS hChar 0x618 i
IF i = 7
IF LOCATE_CHAR_DISTANCE_TO_OBJECT hChar hCaseObject 10.0
GET_PED_POINTER hChar i
READ_STRUCT_OFFSET i 0x756 2 (i)
IF i > 0
TASK_GO_TO_COORD_ANY_MEANS hChar fCaseX fCaseY fCaseZ 4 -1
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_CASE
ELSE
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_IGNORE
ENDIF
ENDIF
ENDIF
ENDIF
ELSE
IF i = REACTION_CASE
IF LOCATE_CHAR_DISTANCE_TO_OBJECT hChar hCaseObject 1.5
OPEN_SEQUENCE_TASK i
SET_NEXT_DESIRED_MOVE_STATE 4
TASK_TURN_CHAR_TO_FACE_COORD -1 fCaseX fCaseY fCaseZ
TASK_PLAY_ANIM -1 "ped_eat_money" CJ_GUITAR 3.0 0 0 0 0 3500
CLOSE_SEQUENCE_TASK i
PERFORM_SEQUENCE_TASK hChar i
CLEAR_SEQUENCE_TASK i
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_ROTATECASE
ENDIF
ELSE
IF i = REACTION_ROTATECASE
IF IS_CHAR_PLAYING_ANIM hChar "ped_eat_money"
IF LOCATE_CHAR_DISTANCE_TO_OBJECT hChar hCaseObject 1.8
GET_PED_POINTER hChar i
READ_STRUCT_OFFSET i 0x756 2 (i)
IF i > 0
j = i / 2
IF j > 100
j = 100
ENDIF
CHANGE_PLAYER_MONEY 0 CHANGE_MONEY_ADD i
i -= j
SET_CHAR_MONEY hChar i
ENDIF
ELSE
TASK_PLAY_ANIM hChar NULL NULL 4.0 0 0 0 0 1
ENDIF
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_IGNORE
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ELSE
IF IS_CHAR_DOING_ANY_IMPORTANT_TASK hChar INCLUDE_ANIMS_NONE
GOTO ResetAI
ENDIF
IF LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hChar 20.0
AND LOCATE_CHAR_DISTANCE_TO_OBJECT scplayer hCaseObject 20.0
IF GET_EXTENDED_CHAR_VAR hChar AUTO 1 i
IF i >= REACTION_LOOK // doing something for player
// reset AI if invalid to continue
ResetAI:
SET_EXTENDED_CHAR_VAR hChar AUTO 1 REACTION_IGNORE
CLEAR_CHAR_TASKS hChar
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDWHILE
ENDIF
ENDIF
ENDIF
ENDIF
IF LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 50.0
IF bWithCase = TRUE
WHILE LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 55.0
AND bWithCase = TRUE
WAIT 0
IF LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 1.0
PRINT_HELP_FOREVER CJGUIT0
WHILE LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 1.5
WAIT 0
IF GOSUB ToggleCommand
GOSUB DeletePlayerCase
BREAK
ENDIF
ENDWHILE
CLEAR_HELP
IF bWithCase = TRUE
PRINT_HELP CJGUIT2
ENDIF
ENDIF
ENDWHILE
ELSE
CREATE_OBJECT_NO_SAVE CASE_MODEL 255.4769 -43.8 1001.47 FALSE FALSE (hCaseObject)
WHILE LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 55.0
AND bWithCase = FALSE
WAIT 0
IF LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 1.0
PRINT_HELP_FOREVER CJGUIT1
WHILE LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer 255.4769 -43.6992 1002.0234 1.5
WAIT 0
IF GOSUB ToggleCommand
DELETE_OBJECT hCaseObject
hCaseObject = 0
GOSUB CreatePlayerCase
BREAK
ENDIF
ENDWHILE
CLEAR_HELP
IF bWithCase = TRUE
PRINT_HELP CJGUIT2
ENDIF
ENDIF
ENDWHILE
DELETE_OBJECT hCaseObject
hCaseObject = 0
ENDIF
ENDIF
ENDWHILE
ToggleCommand:
IF IS_BUTTON_PRESSED PAD1 DPADUP
IF IS_BUTTON_JUST_PRESSED PAD1 LEFTSHOULDER1
RETURN_TRUE
RETURN
ENDIF
ENDIF
IF IS_BUTTON_PRESSED PAD1 LEFTSHOULDER1
IF IS_BUTTON_JUST_PRESSED PAD1 DPADUP
RETURN_TRUE
RETURN
ENDIF
ENDIF
RETURN_FALSE
RETURN
PlaySong:
IF hSong > 0
REMOVE_AUDIO_STREAM hSong
ENDIF
GET_LABEL_POINTER Buffer i
STRING_FORMAT i "CLEO\CJ Guitar\Song%i.mp3" iSongId
LOAD_3D_AUDIO_STREAM $i (hSong)
SET_AUDIO_STREAM_LOOPED hSong OFF
SET_PLAY_3D_AUDIO_STREAM_AT_OBJECT hSong hSpeakerObject
GET_AUDIO_SFX_VOLUME (f)
SET_AUDIO_STREAM_VOLUME hSong f
SET_AUDIO_STREAM_STATE hSong STATE_PLAY
RETURN
ResetPlayerPlayingControls:
SET_PLAYER_DUCK_BUTTON 0 ON
//SET_PLAYER_JUMP_BUTTON 0 ON
SET_PLAYER_FIRE_BUTTON 0 ON
SET_PLAYER_CYCLE_WEAPON_BUTTON 0 ON
SET_PLAYER_ENTER_CAR_BUTTON 0 ON
CLEAR_CHAR_SECONDARY_TASKS scplayer
HIDE_CHAR_WEAPON_FOR_SCRIPTED_CUTSCENE scplayer FALSE
bPlaying = FALSE
RETURN
SetPlayerPlayingControls:
SET_PLAYER_DUCK_BUTTON 0 OFF
//SET_PLAYER_JUMP_BUTTON 0 OFF
SET_PLAYER_FIRE_BUTTON 0 OFF
SET_PLAYER_CYCLE_WEAPON_BUTTON 0 OFF
SET_PLAYER_ENTER_CAR_BUTTON 0 OFF
HIDE_CHAR_WEAPON_FOR_SCRIPTED_CUTSCENE scplayer TRUE
bPlaying = TRUE
bWalking = FALSE
RETURN
CreatePlayerCase:
IF IS_MODEL_IN_CDIMAGE CASE_MODEL
REQUEST_MODEL CASE_MODEL
LOAD_ALL_MODELS_NOW
CREATE_RENDER_OBJECT_TO_CHAR_BONE scplayer CASE_MODEL 3 (0.12 -0.13 0.02) (0.0 90.0 -15.0) (hCase)
SET_RENDER_OBJECT_AUTO_HIDE hCase FALSE FALSE TRUE
bWithCase = TRUE
ELSE
PRINT_HELP CJGUIT5
WAIT 2000
ENDIF
RETURN
DeletePlayerCase:
DELETE_RENDER_OBJECT hCase
MARK_MODEL_AS_NO_LONGER_NEEDED CASE_MODEL
bWithCase = FALSE
RETURN
}
SCRIPT_END
Buffer:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment