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/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 i j
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)
ELSE
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
FREE_DYNAMIC_LIBRARY pLib
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
FREE_DYNAMIC_LIBRARY pLib
// Load neon_api.asi
IF LOAD_DYNAMIC_LIBRARY "neon_api.asi" pLib
GET_DYNAMIC_LIBRARY_PROCEDURE "GetRed" pLib (i)
GET_LABEL_POINTER GetRed (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "GetGreen" pLib (i)
GET_LABEL_POINTER GetGreen (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "GetBlue" pLib (i)
GET_LABEL_POINTER GetBlue (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "SetRed" pLib (i)
GET_LABEL_POINTER SetRed (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "SetGreen" pLib (i)
GET_LABEL_POINTER SetGreen (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "SetBlue" pLib (i)
GET_LABEL_POINTER SetBlue (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "IsNeonInstalled" pLib (i)
GET_LABEL_POINTER IsNeonInstalled (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "IsPulsing" pLib (i)
GET_LABEL_POINTER IsPulsing (j)
WRITE_MEMORY j 4 i FALSE
GET_DYNAMIC_LIBRARY_PROCEDURE "SetPulsing" pLib (i)
GET_LABEL_POINTER SetPulsing (j)
WRITE_MEMORY j 4 i FALSE
ELSE
timera = 0
WHILE timera < 5000
WAIT 0
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Nao foi possivel carregar o neon_api.asi. Tenha certeza que o mod de Neon Pulsante esteja instalado." 1000
ELSE
PRINT_STRING_NOW "~r~Unable to load neon_api.asi. Make sure you have Pulsing Neon mod installed." 1000
ENDIF
ENDWHILE
FREE_DYNAMIC_LIBRARY pLib
TERMINATE_THIS_CUSTOM_SCRIPT
ENDIF
FREE_DYNAMIC_LIBRARY pLib
// 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 headlight color is set
IF IS_LOCAL_VAR_BIT_SET_CONST isEdited 0
Installed:
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
// headlight is not set.. but neon?
IF CLEO_CALL CheckNeonInstalled 0 (hVeh)
GOSUB UpdateColor
//GET_LABEL_POINTER SetPulsing (j)
//READ_MEMORY j 4 FALSE (j)
//CALL_FUNCTION j 2 2 (0 i)
GOTO Installed
ENDIF
IF iLanguage = LANG_PT
PRINT_STRING_NOW "~r~Voce precisa colocar uma nova cor de farol no Tuning Mod ou usar mod Neon Pulsante (estatico) antes de ativar." 5000
ELSE
PRINT_STRING_NOW "~r~You need to set a new headlight color at Tuning Mod or use Pulsing Neon mod (static) before enable it." 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 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
IF iBassLevel < 0
iBassLevel = 0
ENDIF
// Change headlight alpha by bass level
IF IS_LOCAL_VAR_BIT_SET_CONST isEdited 0
CALL_FUNCTION pTMSetLightAlphaRGB 4 4 (iBassLevel iBassLevel iBassLevel hVeh) ()
// Make car lights always on
FORCE_CAR_LIGHTS hVeh 2
ENDIF
// 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
fr *= 2.5
fg *= 2.5
fb *= 2.5
r =# fr
g =# fg
b =# fb
IF CLEO_CALL CheckNeonInstalled 0 (hVeh)
GET_VEHICLE_POINTER hVeh i
GET_LABEL_POINTER SetRed (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (r i)
GET_LABEL_POINTER SetGreen (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (g i)
GET_LABEL_POINTER SetBlue (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (b i)
ENDIF
// Set LED Lighting
IF bLedInitialized = TRUE
fr =# r
fg =# g
fb =# b
fr /= 2.5
fg /= 2.5
fb /= 2.5
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
GOSUB UpdateColor
IF CLEO_CALL CheckNeonInstalled 0 (hVeh)
GET_VEHICLE_POINTER hVeh i
GET_LABEL_POINTER SetRed (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (r i)
GET_LABEL_POINTER SetGreen (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (g i)
GET_LABEL_POINTER SetBlue (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION j 2 2 (b i)
//GET_LABEL_POINTER SetPulsing (j)
//READ_MEMORY j 4 FALSE (j)
//CALL_FUNCTION j 2 2 (1 i)
ENDIF
GET_LABEL_POINTER NeonRed (j)
WRITE_MEMORY j 4 -1 FALSE
IF IS_LOCAL_VAR_BIT_SET_CONST isEdited 0
CALL_FUNCTION pTMSetLightAlphaRGB 4 4 (bak_a bak_a bak_a hVeh) ()
ENDIF
CALL_FUNCTION pLogiLedShutdown 0 0 () ()
bLedInitialized = FALSE
FORCE_CAR_LIGHTS hVeh 0
ENDIF
bReset = FALSE
ENDIF
ENDIF
ENDWHILE
///////////////////////////////////////////////////////////////////////////////////////////////////
UpdateColor:
IF pTMGetLightColorsRGBAStruct > 0
CALL_FUNCTION_RETURN pTMGetLightColorsRGBAStruct 2 2 (pRGBA hVeh) (isEdited)
IF IS_LOCAL_VAR_BIT_SET_CONST isEdited 0
GOSUB CreateColorBackup
RETURN
ENDIF
ENDIF
IF CLEO_CALL CheckNeonInstalled 0 (hVeh)
GET_LABEL_POINTER NeonRed (j)
READ_MEMORY j 4 FALSE (r)
IF r >= 0
GET_LABEL_POINTER NeonGreen (j)
READ_MEMORY j 4 FALSE (g)
GET_LABEL_POINTER NeonBlue (j)
READ_MEMORY j 4 FALSE (b)
ELSE
GET_VEHICLE_POINTER hVeh i
GET_LABEL_POINTER GetRed (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION_RETURN j 1 1 i (r)
GET_LABEL_POINTER NeonRed (j)
WRITE_MEMORY j 4 r FALSE
GET_LABEL_POINTER GetGreen (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION_RETURN j 1 1 i (g)
GET_LABEL_POINTER NeonGreen (j)
WRITE_MEMORY j 4 g FALSE
GET_LABEL_POINTER GetBlue (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION_RETURN j 1 1 i (b)
GET_LABEL_POINTER NeonBlue (j)
WRITE_MEMORY j 4 b FALSE
ENDIF
GOSUB CreateColorBackup
RETURN
ENDIF
r = 0
g = 0
b = 0
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 i j
CheckNeonInstalled:
GET_VEHICLE_POINTER hVeh i
GET_LABEL_POINTER IsNeonInstalled (j)
READ_MEMORY j 4 FALSE (j)
IF j > 0
CALL_FUNCTION_RETURN j 1 1 i (j)
IF NOT j = FALSE
GET_LABEL_POINTER IsPulsing (j)
READ_MEMORY j 4 FALSE (j)
CALL_FUNCTION_RETURN j 1 1 i (j)
IF j = FALSE // not pulsing
RETURN_TRUE
CLEO_RETURN 0 ()
ENDIF
ENDIF
ENDIF
RETURN_FALSE
CLEO_RETURN 0 ()
}
{
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
GetRed:
DUMP
00 00 00 00
ENDDUMP
GetGreen:
DUMP
00 00 00 00
ENDDUMP
GetBlue:
DUMP
00 00 00 00
ENDDUMP
SetRed:
DUMP
00 00 00 00
ENDDUMP
SetGreen:
DUMP
00 00 00 00
ENDDUMP
SetBlue:
DUMP
00 00 00 00
ENDDUMP
NeonRed:
DUMP
FF FF FF FF
ENDDUMP
NeonGreen:
DUMP
FF FF FF FF
ENDDUMP
NeonBlue:
DUMP
FF FF FF FF
ENDDUMP
IsNeonInstalled:
DUMP
00 00 00 00
ENDDUMP
IsPulsing:
DUMP
00 00 00 00
ENDDUMP
SetPulsing:
DUMP
00 00 00 00
ENDDUMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.