Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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. Grand Theft Auto Series

      1. Bugs*
      2. 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. GTA San Andreas

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

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

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. 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

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

c++ Drawing mouse ingame


HeresOtis
 Share

Recommended Posts

I believe I have the proper calculations and drawing, but the cursor texture always moves itself back to the center of the screen. Why does this happen?

What other way can I simulate the mouse ingame?

// Under WINAPI DllMain callCore::RegisterFunc(FUNC_INITIALISE_RW, InitializeTXD);Core::RegisterFunc(FUNC_POST_PROCESS_DRAWING, DrawAndProcessTXD);Core::RegisterFunc(FUNC_SHUTDOWN_RW, ShutdownTXD);// In separate cpp, (don't worry, all function calls are correct, no crashing)float CursorPosX, CursorPosY are global variablesvoid DrawAndProcessTXD(){	CPed* pPlayer = FindPlayerPed(-1);	if (pPlayer)	{		CSphere sphereLS;		sphereLS.m_fRadius = 3.0f;		sphereLS.m_vCenter.x = 2496.19f;		sphereLS.m_vCenter.y = -1703.27f;		sphereLS.m_vCenter.z = 1014.74f;		// player angle 266.0		sphereLS.Set(3.0f, sphereLS.m_vCenter);	// LSPD HQ		// CSprite2d to draw a sphere texture, or custom texture		if (pPlayer->GetIsTouching(sphereLS.m_vCenter, 20.0f))		{			spriteCarLS.Draw(20.0, 20.0, getSizeInScreenScaleByUserResolution(200.0, 'w'), getSizeInScreenScaleByUserResolution(200.0, 'h'), CRGBA(255, 255, 255, 255));			UpdateMouseCursorPos();			spriteCursor.Draw(CursorPosX, CursorPosY, getSizeInScreenScaleByUserResolution(20.0, 'w'), getSizeInScreenScaleByUserResolution(20.0, 'h'), CRGBA(255, 255, 255, 255));			if (GetAsyncKeyState(VK_LBUTTON) & 1)			{				//(x > box.x ) && (x < box.x + box.w) && (y > box.y) && (y < box.y + box.h)				if ((CurrentMouseState->x > 20.0) && (CurrentMouseState->x < 20.0 + 50.0) && (CurrentMouseState->y > 20.0) && (CurrentMouseState->y < 20.0 + 50.0))					CMessages::AddMessageJumpQ("clicked", 100, 1, true);			}					}					}}// Taken from fastman92's Timecyc editorvoid UpdateMouseCursorPos(){	float newPosX, newPosY;	newPosX = ((float)CurrentMouseState->x * 200.0f * getMouseSensitivity());	newPosY = ((float)CurrentMouseState->y * 200.0f * getMouseSensitivity());	CursorPosX += newPosX;	CursorPosY += newPosY;		if (*(bool *)0xBA6744)	// is mouseX inverted		CursorPosX *= -1.0;	if (*(bool *)0xBA6745)	// is mouseY inverted		CursorPosY *= -1.0;		// MouseX below 0	if (CursorPosX < 0.0f)		CursorPosX = 0.0f;	// MouseX above 640	if (CursorPosX > 639.0f)		CursorPosX = 639.0f;	// MouseY below 0	if (CursorPosY < 0.0f)		CursorPosY = 0.0f;	// MouseY above 448	if (CursorPosY > 447.0f)		CursorPosY = 447.0f;			newPosX = CursorPosX + (getSizeInScreenScaleByUserResolution(25.0, 'w') / 2.0f);	newPosY = CursorPosY + (getSizeInScreenScaleByUserResolution(25.0, 'h') / 2.0f);	CursorPosX = newPosX;	CursorPosY = newPosY;	return;}float getMouseSensitivity(){		return *(float *)0xB6EC1C;}
Link to comment
Share on other sites

 


// Idle::RsMouseSetPos
CPatch::Nop(0x53E9F1, 5);

 

Edited by juarez
Link to comment
Share on other sites

// Idle::RsMouseSetPosCPatch::Nop(0x53E9F1, 5);

Nice find. It works.

Link to comment
Share on other sites

  • 1 month later...

Sorry for oftopic but how to script in C++ for GTA SA?

Link to comment
Share on other sites

You need SA Plugin SDK and use a CRunningScriptWrapper that I created.

Link to comment
Share on other sites

You need SA Plugin SDK and use a CRunningScriptWrapper that I created.

Where can I find them?. Thanks!

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.