Skip to content

Instantly share code, notes, and snippets.

@JuniorDjjr
Last active January 5, 2024 18:08
Show Gist options
  • Save JuniorDjjr/234be473d96984eb76f6b27bcca0556e to your computer and use it in GitHub Desktop.
Save JuniorDjjr/234be473d96984eb76f6b27bcca0556e to your computer and use it in GitHub Desktop.
/*
You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
TODO: Add also for hot dogs and vending machines?
*/
SCRIPT_START
{
LVAR_INT scplayer
LVAR_INT hObject ryder
LVAR_INT iModelBurger iModelChicken iModelPizza iModelDonut iModelHotDog
LVAR_FLOAT fProgress
IF NOT READ_INT_FROM_INI_FILE "cleo/Food Eating Fix.ini" "Models" "Burger" iModelBurger
iModelBurger = 2880 //CJ_BURG_2
ENDIF
IF NOT READ_INT_FROM_INI_FILE "cleo/Food Eating Fix.ini" "Models" "Chicken" iModelChicken
iModelChicken = 2880 //CJ_BURG_2
ENDIF
IF NOT READ_INT_FROM_INI_FILE "cleo/Food Eating Fix.ini" "Models" "Pizza" iModelPizza
iModelPizza = 2702 //CJ_PIZZA_1
ENDIF
IF NOT READ_INT_FROM_INI_FILE "cleo/Food Eating Fix.ini" "Models" "Donut" iModelDonut
iModelDonut = 2880 //CJ_BURG_2
ENDIF
IF NOT READ_INT_FROM_INI_FILE "cleo/Food Eating Fix.ini" "Models" "HotDog" iModelHotDog
iModelHotDog = 2880 //CJ_BURG_2
ENDIF
GET_PLAYER_CHAR 0 scplayer
WHILE TRUE
WAIT 0
// Hotdog
IF IS_CHAR_PLAYING_ANIM scplayer "VEND_EAT1_P"
REQUEST_MODEL iModelHotDog
LOAD_ALL_MODELS_NOW
CREATE_OBJECT_NO_OFFSET iModelHotDog 0.0 0.0 0.0 hObject
MARK_MODEL_AS_NO_LONGER_NEEDED iModelHotDog
TASK_PICK_UP_OBJECT scplayer hObject 0.1 0.0 -0.05 5 16 "NULL" "NULL" 0
WHILE IS_CHAR_PLAYING_ANIM scplayer "VEND_EAT1_P"
WAIT 0
GET_CHAR_ANIM_CURRENT_TIME scplayer "VEND_EAT1_P" fProgress
IF fProgress > 0.8
BREAK
ENDIF
ENDWHILE
DELETE_OBJECT hObject
ENDIF
// Burger
IF IS_CHAR_PLAYING_ANIM scplayer "EAT_Burger"
IF LOCATE_CHAR_ANY_MEANS_3D scplayer (379.0799 -186.6528 1000.5) (20.0 20.0 10.0) FALSE
REQUEST_MODEL iModelDonut
LOAD_ALL_MODELS_NOW
CREATE_OBJECT_NO_OFFSET iModelDonut 0.0 0.0 0.0 hObject
MARK_MODEL_AS_NO_LONGER_NEEDED iModelDonut
ELSE
REQUEST_MODEL iModelBurger
LOAD_ALL_MODELS_NOW
CREATE_OBJECT_NO_OFFSET iModelBurger 0.0 0.0 0.0 hObject
MARK_MODEL_AS_NO_LONGER_NEEDED iModelBurger
ENDIF
TASK_PICK_UP_OBJECT scplayer hObject 0.0 0.0 0.0 6 16 "NULL" "NULL" 0
WHILE IS_CHAR_PLAYING_ANIM scplayer "EAT_Burger"
WAIT 0
GET_CHAR_ANIM_CURRENT_TIME scplayer "EAT_Burger" fProgress
IF fProgress > 0.8
BREAK
ENDIF
ENDWHILE
DELETE_OBJECT hObject
ENDIF
// Chicken
IF IS_CHAR_PLAYING_ANIM scplayer "EAT_Chicken"
REQUEST_MODEL iModelChicken
LOAD_ALL_MODELS_NOW
CREATE_OBJECT_NO_OFFSET iModelChicken 0.0 0.0 0.0 hObject
MARK_MODEL_AS_NO_LONGER_NEEDED iModelChicken
TASK_PICK_UP_OBJECT scplayer hObject 0.0 0.0 0.0 6 16 "NULL" "NULL" 0
WHILE IS_CHAR_PLAYING_ANIM scplayer "EAT_Chicken"
WAIT 0
GET_CHAR_ANIM_CURRENT_TIME scplayer "EAT_Chicken" fProgress
IF fProgress > 0.9
BREAK
ENDIF
ENDWHILE
DELETE_OBJECT hObject
ENDIF
// Pizza
IF IS_CHAR_PLAYING_ANIM scplayer "EAT_Pizza"
// Workaround to fix crash in Ryder mission; GET_SCRIPT_STRUCT_NAMED doesn't return correctly
IF LOCATE_CHAR_ANY_MEANS_3D scplayer (374.0681 -119.4528 1001.4922) (20.0 20.0 10.0) FALSE
CLEO_CALL ReadGlobalVar 0 (132)(ryder)
IF ryder > 0
IF DOES_CHAR_EXIST ryder
CONTINUE
ENDIF
ENDIF
ENDIF
REQUEST_MODEL iModelPizza
LOAD_ALL_MODELS_NOW
CREATE_OBJECT_NO_OFFSET iModelPizza 0.0 0.0 0.0 hObject
MARK_MODEL_AS_NO_LONGER_NEEDED iModelPizza
TASK_PICK_UP_OBJECT scplayer hObject 0.05 0.1 0.0 6 16 "NULL" "NULL" 0
WHILE IS_CHAR_PLAYING_ANIM scplayer "EAT_Pizza"
WAIT 0
GET_CHAR_ANIM_CURRENT_TIME scplayer "EAT_Pizza" fProgress
IF fProgress > 0.9
BREAK
ENDIF
ENDWHILE
DELETE_OBJECT hObject
ENDIF
ENDWHILE
}
SCRIPT_END
{
LVAR_INT var //In
LVAR_INT value scriptSpace finalOffset
ReadGlobalVar:
READ_MEMORY 0x00468D5E 4 1 (scriptSpace)
finalOffset = var * 4
finalOffset += scriptSpace
READ_MEMORY finalOffset 4 FALSE (value)
CLEO_RETURN 0 (value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment