gopro_2027 Posted March 15, 2018 Share Posted March 15, 2018 (edited) Hello Gta Forums! I don't post much here because I only mod PS3, but I have something you may like! Below I have some code snippets for creating a phone based menu design, reversed mainly from the settings app script. Video of it in action: Okay so the code! I am just releasing the snippets and not a full base because I don't code pc stuff so I don't know how to do that but it's all natives, except for one bug fix (for when the game tried to close the phone, so not necessary but useful) that I had to reverse from DESTROY_MOBILE_PHONE. Code (pastebin.com/i88X3wkE): //By gopro_2027void func_38(int scaleform, char *thang, float uParam2, float fParam3, float fParam4, float fParam5, float fParam6){ GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION(scaleform, thang); GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(uParam2); if (fParam3 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam3); } if (fParam4 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam4); } if (fParam5 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam5); } if (fParam6 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam6); } GRAPHICS::_POP_SCALEFORM_MOVIE_FUNCTION_VOID();}void func_14(char *uParam0, bool stringsAreGXT = false){ if (stringsAreGXT == false) { GRAPHICS::_BEGIN_TEXT_COMPONENT("STRING"); UI::_ADD_TEXT_COMPONENT_STRING(uParam0); } else { GRAPHICS::_BEGIN_TEXT_COMPONENT(uParam0); } GRAPHICS::_END_TEXT_COMPONENT();}void func_20(int uParam0, char *uParam1, float uParam2, float fParam3, float fParam4, float fParam5, float fParam6, char *uParam7, char *uParam8, char *uParam9, char *uParam10, char *uParam11, bool stringsAreGXT = false){ GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION(uParam0, uParam1); GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(uParam2); if (fParam3 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam3); } if (fParam4 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam4); } if (fParam5 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam5); } if (fParam6 != -1.0f) { GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION_PARAMETER_INT(fParam6); } if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(uParam7)) { func_14(uParam7,stringsAreGXT); } if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(uParam8)) { func_14(uParam8,stringsAreGXT); } if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(uParam9)) { func_14(uParam9,stringsAreGXT); } if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(uParam10)) { func_14(uParam10,stringsAreGXT); } if (!GAMEPLAY::IS_STRING_NULL_OR_EMPTY(uParam11)) { func_14(uParam11,stringsAreGXT); } GRAPHICS::_POP_SCALEFORM_MOVIE_FUNCTION_VOID();}int currentOption = 0;bool createPhone = false;int phonescaleForm = -1;float sizeOfEachRow = 1.0f/maxOptions;int phoneCurrentRender = 0;int lastAmountOptionsPhone = 0;int phonerenderid = 0;#define PHONE_TYPE 22.0f//int phoneBackgroundImage = 0;int phoneTheme = 1;int phoneType = 2;float phoneSize = 500.0f;void updatePhoneTitle();void setPhoneKey(int buttonSpot, float unk1, float icon, char *unk3) { func_20(phonescaleForm, "SET_SOFT_KEYS", buttonSpot, unk1, icon, -1.0f, -1.0f, unk3, 0, 0, 0, 0);}void setupPhone() { phoneCurrentRender = 0; MOBILE::GET_MOBILE_PHONE_RENDER_ID(&phonerenderid); //check to make sure phone wasn't closed by game /* bugfix for when the game disposes of the phone when you get a call or something if (submenu != Closed) if (*(char*)0x1D6D888 == 0)//check if phone is closed or not createPhone = true; */ //create phone if requested if (createPhone) { MOBILE::CREATE_MOBILE_PHONE(phoneType);//0 is multiplayer phone //get render id MOBILE::GET_MOBILE_PHONE_RENDER_ID(&phonerenderid); createPhone = false; } //setting phone properties MOBILE::SET_MOBILE_PHONE_SCALE(phoneSize); Vector3 phonePos = {99.62,-45.305,-113}; Vector3 phoneRot = {-90,0,0}; MOBILE::SET_MOBILE_PHONE_POSITION(phonePos.x,phonePos.y,phonePos.z); MOBILE::SET_MOBILE_PHONE_ROTATION(phoneRot.x,phoneRot.y,phoneRot.z,0); //starting rendering based stuff UI::SET_TEXT_RENDER_ID(phonerenderid); phonescaleForm = GRAPHICS::REQUEST_SCALEFORM_MOVIE("cellphone_ifruit"); //clear options for (int i = 0; i < lastAmountOptionsPhone; i++) func_38(phonescaleForm, "SET_DATA_SLOT_EMPTY", PHONE_TYPE, i, -1, -1, -1); //func_38(phonescaleForm, "SET_BACKGROUND_IMAGE", phoneBackgroundImage, -1.0f, -1.0f, -1.0f, -1.0f);//not useful for this phone, but should work func_38(phonescaleForm, "SET_THEME", phoneTheme, -1.0f, -1.0f, -1.0f, -1.0f); //func_20(phonescaleForm, "SET_SOFT_KEYS", 3.0f, 1.0f, 6.0f, -1.0f, -1.0f, "CELL_202", 0, 0, 0, 0);//white phone in slot 3 setPhoneKey(3,1,6,"CELL_202"); setPhoneKey(2,1,3,"CELL_225"); setPhoneKey(1,1,4,"CELL_206"); updatePhoneTitle(); lastAmountOptionsPhone = 0;}//updatePhoneTitle() calls this functionvoid updatePhoneProvider(){ int uLocal_54,iLocal_34,iLocal_55 = 0; Vector3 c = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), 1); uLocal_54 = ZONE::GET_ZONE_SCUMMINESS(ZONE::GET_ZONE_AT_COORDS(c.x,c.y,c.z)); switch (uLocal_54) { case 0: iLocal_34 = 5; break; case 1: iLocal_34 = 5; break; case 2: iLocal_34 = 4; break; case 3: iLocal_34 = 4; break; case 4: iLocal_34 = 3; break; case 5: iLocal_34 = 2; break; default: iLocal_34 = 3; break; } iLocal_55 = GAMEPLAY::GET_RANDOM_INT_IN_RANGE(0, 8); if (iLocal_55 < 2) { if (iLocal_34 > 2) { iLocal_34--; } } int uLocal_33 = Global(87755).imm(11664).arr(Global(10434).get<int>(),20).imm(8).get<int>();//this needs to be updates to pc if u want it func_38(phonescaleForm, "SET_PROVIDER_ICON", uLocal_33, iLocal_34, -1.0f, -1.0f, -1.0f);}int currentMinutes = 0;void updatePhoneTitle() { int iLocal_36 = TIME::GET_CLOCK_MINUTES(); if (iLocal_36 != currentMinutes) { currentMinutes = iLocal_36; int uLocal_35 = TIME::GET_CLOCK_HOURS(); int uLocal_37 = TIME::GET_CLOCK_DAY_OF_WEEK(); char cLocal_38[16]; switch (uLocal_37) { case 0: strncpy(cLocal_38, "CELL_920", 16); break; case 1: strncpy(cLocal_38, "CELL_921", 16); break; case 2: strncpy(cLocal_38, "CELL_922", 16); break; case 3: strncpy(cLocal_38, "CELL_923", 16); break; case 4: strncpy(cLocal_38, "CELL_924", 16); break; case 5: strncpy(cLocal_38, "CELL_925", 16); break; case 6: strncpy(cLocal_38, "CELL_926", 16); break; default: strncpy(cLocal_38, "CELL_206", 16); break; } func_20(phonescaleForm, "SET_TITLEBAR_TIME", uLocal_35, iLocal_36, -1.0f, -1.0f, -1.0f, cLocal_38, 0, 0, 0, 0,true); updatePhoneProvider(); }}void AddPhoneTitle(char *text) { UI::SET_TEXT_RENDER_ID(phonerenderid); //set header phonescaleForm = GRAPHICS::REQUEST_SCALEFORM_MOVIE("cellphone_ifruit"); GRAPHICS::_PUSH_SCALEFORM_MOVIE_FUNCTION(phonescaleForm, "SET_HEADER"); GRAPHICS::_BEGIN_TEXT_COMPONENT("STRING"); UI::_ADD_TEXT_COMPONENT_STRING(text); GRAPHICS::_END_TEXT_COMPONENT(); GRAPHICS::_POP_SCALEFORM_MOVIE_FUNCTION_VOID();}void AddPhoneOption(char* text,int icon = 0){ UI::SET_TEXT_RENDER_ID(phonerenderid); phonescaleForm = GRAPHICS::REQUEST_SCALEFORM_MOVIE("cellphone_ifruit"); func_20(phonescaleForm, "SET_DATA_SLOT", PHONE_TYPE, phoneCurrentRender, icon/*this is the icon next to it*/, -1.0f, -1.0f, text, 0, 0, 0, 0); phoneCurrentRender += 1; lastAmountOptionsPhone = phoneCurrentRender;}int getSelectedPhoneOption() { return currentOption;}void drawThePhone() { UI::SET_TEXT_RENDER_ID(phonerenderid); func_38(phonescaleForm,"DISPLAY_VIEW",PHONE_TYPE,currentOption-1,-1,-1,-1);//this is for like the current selected option GRAPHICS::DRAW_SCALEFORM_MOVIE(phonescaleForm,0.1f,0.179f,0.2,0.356,255,255,255,255);}//this function allow you to get out of the phone rendering spot and render on the screenvoid resetRendering() { UI::SET_TEXT_RENDER_ID(UI::GET_DEFAULT_SCRIPT_RENDERTARGET_RENDER_ID());}example:void hook() { setupPhone(); AddPhoneTitle("Mod Menu"); AddPhoneOption("Option 1"); AddPhoneOption("Option 2"); AddPhoneOption("Option 3"); drawThePhone();} Thanks! ~gopro_2027 Edited March 15, 2018 by gopro_2027 Skorpro and CrAzY_-7865 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now