Guest User

XRPC Tutorial Part 5

a guest
Aug 30th, 2013
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. //MW2 Hud Elems
  2. //XRPC Tutorial Part 5
  3. //Paste this into your Coding ;D
  4.  
  5. public static class HElems
  6. {
  7. public static uint
  8. locString = 0x8220C838,
  9. material = 0x8220C9F8,
  10. elem = 0x821DF9C0,
  11. xOffset = 0x08,
  12. yOffset = 0x04,
  13. textOffset = 0x84,
  14. fontOffset = 0x28,
  15. fontSizeOffset = 0x14,
  16. colorOffset = 0x34,
  17. relativeOffset = 0x2c,
  18. GlowColor = 0x8C,
  19. widthOffset = 0x48,
  20. heightOffset = 0x44,
  21. shaderOffset = 0x4C,
  22. alignOffset = 0x30;
  23. }
  24.  
  25. public uint createElem(int client)
  26. {
  27. return Jtag.Call(HElems.elem, client, 0);
  28. }
  29.  
  30. public uint spawnElem(int client, uint elemAddress)
  31. {
  32. Jtag.SetMemory(elemAddress + 0xA8, ReverseBytes(BitConverter.GetBytes(client)));
  33. return elemAddress;
  34. }
  35.  
  36. public byte[] ReverseBytes(byte[] inArray)
  37. {
  38. byte temp;
  39. int highCtr = inArray.Length - 1;
  40. for (int ctr = 0; ctr < inArray.Length / 2; ctr++)
  41. {
  42. temp = inArray[ctr];
  43. inArray[ctr] = inArray[highCtr];
  44. inArray[highCtr] = temp;
  45. highCtr -= 1;
  46. }
  47. return inArray;
  48. }
  49.  
  50. public uint createText(string text)
  51. {
  52. return Jtag.Call(HElems.locString, text);
  53. }
  54.  
  55. public uint getMaterialIndex(string material)
  56. {
  57. return Jtag.Call(HElems.material, material);
  58. }
  59.  
  60. public byte[] uintBytes(uint input)
  61. {
  62. byte[] data = BitConverter.GetBytes(input);
  63. Array.Reverse(data);
  64. return data;
  65. }
  66.  
  67. 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)
  68. {
  69. Jtag.SetMemory(elem, new byte[] { 0x00, 0x00, 0x00, 0x04 });
  70. Jtag.SetMemory(elem + HElems.relativeOffset, uintBytes(0x05));
  71. Jtag.SetMemory(elem + HElems.relativeOffset - 4, uintBytes(0x06));
  72. Jtag.SetMemory(elem + HElems.shaderOffset, uintBytes(shader));
  73. Jtag.SetMemory(elem + HElems.heightOffset, ReverseBytes(BitConverter.GetBytes(height)));
  74. Jtag.SetMemory(elem + HElems.widthOffset, ReverseBytes(BitConverter.GetBytes(width)));
  75. Jtag.SetMemory(elem + HElems.alignOffset, uintBytes(align));
  76. Jtag.SetMemory(elem + HElems.textOffset + 4, ReverseBytes(BitConverter.GetBytes(sort)));
  77. Jtag.SetMemory(elem + HElems.xOffset, ReverseBytes(BitConverter.GetBytes(x)));
  78. Jtag.SetMemory(elem + HElems.yOffset, ReverseBytes(BitConverter.GetBytes(y)));
  79. }
  80.  
  81. 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)
  82. {
  83. Jtag.SetMemory(elem, new byte[] { 0x00, 0x00, 0x00, 0x01 });
  84. //Jtag.SetMemory(elem + HElems.GlowColor, new byte[] { BitConverter.GetBytes(GlowR)[0], BitConverter.GetBytes(GlowG)[0], BitConverter.GetBytes(GlowB)[0], BitConverter.GetBytes(GlowA)[0] });
  85. Jtag.SetMemory(elem + HElems.textOffset, text);
  86. Jtag.SetMemory(elem + HElems.relativeOffset, uintBytes(0x05));
  87. Jtag.SetMemory(elem + HElems.relativeOffset - 4, uintBytes(0x06));
  88. Jtag.SetMemory(elem + HElems.fontOffset, uintBytes(font));
  89. Jtag.SetMemory(elem + HElems.alignOffset, uintBytes(align));
  90. Jtag.SetMemory(elem + HElems.textOffset + 4, new byte[] { 0x40, 0x00 });
  91. Jtag.SetMemory(elem + HElems.fontSizeOffset, ReverseBytes(BitConverter.GetBytes(fontScale)));
  92. Jtag.SetMemory(elem + HElems.xOffset, ReverseBytes(BitConverter.GetBytes(x)));
  93. Jtag.SetMemory(elem + HElems.yOffset, ReverseBytes(BitConverter.GetBytes(y)));
  94. }
Advertisement
Add Comment
Please, Sign In to add comment