MW2 - TU8 - Set HudElem + Text w/source

Coder123 Feb 6, 2013

  1. Coder123

    Coder123 Finnish Modder XPG Developer TeamXPG
    0/47

    Joined:
    Jan 21, 2012
    Messages:
    1,954
    Likes Received:
    717
    Trophy Points:
    105
    Gender:
    Male
    Location:
    Finland
    Console:
    Xbox
    Just a simple program if you want to advertise something on your lobbys :)

    Credits to:

    GCAluminizing for his explained tutorial about hudelems
    Me for fixing code, making the program and editing the shader + text position.

    You need MW2 on TU8 and XRPC.xex as plugin to use this.

    Picture:
    [​IMG]
    In-game:
    [​IMG]

    Source:
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using XRPCLib;
    namespace HudElem
    {
    	public partial class Form1 : Form
    	{
    		XRPC Jtag = new XRPC();
    		public Form1()
    		{
    			InitializeComponent();
    		}
    		private void button1_Click(object sender, EventArgs e)
    		{
    			Jtag.Connect(); //connect to default console
    		}
    		private void button2_Click(object sender, EventArgs e)
    		{
    			Jtag.Call(0x82254940, -1, 0, "s loc_warnings 0");
    			Jtag.Call(0x82254940, -1, 0, "s loc_warningsUI 0"); //disable unlocalized text
    			uint elem = createElem(0);
    			string elemtext = "" + textBox1.Text;
    			setText(elem, uintBytes(createText(elemtext)), 1, 20, 330, 0, 1);
    			spawnElem(0, elem); //send text
    			uint elemshader = createElem(0);
    			uint shader = getMaterialIndex("black");
    			setIcon(elemshader, shader, 1000, 23, 250, 0, 1);
    			spawnElem(0, elemshader); //sent black shader
    		}
    		public static class HElems
    		{
    			public static uint
    			locString = 0x8220C838,
    			material = 0x8220C9F8,
    			elem = 0x821DF9C0,
    			xOffset = 0x08,
    			yOffset = 0x04,
    			textOffset = 0x84,
    			fontOffset = 0x28,
    			fontSizeOffset = 0x14,
    			colorOffset = 0x34,
    			relativeOffset = 0x2c,
    			widthOffset = 0x48,
    			heightOffset = 0x44,
    			shaderOffset = 0x4C,
    			alignOffset = 0x30;
    		}
    		public uint createElem(int client)
    		{
    			return Jtag.Call(HElems.elem, client, 0);
    		}
    		public uint spawnElem(int client, uint elemAddress)
    		{
    			Jtag.SetMemory(elemAddress + 0xA8, ReverseBytes(BitConverter.GetBytes(client)));
    			return elemAddress;
    		}
    		public uint createText(string text)
    		{
    			return Jtag.Call(HElems.locString, text);
    		}
    		public uint getMaterialIndex(string material)
    		{
    			return Jtag.Call(HElems.material, material);
    		}
    		public byte[] uintBytes(uint input)
    		{
    			byte[] data = BitConverter.GetBytes(input);
    			Array.Reverse(data);
    			return data;
    		}
    		public byte[] ReverseBytes(byte[] inArray)
    		{
    			byte temp;
    			int highCtr = inArray.Length - 1;
    			for (int ctr = 0; ctr < inArray.Length / 2; ctr++)
    			{
    				temp = inArray[ctr];
    				inArray[ctr] = inArray[highCtr];
    				inArray[highCtr] = temp;
    				highCtr -= 1;
    			}
    			return inArray;
    		}
    		public void setIcon(uint elem, uint shader, int width, int height, float x, float y, uint align, float sort = 0, int r = 255, int g = 255, int b = 255, int a = 255)
    		{
    			Jtag.SetMemory(elem, new byte[] { 0x00, 0x00, 0x00, 0x04 });
    			Jtag.SetMemory(elem + HElems.relativeOffset, uintBytes(0x05));
    			Jtag.SetMemory(elem + HElems.relativeOffset - 4, uintBytes(0x06));
    			Jtag.SetMemory(elem + HElems.shaderOffset, uintBytes(shader));
    			Jtag.SetMemory(elem + HElems.heightOffset, ReverseBytes(BitConverter.GetBytes(height)));
    			Jtag.SetMemory(elem + HElems.widthOffset, ReverseBytes(BitConverter.GetBytes(width)));
    			Jtag.SetMemory(elem + HElems.alignOffset, uintBytes(align));
    			Jtag.SetMemory(elem + HElems.colorOffset, new byte[] { BitConverter.GetBytes(r)[0], BitConverter.GetBytes(g)[0], BitConverter.GetBytes(B)[0], BitConverter.GetBytes(a)[0] });
    			Jtag.SetMemory(elem + HElems.textOffset + 4, ReverseBytes(BitConverter.GetBytes(sort)));
    			Jtag.SetMemory(elem + HElems.xOffset, ReverseBytes(BitConverter.GetBytes(x)));
    			Jtag.SetMemory(elem + HElems.yOffset, ReverseBytes(BitConverter.GetBytes(y)));
    		}
    		public void setText(uint elem, byte[] text, uint font, float fontScale, float x, float y, uint align, int r = 255, int g = 255, int b = 255, int a = 255)
    		{
    			Jtag.SetMemory(elem, new byte[] { 0x00, 0x00, 0x00, 0x01 });
    			Jtag.SetMemory(elem + HElems.textOffset, text);
    			Jtag.SetMemory(elem + HElems.relativeOffset, uintBytes(0x05));
    			Jtag.SetMemory(elem + HElems.relativeOffset - 4, uintBytes(0x06));
    			Jtag.SetMemory(elem + HElems.fontOffset, uintBytes(font));
    			Jtag.SetMemory(elem + HElems.alignOffset, uintBytes(align));
    			Jtag.SetMemory(elem + HElems.textOffset + 4, new byte[] { 0x40, 0x00 });
    			Jtag.SetMemory(elem + HElems.fontSizeOffset, ReverseBytes(BitConverter.GetBytes(fontScale)));
    			Jtag.SetMemory(elem + HElems.xOffset, ReverseBytes(BitConverter.GetBytes(x)));
    			Jtag.SetMemory(elem + HElems.yOffset, ReverseBytes(BitConverter.GetBytes(y)));
    			Jtag.SetMemory(elem + HElems.colorOffset, new byte[] { BitConverter.GetBytes(r)[0], BitConverter.GetBytes(g)[0], BitConverter.GetBytes(B)[0], BitConverter.GetBytes(a)[0] });
    		}
    	}
    }
    
    Download:
    https://mega.co.nz/#...OnOADgVwhHGpSbI
     
  2. XPGProgrammer

    XPGProgrammer Newbie
    0/47

    Joined:
    Jan 2, 2013
    Messages:
    802
    Likes Received:
    214
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Canada
    Console:
    Xbox
    I just tried this and there's an error saying that 'B' doesn't exist, I'm gonna try to fix it.
     
  3. Coder123

    Coder123 Finnish Modder XPG Developer TeamXPG
    105/188

    Joined:
    Jan 21, 2012
    Messages:
    1,954
    Likes Received:
    717
    Trophy Points:
    105
    Gender:
    Male
    Location:
    Finland
    Console:
    Xbox
    Working for me

    MW2
    TU8
    720P

    Is the error in the game or program?
     
  4. BxRKings

    BxRKings Developer XPG Developer Lifetime Gold TeamXPG
    135/188

    Joined:
    May 1, 2011
    Messages:
    2,163
    Likes Received:
    849
    Trophy Points:
    135
    Gender:
    Male
    Location:
    BxRCo., Ltd.™©
    Console:
    Xbox
    Fantastic Job Coder.
     
  5. X9Cinema

    X9Cinema Resident GFX Guru Lifetime Gold
    0/47

    Joined:
    Dec 9, 2011
    Messages:
    2,596
    Likes Received:
    476
    Trophy Points:
    0
    Gender:
    Male
    Location:
    US
    Console:
    Xbox
    I'll try this later, but most of your programs never work for me. :(
     
  6. XPGProgrammer

    XPGProgrammer Newbie
    0/47

    Joined:
    Jan 2, 2013
    Messages:
    802
    Likes Received:
    214
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Canada
    Console:
    Xbox
    I made a menu with sub menu's, ect.. but I can't get the scolling part to work..

    [​IMG]
     
  7. hT

    hTDrag Newbie
    0/47

    Joined:
    Oct 6, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Console:
    Xbox
    Is this possible in a .dll?
    I am new to tu8 because I was on PS3 while the tu was in progress.
     
  8. DA

    DArKx1337HaX Newbie
    0/47

    Joined:
    May 11, 2012
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    0
    Console:
    Xbox
    Tried your source, but im getting a lot of errors with the coloroffset function
     
  9. XPGProgrammer

    XPGProgrammer Newbie
    0/47

    Joined:
    Jan 2, 2013
    Messages:
    802
    Likes Received:
    214
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Canada
    Console:
    Xbox
    Yes, me too. I suggest you to just pick some things in it and then make your own.
     
  10. DA

    DArKx1337HaX Newbie
    0/47

    Joined:
    May 11, 2012
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    0
    Console:
    Xbox
    Yeah I re-made it without errors
     

Share This Page

Close