Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
gopro_2027

[C++] Phone Based Mod Menu

Recommended Posts

gopro_2027

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 by gopro_2027

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.