Skip to content

Instantly share code, notes, and snippets.

@JuniorDjjr
Last active January 5, 2024 17:38
// by Junior_Djjr - MixMods.com.br
// You need: https://forum.mixmods.com.br/f141-gta3script-cleo/t5206-como-criar-scripts-com-cleo
SCRIPT_START
{
LVAR_INT playerId pOtherScript hVeh // preserve order
LVAR_INT scplayer i j k iWeaponType iAmmo pVeh iVehSearchProgress bResult iSelectedSlot lListWeapon lListAmmo iListSize pWeaponInfo pBuffer
LVAR_INT hOnCarDeleteVeh lOnCarDeleteVehList bShowTrunkButton iDoorId
LVAR_FLOAT f x y z x2 y2 sizeX sizeY fProgress fDrawX
WAIT 900
IF playerId = 0
GET_PLAYER_CHAR playerId (scplayer)
// start player 2
GET_THIS_SCRIPT_STRUCT (pOtherScript)
STREAM_CUSTOM_SCRIPT "Trunk Store Weapons (Junior_Djjr).cs" 1 pOtherScript
GET_LAST_CREATED_CUSTOM_SCRIPT (pOtherScript)
fDrawX = 320.0
ELSE
fDrawX = 450.0
ENDIF
SET_SCRIPT_EVENT_CAR_DELETE ON OnCarDelete hOnCarDeleteVeh
IF NOT READ_INT_FROM_INI_FILE "CLEO\Trunk Store Weapons.ini" "Settings" "ShowTrunkButton" (bShowTrunkButton)
bShowTrunkButton = TRUE
ENDIF
WHILE TRUE
WAIT 0
IF playerId = 1
IF NOT IS_2PLAYER_GAME_GOING_ON
CONTINUE
ENDIF
GET_PLAYER_CHAR playerId (scplayer)
ENDIF
IF NOT IS_CHAR_IN_ANY_CAR scplayer
IF NOT IS_ON_SCRIPTED_CUTSCENE
AND IS_PLAYER_CONTROL_ON playerId
AND NOT IS_CHAR_DOING_ANY_IMPORTANT_TASK scplayer INCLUDE_ANIMS_BOTH
iVehSearchProgress = 0
WHILE GET_ANY_CAR_NO_SAVE_RECURSIVE iVehSearchProgress (iVehSearchProgress hVeh)
IF IS_CAR_OWNED_BY_PLAYER hVeh
AND IS_CAR_STOPPED hVeh
IF LOCATE_CHAR_DISTANCE_TO_CAR scplayer hVeh 10.0
GET_VEHICLE_SUBCLASS hVeh (i)
IF i = VEHICLE_SUBCLASS_AUTOMOBILE
OR i = VEHICLE_SUBCLASS_MTRUCK
IF DOES_CAR_HAVE_PART_NODE hVeh CAR_NODE_BOOT
GET_CAR_HEALTH hVeh i
IF i > 0
GET_CAR_DUMMY_COORD hVeh VEHICLE_DUMMY_ENGINE FALSE FALSE (x y z)
GET_CAR_MODEL hVeh i
GET_MODEL_DIMENSIONS i (f y2 f, f sizeY f)
IF sizeY < 0.0
y2 = sizeY
ENDIF
IF y < 0.0 // rear engine
y2 *= -1.0
iDoorId = 0 // use hood
ELSE
iDoorId = 1 // use trunk
ENDIF
GET_OFFSET_FROM_CAR_IN_WORLD_COORDS hVeh 0.0 y2 0.0 (x y z)
IF LOCATE_CHAR_DISTANCE_TO_COORDINATES scplayer x y z 1.2
IF bShowTrunkButton = TRUE
CONVERT_3D_TO_SCREEN_2D x y z TRUE TRUE (x2 y2 sizeX sizeY)
GET_FIXED_XY_ASPECT_RATIO sizeX sizeY (sizeX sizeY)
GET_CURRENT_CAMERA_MODE i
IF i = CAMERAMODE_TWOPLAYER
sizeX *= 0.8
sizeY *= 1.4
ELSE
sizeX *= 0.4
sizeY *= 0.7
ENDIF
SET_TEXT_SCALE sizeX sizeY
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_CENTRE TRUE
SET_TEXT_FONT FONT_MENU
DISPLAY_TEXT x2 y2 TSWEP01
USE_TEXT_COMMANDS 0
ENDIF
IF IS_BUTTON_PRESSED playerId DPADUP
AND IS_CHAR_STOPPED scplayer
//SET_PLAYER_CONTROL_PAD_MOVEMENT playerId OFF
FREEZE_CHAR_POSITION scplayer ON
GET_CAR_COORDINATES hVeh x y z
TASK_LOOK_AT_VEHICLE scplayer hVeh -1
OPEN_SEQUENCE_TASK i
TASK_TURN_CHAR_TO_FACE_COORD -1 x y z
CLOSE_SEQUENCE_TASK i
PERFORM_SEQUENCE_TASK scplayer i
CLEAR_SEQUENCE_TASK i
bResult = FALSE
timera = 0
WHILE timera < 5000
WAIT 0
// For 2 player compatibility
IF NOT DOES_CHAR_EXIST scplayer
OR NOT DOES_VEHICLE_EXIST hVeh
BREAK
ENDIF
GET_SCRIPT_TASK_STATUS scplayer 0x618 (i) //PERFORM_SEQUENCE_TASK
IF i = 7
GET_DOOR_ANGLE_RATIO hVeh iDoorId fProgress
ABS_LVAR_FLOAT fProgress
CLAMP_FLOAT fProgress 0.0 1.0 (fProgress)
IF fProgress < 1.0
REQUEST_ANIMATION cardoorwhand
LOAD_ALL_MODELS_NOW
WHILE fProgress < 1.0
WAIT 0
IF NOT DOES_CHAR_EXIST scplayer
OR NOT DOES_VEHICLE_EXIST hVeh
BREAK
ENDIF
IF GOSUB IsOtherScriptUsingThisVeh
BREAK
ENDIF
TASK_PLAY_ANIM_NON_INTERRUPTABLE scplayer "fucku" "cardoorwhand" 4.0 FALSE FALSE FALSE FALSE -1
SET_CHAR_ANIM_PLAYING_FLAG scplayer "fucku" OFF
EASE fProgress EASE_MODE_CUBIC EASE_WAY_INOUT (f)
f *= 0.25
SET_CHAR_ANIM_CURRENT_TIME scplayer "fucku" f
f *= 4.0
OPEN_CAR_DOOR_A_BIT hVeh iDoorId f
IF IS_WANTED_LEVEL_GREATER 0 1
fProgress +=@ 0.04
ELSE
fProgress +=@ 0.02
ENDIF
ENDWHILE
SET_CHAR_ANIM_PLAYING_FLAG scplayer "fucku" ON
ENDIF
bResult = TRUE
BREAK
ENDIF
ENDWHILE
IF bResult = TRUE
AND DOES_CHAR_EXIST scplayer
AND DOES_VEHICLE_EXIST hVeh
IF GET_EXTENDED_CAR_VAR hVeh TSWP 1 (lListWeapon) // use TSWP for adapt other mods
GET_EXTENDED_CAR_VAR hVeh TSWP 2 (lListAmmo)
ELSE
INIT_EXTENDED_CAR_VARS hVeh TSWP 2
CREATE_LIST DATATYPE_INT (lListWeapon)
CREATE_LIST DATATYPE_INT (lListAmmo)
SET_EXTENDED_CAR_VAR hVeh TSWP 1 lListWeapon
SET_EXTENDED_CAR_VAR hVeh TSWP 2 lListAmmo
ENDIF
// -- Menu loop
WHILE NOT IS_BUTTON_JUST_PRESSED playerId TRIANGLE
USE_TEXT_COMMANDS 0
WAIT 0
IF NOT DOES_CHAR_EXIST scplayer
OR NOT DOES_VEHICLE_EXIST hVeh
BREAK
ENDIF
TASK_PLAY_ANIM_NON_INTERRUPTABLE scplayer "NULL" "NULL" 4.0 FALSE FALSE FALSE FALSE -1
FREEZE_CHAR_POSITION scplayer ON
// Keep forcing door opened
OPEN_CAR_DOOR_A_BIT hVeh iDoorId 1.0
GET_LIST_SIZE lListWeapon (iListSize)
IF IS_BUTTON_JUST_PRESSED playerId DPADRIGHT
++iSelectedSlot
IF iSelectedSlot >= iListSize
iSelectedSlot = iListSize - 1
IF iSelectedSlot < 0
iSelectedSlot = 0
ENDIF
ENDIF
ENDIF
IF IS_BUTTON_JUST_PRESSED playerId DPADLEFT
--iSelectedSlot
IF iSelectedSlot < 0
iSelectedSlot = iListSize - 1
IF iSelectedSlot < 0
iSelectedSlot = 0
ENDIF
ENDIF
ENDIF
DRAW_RECT fDrawX 224.0 85.0 100.0 0 0 0 180
GOSUB TextFormat
i = iSelectedSlot + 1
IF i > iListSize
i = iListSize
ENDIF
DISPLAY_TEXT_WITH_2_NUMBERS fDrawX 215.0 TSWEP02 i iListSize
IF iListSize >= 16
IF IS_BUTTON_JUST_PRESSED playerId DPADDOWN
SET_TEXT_COLOUR 255 100 0 255
ENDIF
ENDIF
GOSUB TextFormatSmall
DISPLAY_TEXT_WITH_NUMBER fDrawX 225.0 TSWEP03 16
GOSUB TextFormat
DISPLAY_TEXT fDrawX 190.0 TSWEP04 // Get
GOSUB TextFormat
DISPLAY_TEXT fDrawX 250.0 TSWEP05 // Store
GOSUB TextFormat
f = fDrawX - 30.0
DISPLAY_TEXT f 220.0 TSWEP06 // <
GOSUB TextFormat
f = fDrawX + 30.0
DISPLAY_TEXT f 220.0 TSWEP07 // >
GET_CURRENT_CHAR_WEAPON scplayer iWeaponType
IF iWeaponType > 0
AND NOT iWeaponType = 40 // ignore detonator
GET_WEAPONINFO iWeaponType 1 pWeaponInfo
GET_WEAPONINFO_MODELS pWeaponInfo j k
IF j > 0
GOSUB TextFormatSmall
GET_LABEL_POINTER Buffer2 (pBuffer)
CLEO_CALL ShowWeaponName 0 (iWeaponType pBuffer fDrawX 260.0)()
IF IS_BUTTON_JUST_PRESSED playerId DPADDOWN
IF iListSize < 16
LIST_ADD lListWeapon iWeaponType
GET_AMMO_IN_CHAR_WEAPON scplayer iWeaponType iAmmo
LIST_ADD lListAmmo iAmmo
REMOVE_WEAPON_FROM_CHAR scplayer iWeaponType
ENDIF
ENDIF
ENDIF
ENDIF
IF iListSize > 0
GET_LIST_VALUE_BY_INDEX lListWeapon iSelectedSlot (iWeaponType)
IF iWeaponType > 0
GET_WEAPONINFO iWeaponType 1 pWeaponInfo
GET_WEAPONINFO_MODELS pWeaponInfo j k
IF j > 0
GOSUB TextFormatSmall
GET_LABEL_POINTER Buffer (pBuffer)
CLEO_CALL ShowWeaponName 0 (iWeaponType pBuffer fDrawX 180.0)()
IF IS_BUTTON_JUST_PRESSED playerId DPADUP
IF j > 0
REQUEST_MODEL j
ENDIF
IF k > 0
REQUEST_MODEL k
ENDIF
LOAD_ALL_MODELS_NOW
GET_LIST_VALUE_BY_INDEX lListAmmo iSelectedSlot (iAmmo)
GIVE_WEAPON_TO_CHAR scplayer iWeaponType iAmmo
SET_CURRENT_CHAR_WEAPON scplayer iWeaponType
IF j > 0
MARK_MODEL_AS_NO_LONGER_NEEDED j
ENDIF
IF k > 0
MARK_MODEL_AS_NO_LONGER_NEEDED k
ENDIF
//PRINT_FORMATTED_NOW "give weapon %i" 1000 i
LIST_REMOVE_INDEX lListWeapon iSelectedSlot
LIST_REMOVE_INDEX lListAmmo iSelectedSlot
ENDIF
ENDIF
ENDIF
ENDIF
ENDWHILE
USE_TEXT_COMMANDS 0
GET_DOOR_ANGLE_RATIO hVeh iDoorId fProgress
ABS_LVAR_FLOAT fProgress
CLAMP_FLOAT fProgress 0.0 1.0 (fProgress)
IF fProgress > 0.0
WHILE fProgress > 0.0
WAIT 0
IF NOT DOES_CHAR_EXIST scplayer
OR NOT DOES_VEHICLE_EXIST hVeh
BREAK
ENDIF
IF GOSUB IsOtherScriptUsingThisVeh
BREAK
ENDIF
IF IS_WANTED_LEVEL_GREATER 0 1
fProgress -=@ 0.04
ELSE
fProgress -=@ 0.02
ENDIF
IF fProgress < 0.0
fProgress = 0.0
ENDIF
TASK_PLAY_ANIM_NON_INTERRUPTABLE scplayer "fucku" "cardoorwhand" 4.0 FALSE FALSE FALSE FALSE -1
SET_CHAR_ANIM_PLAYING_FLAG scplayer "fucku" OFF
EASE fProgress EASE_MODE_CUBIC EASE_WAY_INOUT (f)
f *= 0.25
SET_CHAR_ANIM_CURRENT_TIME scplayer "fucku" f
f *= 4.0
OPEN_CAR_DOOR_A_BIT hVeh iDoorId f
ENDWHILE
SET_CHAR_ANIM_PLAYING_FLAG scplayer "fucku" ON
ENDIF
ENDIF
//SET_PLAYER_CONTROL_PAD_MOVEMENT playerId ON
IF DOES_CHAR_EXIST scplayer
FREEZE_CHAR_POSITION scplayer OFF
CLEAR_LOOK_AT scplayer
CLEAR_CHAR_PRIMARY_TASKS scplayer
ENDIF
REMOVE_ANIMATION "cardoorwhand"
ELSE
BREAK // break the recursive search vehicle loop
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDWHILE
ENDIF
ENDIF
hVeh = -1 // important for IsOtherScriptUsingThisVeh
ENDWHILE
IsOtherScriptUsingThisVeh:
GET_THREAD_VAR pOtherScript 2 (i)
IF i = hVeh
RETURN_TRUE
RETURN
ENDIF
RETURN_FALSE
RETURN
TextFormat:
GET_FIXED_XY_ASPECT_RATIO 0.3 0.9 (sizeX sizeY)
SET_TEXT_SCALE sizeX sizeY
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_CENTRE TRUE
SET_TEXT_FONT FONT_MENU
RETURN
TextFormatSmall:
GET_FIXED_XY_ASPECT_RATIO 0.25 0.75 (sizeX sizeY)
SET_TEXT_SCALE sizeX sizeY
SET_TEXT_EDGE 1 0 0 0 255
SET_TEXT_CENTRE TRUE
SET_TEXT_FONT FONT_MENU
RETURN
OnCarDelete:
IF GET_EXTENDED_CAR_VAR hOnCarDeleteVeh TSWP 1 (lOnCarDeleteVehList)
DELETE_LIST lOnCarDeleteVehList
GET_EXTENDED_CAR_VAR hOnCarDeleteVeh TSWP 2 (lOnCarDeleteVehList)
DELETE_LIST lOnCarDeleteVehList
ENDIF
RETURN_SCRIPT_EVENT
}
SCRIPT_END
{
LVAR_INT iWeaponType pBuffer //In
LVAR_FLOAT fDrawX y //In
LVAR_INT i
LVAR_TEXT_LABEL tWeaponName
ShowWeaponName:
STRING_FORMAT tWeaponName "WEAP%i" iWeaponType
WRITE_MEMORY pBuffer 64 0 FALSE
GET_TEXT_LABEL_STRING $tWeaponName (pBuffer)
GET_STRING_LENGTH $pBuffer (i)
IF i > 0
DISPLAY_TEXT fDrawX y $tWeaponName // Weapon name
ELSE
DISPLAY_TEXT_WITH_NUMBER fDrawX y WEAPNUM iWeaponType // Weapon ID
ENDIF
CLEO_RETURN 0 ()
}
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
Buffer2:
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