Last active
January 5, 2024 17:51
-
-
Save JuniorDjjr/55df5044c6ec5de88f2e085dce809edb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false | |
SCRIPT_START | |
{ | |
LVAR_INT iPlayerId // Preserve order | |
LVAR_INT scplayer i iCurHealth iLastCurHealth iMaxHealth p iWithDelay iFinalHealth bPatchHud bNoSAMP | |
LVAR_FLOAT f fMaxHealth fCurHealth fCurHealthPercent fFinalHealth fIfLessThan fIncreaseTo fUsingSpeed fRegeHealthPercent fFlashHudHealth | |
WAIT 1100 | |
IF iPlayerId = 0 | |
STREAM_CUSTOM_SCRIPT "Simple Regeneration (Junior_Djjr).cs" 1 | |
IF DOES_FILE_EXIST "CLEO\Simple Regeneration - Player 2.cs" | |
DELETE_FILE "CLEO\Simple Regeneration - Player 2.cs" | |
IF DOES_FILE_EXIST "CLEO\Simple Regeneration - Player 2.cs" | |
PRINT_STRING_NOW "~r~Warning: Delete 'CLEO\Simple Regeneration - Player 2.cs' and restart your game." 10000 | |
ELSE | |
PRINT_STRING_NOW "~r~File deleted: 'CLEO\Simple Regeneration - Player 2.cs'. Restart your game." 10000 | |
ENDIF | |
ENDIF | |
ENDIF | |
GET_PLAYER_CHAR iPlayerId scplayer | |
READ_FLOAT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "IfLessThan" (fIfLessThan) | |
READ_FLOAT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "IncreaseTo" (fIncreaseTo) | |
READ_FLOAT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "UsingSpeed" (fUsingSpeed) | |
READ_INT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "WithDelay" (iWithDelay) | |
READ_INT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "PatchHud" (bPatchHud) | |
READ_INT_FROM_INI_FILE "CLEO/Simple Regeneration.ini" "Settings" "NoSAMP" (bNoSAMP) | |
IF bNoSAMP = TRUE | |
IF LOAD_DYNAMIC_LIBRARY "SAMP.dll" i | |
TERMINATE_THIS_CUSTOM_SCRIPT | |
ENDIF | |
ENDIF | |
fIfLessThan /= 100.0 | |
fIncreaseTo /= 100.0 | |
fUsingSpeed /= 50.0 | |
timerb = 99999 | |
WHILE TRUE | |
WAIT 0 | |
IF iPlayerId = 1 | |
IF IS_2PLAYER_GAME_GOING_ON | |
GET_PLAYER_CHAR iPlayerId scplayer | |
ELSE | |
CONTINUE | |
ENDIF | |
ENDIF | |
IF GOSUB StoreValues | |
IF bPatchHud = TRUE | |
IF timerb > 2500 // we don't need it every time | |
f = fIncreaseTo * 100.0 | |
fFlashHudHealth = f * fMaxHealth | |
fFlashHudHealth /= 100.0 | |
i =# fFlashHudHealth | |
i -= 1 | |
WRITE_MEMORY 0x5892AB 2 i TRUE | |
timerb = 0 | |
ENDIF | |
ENDIF | |
IF fCurHealthPercent < fIfLessThan | |
GOSUB RunRegeneration | |
ENDIF | |
ENDIF | |
ENDWHILE | |
RunRegeneration: | |
iLastCurHealth = iCurHealth | |
timera = 0 | |
WHILE timera < iWithDelay | |
IF GOSUB ProcessCancel | |
RETURN | |
ENDIF | |
GET_CHAR_HEALTH scplayer (iCurHealth) | |
IF NOT iLastCurHealth = iCurHealth | |
RETURN | |
ENDIF | |
ENDWHILE | |
fRegeHealthPercent = fCurHealthPercent | |
WHILE TRUE | |
IF GOSUB ProcessCancel | |
RETURN | |
ENDIF | |
GET_CHAR_HEALTH scplayer (iCurHealth) | |
IF iCurHealth < iLastCurHealth // was damaged | |
RETURN | |
ENDIF | |
IF GOSUB StoreValues | |
ELSE | |
RETURN | |
ENDIF | |
IF fCurHealthPercent > fRegeHealthPercent | |
fRegeHealthPercent = fCurHealthPercent + 1.0 | |
ENDIF | |
fRegeHealthPercent +=@ fUsingSpeed | |
IF fRegeHealthPercent > fIncreaseTo | |
GOSUB SetHealthByPercent | |
BREAK | |
ENDIF | |
GOSUB SetHealthByPercent | |
iLastCurHealth = iFinalHealth | |
ENDWHILE | |
RETURN | |
SetHealthByPercent: | |
fFinalHealth = fMaxHealth * fRegeHealthPercent | |
iFinalHealth =# fFinalHealth | |
SET_CHAR_HEALTH scplayer iFinalHealth | |
RETURN | |
StoreValues: | |
GET_CHAR_HEALTH scplayer (iCurHealth) | |
IF iCurHealth > 0 | |
READ_MEMORY 0xB7CEE7 1 FALSE (iMaxHealth) | |
fMaxHealth =# iMaxHealth | |
fCurHealth =# iCurHealth | |
fCurHealthPercent = fCurHealth / fMaxHealth | |
RETURN_TRUE | |
RETURN | |
ENDIF | |
RETURN_FALSE | |
RETURN | |
ProcessCancel: | |
WAIT 0 | |
GET_PLAYER_CHAR iPlayerId scplayer | |
IF NOT DOES_CHAR_EXIST scplayer | |
RETURN_TRUE | |
RETURN | |
ENDIF | |
RETURN_FALSE | |
RETURN | |
} | |
SCRIPT_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment