HeresOtis Posted June 8, 2015 Share Posted June 8, 2015 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 More sharing options...
Juarez Posted June 8, 2015 Share Posted June 8, 2015 (edited) // Idle::RsMouseSetPosCPatch::Nop(0x53E9F1, 5); Edited June 8, 2015 by juarez HeresOtis 1 Link to comment Share on other sites More sharing options...
HeresOtis Posted June 9, 2015 Author Share Posted June 9, 2015 // Idle::RsMouseSetPosCPatch::Nop(0x53E9F1, 5); Nice find. It works. Link to comment Share on other sites More sharing options...
Davve95 Posted July 16, 2015 Share Posted July 16, 2015 Sorry for oftopic but how to script in C++ for GTA SA? Link to comment Share on other sites More sharing options...
fastman92 Posted July 16, 2015 Share Posted July 16, 2015 You need SA Plugin SDK and use a CRunningScriptWrapper that I created. Davve95 1 Link to comment Share on other sites More sharing options...
Davve95 Posted July 17, 2015 Share Posted July 17, 2015 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 More sharing options...
Shmoopy Posted July 17, 2015 Share Posted July 17, 2015 SDK: https://github.com/DK22Pac/plugin-sdk/archive/master.zip Precompiled-Library: http://www62.zippyshare.com/v/IPavxDwr/file.html Davve95 1 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