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

    1. GTANet.com

    1. GTA Online

      1. The Contract
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    2. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    3. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    4. Bugs*

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

Drawing Menu is Crashing Game!


Sharpiee
 Share

Recommended Posts

I am going off the code snippets from the original NativeTrainer source code for drawing a menu. Whenever I press my button to activate the menu GUI, my game freezes and crashes. This is a small part of the code I have at the moment:

void drawRect(float A_0, float A_1, float A_2, float A_3, int A_4, int A_5, int A_6, int A_7){	GRAPHICS::DRAW_RECT((A_0 + (A_2 * 0.5f)), (A_1 + (A_3 * 0.5f)), A_2, A_3, A_4, A_5, A_6, A_7);}void renderMenuLine(std::string title, float optionWidth, float optionHeight, float optionTop, float optionLeft, float textLeft, bool active, bool menuTitle, bool rescaleText = true){	//Default Values	int text_col[4] = { 255, 0, 0, 255 },		rect_col[4] = { 0, 0, 0, 255 };	float text_scale = 0.35;	int font = 0;	//Hover	if (active)	{		text_col[0] = 255;		text_col[1] = 255;		text_col[2] = 255;		rect_col[0] = 50;		rect_col[1] = 50;		rect_col[2] = 50;		if (rescaleText) text_scale = 0.40;	}	if (menuTitle)	{		rect_col[0] = 255;		rect_col[1] = 255;		rect_col[2] = 255;		rect_col[3] = 255;		if (rescaleText) text_scale = 0.50;		font = 1;	}	int screen_w, screen_h;	GRAPHICS::GET_SCREEN_RESOLUTION(&screen_w, &screen_h);	textLeft += optionLeft;	float lineWidthScaled = optionWidth / (float)screen_w; // line width	float lineTopScaled = optionTop / (float)screen_h; // line top offset	float textLeftScaled = textLeft / (float)screen_w; // text left offset	float lineHeightScaled = optionHeight / (float)screen_h; // line height	float lineLeftScaled = optionLeft / (float)screen_w;	//Upper Text	UI::SET_TEXT_FONT(font);	UI::SET_TEXT_SCALE(0.0, text_scale);	UI::SET_TEXT_COLOUR(text_col[0], text_col[1], text_col[2], text_col[3]);	UI::SET_TEXT_CENTRE(0);	UI::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);	UI::SET_TEXT_EDGE(0, 0, 0, 0, 0);	UI::_SET_TEXT_ENTRY("STRING");	UI::_ADD_TEXT_COMPONENT_STRING((LPSTR)title.c_str());	UI::_DRAW_TEXT(textLeftScaled, (((lineTopScaled + 0.00278f) + lineHeightScaled) - 0.005f));	//Lower Text	UI::SET_TEXT_FONT(font);	UI::SET_TEXT_SCALE(0.0, text_scale);	UI::SET_TEXT_COLOUR(text_col[0], text_col[1], text_col[2], text_col[3]);	UI::SET_TEXT_CENTRE(0);	UI::SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);	UI::SET_TEXT_EDGE(0, 0, 0, 0, 0);	UI::_SET_TEXT_GXT_ENTRY("STRING");	UI::_ADD_TEXT_COMPONENT_STRING((LPSTR)title.c_str());	int num25 = UI::_0x9040DFB09BE75706(textLeftScaled, (((lineTopScaled + 0.00278f) + lineHeightScaled) - 0.005f));	//BackGround Rectangle	drawRect(lineLeftScaled, lineTopScaled + (0.00278f), lineWidthScaled, ((((float)(num25)* UI::_0xDB88A37483346780(text_scale, 0)) + (lineHeightScaled * 2.0f)) + 0.005f), rect_col[0], rect_col[1], rect_col[2], rect_col[3]);}void renderMainMenu(){	const float optionWidth = 200.0;	const int optionCount = 7;	std::string menuTitle = "Sharpie's Menu";	static LPCSTR optionTitles[optionCount] = {		"Player",		"Warps",		"Weapons",		"Vehicles",		"Online Players",		"World",		"Settings"	};	DWORD waitTime = 150;	while (true)	{		DWORD maximumTicks = GetTickCount() + waitTime;		do		{			renderMenuLine(menuTitle, optionWidth, 15.0, 18.0, 0.0, 5.0, false, true);			for (int c = 0; c < optionCount; c++)				if(c != activeOptionIndexMain)					renderMenuLine(optionTitles[c], optionWidth, 9.0, 60.0 + c * 36.0, 0.0, 9.0, false, false);			renderMenuLine(optionTitles[activeOptionIndexMain], optionWidth + 1.0, 11.0, 56.0 + activeOptionIndexMain * 36, 0.0, 7.0, true, false);		} while (GetTickCount() < maximumTicks);		waitTime = 0;	}	bool btnSelect, btnBack, btnUp, btnDown;	getButtonState(&btnSelect, &btnBack, &btnUp, &btnDown, NULL, NULL);	if (btnSelect)	{		switch (activeOptionIndexMain)		{			case 0: renderPlayerMenu(); break;			case 1: renderWarpsMenu(); break;			case 2: renderWeaponsMenu(); break;			case 3: renderVehiclesMenu(); break;			case 4: renderOnlineMenu(); break;			case 5: renderWorldMenu(); break;			case 6: renderSettingsMenu(); break;		}		waitTime = 200;	}	else if (btnUp)	{		if (activeOptionIndexMain == 0)			activeOptionIndexMain = optionCount;		activeOptionIndexMain--;		waitTime = 150;	}	else if (btnDown)	{		activeOptionIndexMain++;		if (activeOptionIndexMain == 0)			activeOptionIndexMain = 0;		waitTime = 150;	}}void main(){	while (true)	{		//Functionability for Menu Display		if (menuToggle())		{			resetMenuSwitch();			DWORD time = GetTickCount() + 1000;			menuActive = !menuActive;			//Display Notification			UI::_SET_NOTIFICATION_TEXT_ENTRY("STRING");			UI::_ADD_TEXT_COMPONENT_STRING3(menuToString(menuActive));			UI::_SET_NOTIFICATION_MESSAGE("CHAR_DEFAULT", "CHAR_DEFAULT", false, 4, "Sharpie's Menu", "Version 1.0");			UI::_DRAW_NOTIFICATION(false, false);			renderMainMenu();						while (GetTickCount() < time)			{				updateStatusText();				WAIT(0);			}			resetMenuSwitch();		}		//Functionability for Enabled Mods		WAIT(0);	}}void ScriptMain(){	srand(GetTickCount());	main();}
Edited by Sharpiee
  • Like 1
Link to comment
Share on other sites

unknown modder

Use OutputDebugString and find out the line thats that's causing you to crash. Aka the last debug text to be displayed

Link to comment
Share on other sites

Because thats not implemented in the original C++ scripthook library. Im using this as a C++ learning experience. But I got it working so this topic is answered :) well fixed whatevs

Link to comment
Share on other sites

bhavinbhai2707

Because thats not implemented in the original C++ scripthook library. Im using this as a C++ learning experience. But I got it working so this topic is answered :) well fixed whatevs

that's great. . . . i have one suggestion when u get the solution then upload it here so others can learn from it :)

Edited by bhavinbhai2707
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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