Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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 pFilename //In
LVAR_INT i scplayer pBuffer hFind pBufferPath hMenu hVeh bAllowRaceMode pBufferRecordPath
LVAR_FLOAT enterX enterY enterZ x y width height
IF NOT pFilename = 0
GOTO RaceScript
ENDIF
WAIT 2000
//GET_PLAYER_CHAR 0 i
//SET_CHAR_COORDINATES i -2405.3906 -2181.051 33.2891
GET_LABEL_POINTER Buffer pBuffer
IF FIND_FIRST_FILE "CLEO\Race Creator\*.ini" (hFind pBuffer)
WHILE TRUE
ALLOCATE_MEMORY 32 (pFilename)
WRITE_MEMORY pFilename 32 0 FALSE
COPY_STRING $pBuffer pFilename
STREAM_CUSTOM_SCRIPT "Race Creator (Junior_Djjr).cs" pFilename
IF NOT FIND_NEXT_FILE hFind (pBuffer)
BREAK
ENDIF
ENDWHILE
ENDIF
TERMINATE_THIS_CUSTOM_SCRIPT
RaceScript:
GET_PLAYER_CHAR 0 (scplayer)
GET_LABEL_POINTER BufferPath pBufferPath
STRING_FORMAT pBufferPath "CLEO\Race Creator\%s" $pFilename
GET_LABEL_POINTER Buffer pBuffer
GET_LABEL_POINTER BufferRecordPath pBufferRecordPath
STRING_FORMAT pBufferRecordPath "CLEO\Race Creator\Records\%s" $pFilename
IF NOT READ_STRING_FROM_INI_FILE $pBufferPath "Settings" "EnterCoord" (pBuffer)
PRINT_FORMATTED_NOW "~r~ERROR: Can't read race ini file: %s" 6000 $pBufferPath
GOSUB Terminate
ENDIF
SCAN_STRING $pBuffer "%f %f %f" (i) enterX enterY enterZ
WHILE TRUE
WAIT 0
IF LOCATE_CAMERA_DISTANCE_TO_COORDINATES enterX enterY enterZ 200.0
IF LOCATE_CAMERA_DISTANCE_TO_COORDINATES enterX enterY enterZ 80.0
CONVERT_3D_TO_SCREEN_2D enterX enterY enterZ TRUE TRUE x y width height
IF width > 0.1
width *= 0.6
height *= 0.6
DRAW_STRING_EXT $pFilename DRAW_EVENT_BEFORE_HUD x y width height TRUE FONT_SUBTITLES TRUE ALIGN_CENTER 640.0 FALSE 255 255 255 255 1 0 0 0 0 255 FALSE 0 0 0 0
ENDIF
ENDIF
IF LOCATE_STOPPED_CHAR_ANY_MEANS_3D scplayer enterX enterY enterZ 3.0 3.0 3.0 TRUE
IF IS_CHAR_SITTING_IN_ANY_CAR scplayer
STORE_CAR_CHAR_IS_IN_NO_SAVE scplayer hVeh
GOSUB Start
ELSE
PRINT_NOW RCRTR13 3000 1
ENDIF
ENDIF
ENDIF
ENDWHILE
Start:
WAIT 500
GOSUB LockPlayer
READ_INT_FROM_INI_FILE $pBufferPath "Settings" "AllowRaceMode" (bAllowRaceMode)
// 08D4: create_menu 'IE09' position 29.0 170.0 width 180.0 columns 1 interactive 1 background 1 alignment 0 store_to $1153
CREATE_MENU RCRTR01 220.0 100.0 200.0 1 1 1 0 (hMenu)
// 08DB: set_menu_column $1153 col 0 title_to 'DUMMY' items_to 'IE16' 'IE10' 'IE11' 'IE12' 'IE13' 'IE14' 'IE15' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'
SET_MENU_COLUMN hMenu 0 RCRTR02 (RCRTR03 RCRTR04 DUMMY DUMMY DUMMY DUMMY DUMMY DUMMY DUMMY DUMMY DUMMY DUMMY)
ACTIVATE_MENU_ITEM hMenu 0 bAllowRaceMode
WHILE TRUE
WAIT 0
IF IS_SELECT_MENU_JUST_PRESSED
GET_MENU_ITEM_SELECTED hMenu (i)
IF i = 0
PRINT_NOW RCRTR21 3000 1
ENDIF
IF i = 1
DELETE_MENU hMenu
CLEO_CALL TimeAttack 0 (hVeh)()
GOSUB PostEvent
BREAK
ENDIF
IF i = 2
DELETE_DIRECTORY "CLEO\Race Creator\Records" TRUE
IF DOES_DIRECTORY_EXIST "CLEO\Race Creator\Records"
PRINT_NOW RCRTR19 4000 1
ELSE
PRINT_NOW RCRTR18 2000 1
ENDIF
ENDIF
ENDIF
IF IS_BUTTON_JUST_PRESSED PAD1 TRIANGLE
BREAK
ENDIF
ENDWHILE
DELETE_MENU hMenu
WHILE IS_BUTTON_PRESSED PAD1 TRIANGLE
WAIT 0
ENDWHILE
GOSUB UnlockPlayer
WHILE LOCATE_CHAR_ANY_MEANS_3D scplayer enterX enterY enterZ 4.0 4.0 4.0 FALSE
WAIT 0
ENDWHILE
RETURN
PostEvent:
GOSUB LockPlayer
DO_FADE 1000 FADE_OUT
WAIT 1100
SET_PLAYER_ENTER_CAR_BUTTON 0 OFF
IF DOES_VEHICLE_EXIST hVeh
AND NOT IS_CAR_DEAD hVeh
SET_CAR_COORDINATES hVeh enterX enterY enterZ
SET_CAR_HEADING hVeh 0.0
ELSE
SET_CHAR_COORDINATES scplayer enterX enterY enterZ
SET_CHAR_HEADING scplayer 0.0
ENDIF
RESTORE_CAMERA_JUMPCUT
WAIT 200
DO_FADE 1000 FADE_IN
GOSUB UnlockPlayer
WHILE IS_BUTTON_PRESSED PAD1 TRIANGLE
WAIT 0
ENDWHILE
SET_PLAYER_ENTER_CAR_BUTTON 0 ON
RETURN
LockPlayer:
CLEAR_PRINTS
SET_PLAYER_CONTROL 0 OFF
RETURN
UnlockPlayer:
CLEAR_PRINTS
SET_PLAYER_CONTROL 0 ON
SET_PLAYER_ENTER_CAR_BUTTON 0 ON
RESTORE_CAMERA_JUMPCUT
RETURN
Terminate:
FREE_MEMORY pFilename
TERMINATE_THIS_CUSTOM_SCRIPT
}
SCRIPT_END
{
LVAR_INT hVeh //In
LVAR_INT i j k scplayer hCheckpoint iCurrentSection iTotalSection pBufferPath pBuffer pBufferB bIsCircuit lSectionX lSectionY lSectionZ lSectionR lSectionPit iCurrentSectionDisplay iTime bVisualCheckpoints bFinished hBlip
LVAR_FLOAT x y z r a x2 y2 z2
TimeAttack:
CLEAR_PRINTS
SET_PLAYER_CONTROL 0 OFF
SET_PLAYER_ENTER_CAR_BUTTON 0 OFF
GET_PLAYER_CHAR 0 scplayer
hCheckpoint = -1
DO_FADE 1000 FADE_OUT
WAIT 1100
GET_LABEL_POINTER BufferPath pBufferPath
GET_LABEL_POINTER Buffer pBuffer
GET_LABEL_POINTER BufferB pBufferB
READ_INT_FROM_INI_FILE $pBufferPath "Settings" "IsCircuit" (bIsCircuit)
READ_INT_FROM_INI_FILE $pBufferPath "Settings" "VisualCheckpoints" (bVisualCheckpoints)
CREATE_LIST DATATYPE_FLOAT lSectionX
CREATE_LIST DATATYPE_FLOAT lSectionY
CREATE_LIST DATATYPE_FLOAT lSectionZ
CREATE_LIST DATATYPE_FLOAT lSectionR
CREATE_LIST DATATYPE_FLOAT lSectionPit
IF READ_STRING_FROM_INI_FILE $pBufferPath "Pitstop" "Start" (pBuffer)
SCAN_STRING $pBuffer "%f %f %f %f" (i) x y z r
LIST_ADD lSectionPit x
LIST_ADD lSectionPit y
LIST_ADD lSectionPit z
LIST_ADD lSectionPit r
IF READ_STRING_FROM_INI_FILE $pBufferPath "Pitstop" "End" (pBuffer)
SCAN_STRING $pBuffer "%f %f %f %f" (i) x y z r
LIST_ADD lSectionPit x
LIST_ADD lSectionPit y
LIST_ADD lSectionPit z
LIST_ADD lSectionPit r
ENDIF
ENDIF
iTotalSection = 1
WHILE TRUE
STRING_FORMAT pBufferB "%i" iTotalSection
IF READ_STRING_FROM_INI_FILE $pBufferPath "Sections" $pBufferB (pBuffer)
SCAN_STRING $pBuffer "%f %f %f %f" (i) x y z r
LIST_ADD lSectionX x
LIST_ADD lSectionY y
LIST_ADD lSectionZ z
LIST_ADD lSectionR r
ELSE
BREAK
ENDIF
++iTotalSection
ENDWHILE
--iTotalSection
IF iTotalSection > 1
READ_STRING_FROM_INI_FILE $pBufferPath "Cars" "1" (pBuffer)
SCAN_STRING $pBuffer "%f %f %f %f" (i) x y z a
SET_CAR_COORDINATES_NO_OFFSET hVeh x y z
SET_CAR_HEADING hVeh a
RESTORE_CAMERA_JUMPCUT
WAIT 500
iTime = 0
iCurrentSection = 0
iCurrentSectionDisplay = 1
IF bIsCircuit = TRUE
iCurrentSection = 1
DISPLAY_TWO_ONSCREEN_COUNTERS_WITH_STRING_LOCAL iCurrentSectionDisplay iTotalSection RCRTR05
ELSE
DISPLAY_TWO_ONSCREEN_COUNTERS_WITH_STRING_LOCAL iCurrentSectionDisplay iTotalSection RCRTR06
ENDIF
DISPLAY_ONSCREEN_TIMER_WITH_STRING_LOCAL iTime TIMER_UP RCRTR07
DO_FADE 1500 FADE_IN
WHILE timera < 1000
WAIT 0
iTime = 0
ENDWHILE
timera = 0
PRINT_BIG RCRTR14 1100 4 //3
REPORT_MISSION_AUDIO_EVENT_AT_POSITION 0.0 0.0 0.0 SOUND_RACE_321
WHILE timera < 1000
WAIT 0
iTime = 0
ENDWHILE
timera = 0
PRINT_BIG RCRTR15 1100 4 //2
REPORT_MISSION_AUDIO_EVENT_AT_POSITION 0.0 0.0 0.0 SOUND_RACE_321
WHILE timera < 1000
WAIT 0
iTime = 0
ENDWHILE
timera = 0
PRINT_BIG RCRTR16 1100 4 //1
REPORT_MISSION_AUDIO_EVENT_AT_POSITION 0.0 0.0 0.0 SOUND_RACE_321
WHILE timera < 1000
WAIT 0
iTime = 0
ENDWHILE
PRINT_BIG RCRTR12 400 4 //Go!
REPORT_MISSION_AUDIO_EVENT_AT_POSITION 0.0 0.0 0.0 SOUND_RACE_GO
SET_PLAYER_CONTROL 0 ON
GOSUB NewSection
bFinished = FALSE
WHILE TRUE
WAIT 0
IF NOT DOES_VEHICLE_EXIST hVeh
OR IS_CAR_DEAD hVeh
BREAK
ENDIF
IF IS_BUTTON_JUST_PRESSED PAD1 TRIANGLE
OR NOT IS_CHAR_IN_CAR scplayer hVeh
BREAK
ENDIF
IF LOCATE_CAR_3D hVeh x y z r r 30.0 FALSE
IF bIsCircuit = TRUE
AND iCurrentSection = 0
iCurrentSection = 1
iCurrentSectionDisplay = 1
GOSUB NewSection
GOSUB Finished
ELSE
++iCurrentSection
++iCurrentSectionDisplay
IF iCurrentSection = iTotalSection
iCurrentSection = 0
GOSUB NewSection
IF bIsCircuit = FALSE
GOSUB Finished
bFinished = TRUE
BREAK
ENDIF
ELSE
GOSUB NewSection
ENDIF
ENDIF
ENDIF
//PRINT_FORMATTED_NOW "Section: %i/%i" 2000 iCurrentSection iTotalSection
ENDWHILE
ELSE
PRINT_STRING_NOW "~r~Fail to load race sections." 4000
ENDIF
DELETE_LIST lSectionX
DELETE_LIST lSectionY
DELETE_LIST lSectionZ
DELETE_LIST lSectionR
IF hCheckpoint >= 0
DELETE_CHECKPOINT hCheckpoint
hCheckpoint = -1
ENDIF
REMOVE_BLIP hBlip
iTime = 0
CLEAR_ONSCREEN_TIMER_LOCAL iTime
CLEAR_ONSCREEN_COUNTER_LOCAL iCurrentSectionDisplay
IF bFinished = TRUE
WAIT 3000
ENDIF
CLEAR_PRINTS
CLEO_RETURN 0
GetSectionCoords:
GET_LIST_VALUE_BY_INDEX lSectionX iCurrentSection (x)
GET_LIST_VALUE_BY_INDEX lSectionY iCurrentSection (y)
GET_LIST_VALUE_BY_INDEX lSectionZ iCurrentSection (z)
GET_LIST_VALUE_BY_INDEX lSectionR iCurrentSection (r)
RETURN
NewSection:
GOSUB GetSectionCoords
IF bVisualCheckpoints = TRUE
IF hCheckpoint >= 0
DELETE_CHECKPOINT hCheckpoint
REPORT_MISSION_AUDIO_EVENT_AT_POSITION 0.0 0.0 0.0 SOUND_CHECKPOINT_RED
REMOVE_BLIP hBlip
ENDIF
++iCurrentSection
IF iCurrentSection >= iTotalSection
IF bIsCircuit = FALSE
CREATE_CHECKPOINT 1 x y z x y z r (hCheckpoint)
ELSE
GET_LIST_VALUE_BY_INDEX lSectionX 0 (x2)
GET_LIST_VALUE_BY_INDEX lSectionY 0 (y2)
GET_LIST_VALUE_BY_INDEX lSectionZ 0 (z2)
CREATE_CHECKPOINT 0 x y z x2 y2 z2 r (hCheckpoint)
ENDIF
ELSE
GET_LIST_VALUE_BY_INDEX lSectionX iCurrentSection (x2)
GET_LIST_VALUE_BY_INDEX lSectionY iCurrentSection (y2)
GET_LIST_VALUE_BY_INDEX lSectionZ iCurrentSection (z2)
CREATE_CHECKPOINT 0 x y z x2 y2 z2 r (hCheckpoint)
ENDIF
ADD_BLIP_FOR_COORD x y z hBlip
CHANGE_BLIP_COLOUR hBlip 0
--iCurrentSection
ENDIF
RETURN
Finished:
j = 0
i = iTime / 1000
WHILE i >= 60
i -= 60
++j
ENDWHILE
IF bIsCircuit = TRUE
GET_TEXT_LABEL_STRING RCRTR08 pBuffer //Lap
ELSE
GET_TEXT_LABEL_STRING RCRTR09 pBuffer //Time
ENDIF
IF CLEO_CALL GetRecordTime 0 (hVeh)(k timera timerb)
IF iTime < k
GET_TEXT_LABEL_STRING RCRTR11 pBufferB
PRINT_FORMATTED_NOW "%s: ~b~%.2d:%.2d~n~~s~%s: %.2d:%.2d" 5000 $pBuffer j i $pBufferB timera timerb
CLEO_CALL SetRecordTime 0 (hVeh iTime)()
ELSE
GET_TEXT_LABEL_STRING RCRTR10 pBufferB
PRINT_FORMATTED_NOW "%s: ~r~%.2d:%.2d~n~~s~%s: %.2d:%.2d" 5000 $pBuffer j i $pBufferB timera timerb
ENDIF
ELSE
PRINT_FORMATTED_NOW "%s: ~b~%.2d:%.2d" 5000 $pBuffer j i
CLEO_CALL SetRecordTime 0 (hVeh iTime)()
ENDIF
iTime = 0
RETURN
}
{
LVAR_INT hVeh //In
LVAR_INT i pBuffer iTotal iMin iSec pBufferRecordPath
GetRecordTime:
GET_LABEL_POINTER BufferRecordPath pBufferRecordPath
GET_LABEL_POINTER Buffer pBuffer
GET_CAR_MODEL hVeh i
STRING_FORMAT pBuffer "%i" i
IF READ_INT_FROM_INI_FILE $pBufferRecordPath "Times" $pBuffer (iTotal)
iSec = iTotal / 1000
WHILE iSec >= 60
iSec -= 60
++iMin
ENDWHILE
RETURN_TRUE
CLEO_RETURN 0 (iTotal iMin iSec)
ELSE
RETURN_FALSE
CLEO_RETURN 0 (0 0 0)
ENDIF
}
{
LVAR_INT hVeh iTime //In
LVAR_INT pBufferRecordPath pBuffer i
SetRecordTime:
GET_LABEL_POINTER BufferRecordPath pBufferRecordPath
GET_LABEL_POINTER Buffer pBuffer
IF NOT DOES_DIRECTORY_EXIST "CLEO\Race Creator\Records"
CREATE_DIRECTORY "CLEO\Race Creator\Records"
IF NOT DOES_DIRECTORY_EXIST "CLEO\Race Creator\Records"
PRINT_NOW RCRTR20 6000 1
RETURN_FALSE
CLEO_RETURN 0
ENDIF
ENDIF
GET_CAR_MODEL hVeh i
STRING_FORMAT pBuffer "%i" i
WRITE_INT_TO_INI_FILE iTime $pBufferRecordPath "Times" $pBuffer
RETURN_TRUE
CLEO_RETURN 0
}
BufferPath:
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 //32
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 //64
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 //128
ENDDUMP
BufferRecordPath:
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 //32
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 //64
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 //128
ENDDUMP
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 //32
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 //64
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 //128
ENDDUMP
BufferB:
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 //32
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 //64
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 //128
ENDDUMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment