Jump to content

Making asi which will hide hud (edit hud parameters)?


Recommended Posts

I already have visual studio. I downloaded plugin-sdk by DK22Pac. I have some programming knowledge about C++.

I want to know how can I edit for example Radar x, y position. How could I hide Fist (weapon) icon, how could I change position of health/armour?

 

How it is done? I googled a lot and search this forum but couldn't find a topic that would help me understand editing hud objects? I appreciate any help.

if you take a look on CHud class you will see that it has specific functions for those you need with specific parameters (pos, cped). it allows you to do your logic easily on function call or in the beginning of function. Two of possible ways to do that on your choice: first one requires to find call points and replace them to your "mirror" function, second - some poor asm knowledge

#include "plugin.h"#include "game_sa\CHud.h"using namespace plugin;void drawWeaponIconExtension();class custom_plgn{public:	static bool bdrawHP;	custom_plgn()	{		DWORD vProtect;		// hook draw hp bar		VirtualProtect((void*)0x0058EE9A, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EE9B = (DWORD)drawHPbarCB - 0x0058EE9A - 5;				// destination - source - 5		VirtualProtect((void*)0x0058EE9A, 5, vProtect, &vProtect);		VirtualProtect((void*)0x0058EF0D, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EF0E = (DWORD)drawHPbarCB - 0x0058EF0D - 5;		VirtualProtect((void*)0x0058EF0D, 5, vProtect, &vProtect);		// hook draw weapon icon		VirtualProtect((void*)0x0058D7D0, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(BYTE*)0x0058D7D0 = 0xE8;								// asm call		*(DWORD*)0x0058D7D1 = (DWORD)drawWeaponIconExtension - 0x0058D7D0 - 5;		VirtualProtect((void*)0x0058D7D0, 5, vProtect, &vProtect);	}	static void drawHPbarCB(int playerId, int x, int y)	{		if (bdrawHP)			CHud::RenderHealthBar(playerId, 100, 100);	}	} cp;bool custom_plgn::bdrawHP = true;static void __declspec(naked) drawWeaponIconExtension(){	_asm	{		mov eax, [esp + 8];				// Cped in eax		mov al, [eax + 1816];			        // Cped.active weapon slot(BYTE) in low byte eax		test al, al;					// comparing with zero		jz Abort;					// jump if zero		mov eax, DWORD PTR DS : [0x00C97B24];	        // replaced code (this time fits perfectly (5b), otherwise use jmp or ret ptr to leave)		ret;						// continue hooked function 		Abort:		add esp, 4;					// set return point		ret;						// leaving both functions, rest of stack will be cleared by caller (cdecl)	}}

 

if you take a look on CHud class you will see that it has specific functions for those you need with specific parameters (pos, cped). it allows you to do your logic easily on function call or in the beginning of function. Two of possible ways to do that on your choice: first one requires to find call points and replace them to your "mirror" function, second - some poor asm knowledge

 

 

This works, but depending on your monitor size it changes position, how do I make it stay in the same spot I want it to do?

Thanks for reply madleg!

 

Could you tell me what does this code:

                // hook draw hp bar		VirtualProtect((void*)0x0058EE9A, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EE9B = (DWORD)drawHPbarCB - 0x0058EE9A - 5;				// destination - source - 5		VirtualProtect((void*)0x0058EE9A, 5, vProtect, &vProtect);		VirtualProtect((void*)0x0058EF0D, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EF0E = (DWORD)drawHPbarCB - 0x0058EF0D - 5;		VirtualProtect((void*)0x0058EF0D, 5, vProtect, &vProtect);

Why is it repeating (in first block 0x0058EE9A, in the second 0x0058EF0D) ?

 

What is // destination - source - 5 ? What is destination here?

 

And what did you do with this:

                // hook draw weapon icon		VirtualProtect((void*)0x0058D7D0, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(BYTE*)0x0058D7D0 = 0xE8;								// asm call		*(DWORD*)0x0058D7D1 = (DWORD)drawWeaponIconExtension - 0x0058D7D0 - 5;		VirtualProtect((void*)0x0058D7D0, 5, vProtect, &vProtect);

You did something with weapon icon? You hide it or?

 

Edit: While compiling, at the end i got this error:

 

cLDSVRL.png

Edited by Contixo

Thanks for reply madleg!

 

Could you tell me what does this code:

                // hook draw hp bar		VirtualProtect((void*)0x0058EE9A, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EE9B = (DWORD)drawHPbarCB - 0x0058EE9A - 5;				// destination - source - 5		VirtualProtect((void*)0x0058EE9A, 5, vProtect, &vProtect);		VirtualProtect((void*)0x0058EF0D, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(DWORD*)0x0058EF0E = (DWORD)drawHPbarCB - 0x0058EF0D - 5;		VirtualProtect((void*)0x0058EF0D, 5, vProtect, &vProtect);

Why is it repeating (in first block 0x0058EE9A, in the second 0x0058EF0D) ?

 

What is // destination - source - 5 ? What is destination here?

 

And what did you do with this:

                // hook draw weapon icon		VirtualProtect((void*)0x0058D7D0, 5, PAGE_EXECUTE_READWRITE, &vProtect);		*(BYTE*)0x0058D7D0 = 0xE8;								// asm call		*(DWORD*)0x0058D7D1 = (DWORD)drawWeaponIconExtension - 0x0058D7D0 - 5;		VirtualProtect((void*)0x0058D7D0, 5, vProtect, &vProtect);

You did something with weapon icon? You hide it or?

 

Edit: While compiling, at the end i got this error:

 

cLDSVRL.png

 

You probably didn't install the plugin.lib with the plug-in sdk by DK22PAC

Could you tell me what does this code:

                // hook draw hp bar...

Why is it repeating (in first block 0x0058EE9A, in the second 0x0058EF0D) ?

 

What is // destination - source - 5 ? What is destination here?

 

And what did you do with this:

                // hook draw weapon icon...

 

in // hook draw hp bar... i did call redirection. At 0x0058EE9A and 0x0058EF0D theres calls to DrawHealthBar function. In process memory they look like this: 0xE8 (asm opcode to call), then parameter (offset to CHud:;RenderHealthBar function from after command (destination(CHud:;RenderHealthBar) - source (0x0058EE9A or 0x0058EF0D) - 5 (opcode size))). So you simple change offset to your function (drawHPbarCB in my case). Keep in mind that your function should take parameters like original one. Also to access those memory regions you need to unprotect them.

 

In // hook draw weapon incon..., as alternative which gives you absolute freedom, i edited CHud::DrawWeaponIcon function which starts at 0x0058D7D0. As i said, you need some basic asm understanding, otherwise its pointless. In a nutshell that function looks like this now:

...(ped, x, y, transparency){    if (!ped->activeWeaponSlot) // 0 = fist        return;    ...original function...}

but technically it looks a bit different though.

 

Idk about error, build it in build->build solution or rmb on your project and build, set relsease configuration as well.

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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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