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/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
SCRIPT_START
{
LVAR_INT scplayer pLib isEdited hVeh bEnabled bReset
LVAR_INT pTMGetLightColorsRGBAStruct pTMSetLightAlphaRGB
LVAR_INT pLogiLedInitWithName pLogiLedSetLighting pLogiLedShutdown
LVAR_INT pRGBA r g b a bak_r bak_g bak_b bak_a
LVAR_FLOAT fr fg fb fa
LVAR_FLOAT fBassLevel
LVAR_INT iBassLevel bLedInitialized bEnableLED
LVAR_INT iLanguage psCommand
CONST_INT LANG_PT 1
CONST_INT LANG_EN 2
GET_PLAYER_CHAR 0 scplayer
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load language from Tuning Mod + check Tuning Mod installation
IF NOT READ_INT_FROM_INI_FILE "CLEO/Tuning Mod/Tuning Mod - CFG.ini" "CONFG" "Language" (iLanguage)
timera = 0
WHILE timera < 4000
WAIT 0
PRINT_STRING_NOW "~r~EN: Tuning Mod isn't installed.~n~PT: Tuning Mod nao esta instalado." 1000
ENDWHILE
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
// Load mod ini
GET_LABEL_POINTER Command (psCommand)
IF NOT READ_INT_FROM_INI_FILE "CLEO/Music Bass Light.ini" "Settings" "EnableLogitechLED" (bEnableLED)
OR NOT READ_STRING_FROM_INI_FILE "CLEO/Music Bass Light.ini" "Settings" "Command" (psCommand)
timera = 0
WHILE timera < 4000
WAIT 0
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Nao foi possivel ler o arquivo 'CLEO/Music Bass Light.ini'." 1000
ELSE
PRINT_STRING_NOW "~r~Unable to read file 'CLEO/Music Bass Light.ini'." 1000
ENDIF
ENDWHILE
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
// Load TM.asi
IF LOAD_DYNAMIC_LIBRARY "TM.asi" pLib
GET_DYNAMIC_LIBRARY_PROCEDURE "TMGetLightColorsRGBAStruct" pLib (pTMGetLightColorsRGBAStruct)
GET_DYNAMIC_LIBRARY_PROCEDURE "TMSetLightAlphaRGB" pLib (pTMSetLightAlphaRGB)
ENDIF
IF NOT pTMGetLightColorsRGBAStruct > 0
OR NOT pTMSetLightAlphaRGB > 0
timera = 0
WHILE timera < 5000
WAIT 0
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Nao foi possivel carregar o TM.asi. Tenha certeza que o Tuning Mod v3 esteja instalado." 1000
ELSE
PRINT_STRING_NOW "~r~Unable to load TM.asi. Make sure you have Tuning Mod v3 installed." 1000
ENDIF
ENDWHILE
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
// Load Logitech LED
IF bEnableLED = TRUE
IF LOAD_DYNAMIC_LIBRARY "LogitechLedEnginesWrapper.dll" pLib
GET_DYNAMIC_LIBRARY_PROCEDURE "LogiLedInitWithName" pLib (pLogiLedInitWithName)
GET_DYNAMIC_LIBRARY_PROCEDURE "LogiLedSetLighting" pLib (pLogiLedSetLighting)
GET_DYNAMIC_LIBRARY_PROCEDURE "LogiLedShutdown" pLib (pLogiLedShutdown)
ENDIF
IF NOT pLogiLedInitWithName > 0
OR NOT pLogiLedSetLighting > 0
OR NOT pLogiLedShutdown > 0
timera = 0
WHILE timera < 4000
WAIT 0
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Nao foi possivel carregar o 'LogitechLedEnginesWrapper.dll'." 1000
ELSE
PRINT_STRING_NOW "~r~Unable to load 'LogitechLedEnginesWrapper.dll'." 1000
ENDIF
ENDWHILE
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
ENDIF
///////////////////////////////////////////////////////////////////////////////////////////////////
WHILE TRUE
WAIT 0
IF TEST_CHEAT $psCommand
// If enabled, just disable it
IF bEnabled = TRUE
bEnabled = FALSE
bReset = TRUE
PRINT_STRING_NOW "Music Bass Light: ~r~OFF" 2000
ELSE
IF IS_CHAR_SITTING_IN_ANY_CAR scplayer
STORE_CAR_CHAR_IS_IN_NO_SAVE scplayer hVeh
WAIT 0 // workaround to make it not bug because of indie handling update
IF DOES_VEHICLE_EXIST hVeh // was not despawn in last frame
// Get RGBA and store it in thread vars
GET_VAR_POINTER r (pRGBA)
CALL_FUNCTION_RETURN pTMGetLightColorsRGBAStruct 2 2 (pRGBA hVeh) (isEdited)
// Check if new headlighting color is set
IF IS_LOCAL_VAR_BIT_SET_CONST isEdited 0
bEnabled = TRUE
PRINT_STRING_NOW "Music Bass Light: ~b~ON" 2000
// Make color backup + alpha backup
GOSUB CreateColorBackup
bak_a = a
// Init LED
IF bEnableLED = TRUE
CALL_FUNCTION_RETURN pLogiLedInitWithName 1 1 ("MDPMv5")(bLedInitialized)
WAIT 500 // Wait for initialization
IF NOT bLedInitialized = TRUE
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Nao foi possivel iniciar o LED. Tente reiniciar o software Logitech." 5000
ELSE
PRINT_STRING_NOW "~r~Unable to load init LED. Try to restart the Logitech software." 5000
ENDIF
ENDIF
ENDIF
ELSE
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Voce precisa colocar uma nova cor de farol no Tuning Mod antes de ativar." 5000
ELSE
PRINT_STRING_NOW "~r~You need to set a new headlight color at Tuning Mod before enable." 5000
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
// The mod is enabled
IF bEnabled = TRUE
// Disable the mod if car not exist
IF NOT DOES_VEHICLE_EXIST hVeh
bEnabled = FALSE
CONTINUE
ENDIF
// Make car lights always on
FORCE_CAR_LIGHTS hVeh 2
// Make sure the color is always updated (fixes if you change it while using this mod)
GOSUB UpdateColor
// Get MDPM bass level
CLEO_CALL GetMDPMBassLevel 0 (hVeh)(fBassLevel)
fBassLevel *= 510.0
iBassLevel =# fBassLevel
IF iBassLevel > 255
iBassLevel = 255
ENDIF
// Change headlight alpha by bass level
CALL_FUNCTION pTMSetLightAlphaRGB 4 4 (iBassLevel iBassLevel iBassLevel hVeh) ()
// Set LED Lighting
IF bLedInitialized = TRUE
// Convert 255 to 1.0
fBassLevel =# iBassLevel
fBassLevel /= 255.0
IF fBassLevel > 1.0
fBassLevel = 1.0
ENDIF
iBassLevel =# fBassLevel
// Multiply rgb to simulate alpha value
fr =# bak_r
fg =# bak_g
fb =# bak_b
fr *= fBassLevel
fg *= fBassLevel
fb *= fBassLevel
r =# fr
g =# fg
b =# fb
CALL_FUNCTION pLogiLedSetLighting 3 3 b g r
ENDIF
ELSE
// Reset alpha and shutdown LED
IF bReset = TRUE
IF DOES_VEHICLE_EXIST hVeh
CALL_FUNCTION pTMSetLightAlphaRGB 4 4 (bak_a bak_a bak_a hVeh) ()
CALL_FUNCTION pLogiLedShutdown 0 0 () ()
bLedInitialized = FALSE
FORCE_CAR_LIGHTS hVeh 0
ENDIF
bReset = FALSE
ENDIF
ENDIF
ENDWHILE
///////////////////////////////////////////////////////////////////////////////////////////////////
UpdateColor:
CALL_FUNCTION_RETURN pTMGetLightColorsRGBAStruct 2 2 (pRGBA hVeh) (isEdited)
GOSUB CreateColorBackup
RETURN
CreateColorBackup:
fr =# r
fg =# g
fb =# b
fr /= 2.55
fg /= 2.55
fb /= 2.55
bak_r =# fr
bak_g =# fg
bak_b =# fb
RETURN
}
SCRIPT_END
///////////////////////////////////////////////////////////////////////////////////////////////////
{
LVAR_INT hVeh // In
LVAR_INT p
LVAR_FLOAT fBassLevel
GetMDPMBassLevel:
GET_VEHICLE_POINTER hVeh (p)
p += 0x384 // pHandling
READ_MEMORY p 4 FALSE (p)
p += 0x105 // offset of MDPM's bass level (float)
READ_MEMORY p 4 FALSE (fBassLevel)
CLEO_RETURN 0 (fBassLevel)
}
Command:
DUMP
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