• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hud Elements Tutorial
#1
Can Somebody make a tutorial for Grandma about How to make Hud elements and how to customize them? please? Happy cry

i just couldnt get enough in http://www.itsmods.com/forum/Thread-Rele...verAd.html
  Reply
#2
CSHARP Code
  1. using System.Threading;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Addon;
  6.  
  7. namespace PimpItUp
  8. {
  9. class HUDManager
  10. {
  11. public static Dictionary<string, HudElem> HUDs = new Dictionary<string, HudElem>();
  12. public static Dictionary<string, HudElem> Messages = new Dictionary<string, HudElem>();
  13. public static Dictionary<string, HudElem> Icons = new Dictionary<string, HudElem>();
  14. public static Dictionary<string, HudElem> Logos = new Dictionary<string, HudElem>();
  15. public static Dictionary<string, HudElem> Taglines = new Dictionary<string, HudElem>();
  16.  
  17. public static void AddClient(ServerClient cl)
  18. {
  19. InitHUD(cl);
  20. }
  21.  
  22. static HudElem DefaultProcedure(HudElem ele, ServerClient cl)
  23. {
  24. ele.Team = cl.Team;
  25. ele.ShowToEnt = cl.ClientNum;
  26. ele.HideInMenu = true;
  27. return ele;
  28. }
  29.  
  30. public static void InitHUD(ServerClient cl)
  31. {
  32. //create 2 elements for this new user
  33.  
  34. try
  35. {
  36. Debug.WriteLine("HUD init");
  37. if (HUDs.ContainsKey(cl.XUID) && Messages.ContainsKey(cl.XUID) && Icons.ContainsKey(cl.XUID))
  38. {
  39. Debug.WriteLine("Removing old HudElems for client " + cl.ClientNum);
  40. RemoveClient(cl);
  41. }
  42. HudElem HUD = Core.Main.CreateNewHudElem();
  43. HUD = DefaultProcedure(HUD, cl);
  44. HUD.Font = HudElementFonts.HudMedium;
  45. HUD.Type = HudElementTypes.Text;
  46. HUD.SetLabel("Upgrade 0/5");
  47. HUD.FontScale = 1.6f;
  48. HUD.PointType = 81;
  49. HUD.OriginY = 75f;
  50. HUD.OriginX = 10f;
  51. HUD.Color.R = 255;
  52. HUD.Color.GlowR = 255;
  53. HUD.Color.GlowA = 255;
  54.  
  55. HudElem Icon = Core.Main.CreateNewHudElem();
  56. Icon = DefaultProcedure(Icon, cl);
  57. Icon.Type = HudElementTypes.Icon;
  58. //Icon.SetIcon("iw5_cardicon_cat");
  59. Icon.IconHeight = 64;
  60. Icon.IconWidth = 64;
  61.  
  62. HudElem Logo = Core.Main.CreateNewHudElem();
  63. Logo = DefaultProcedure(Icon, cl);
  64. Logo.Type = HudElementTypes.Text;
  65. Logo.Font = HudElementFonts.ModernBold;
  66. Logo.Color.GlowA = 200; //not that intense
  67. Logo.Color.GlowG = 200;
  68. Logo.FontScale = 1.6f;
  69. Logo.PointType = 123;
  70. Logo.OriginX = 255;
  71. Logo.SetLabel("PimpItUp");
  72.  
  73. HudElem Tagline = Core.Main.CreateNewHudElem();
  74. Tagline = DefaultProcedure(Tagline, cl);
  75. Tagline.Type = HudElementTypes.Text;
  76. Tagline.PointType = 123;
  77. Tagline.OriginX = 255;
  78. Tagline.OriginY = 30;
  79. Tagline.Font = HudElementFonts.Modern;
  80. Tagline.FontScale = 0.8f;
  81. Tagline.SetLabel("by jariz - itsmods.com");
  82.  
  83. HudElem Message = Core.Main.CreateNewHudElem();
  84. Message = DefaultProcedure(Message, cl);
  85. Message.HideInMenu = false;
  86. Message.PointType = 31;
  87. //Message.PointType = 113;
  88. Message.Type = HudElementTypes.Text;
  89. Message.Font = HudElementFonts.Modern;
  90. Message.OriginX = 245;
  91. //Message.OriginY = 180;
  92. Message.OriginY = 200;
  93. Message.FontScale = 1;
  94.  
  95. Icons.Add(cl.XUID, Icon);
  96. HUDs.Add(cl.XUID, HUD);
  97. Messages.Add(cl.XUID, Message);
  98. Logos.Add(cl.XUID, Logo);
  99. Taglines.Add(cl.XUID, Tagline);
  100.  
  101. }
  102. catch (Exception z)
  103. {
  104. Core.Main.ServerPrint("[PIU] Failed initializing HUD: " + z.ToString());
  105. if (Debug.DEV) Core.Main.TellClient(cl.ClientNum, "Failed initializing HUD: ^1" + z.Message, true);
  106. }
  107. }
  108.  
  109. public static void UpdateHUD(ServerClient cl, Upgrade.Rank rank)
  110. {
  111. int totalrank = 5;
  112. byte green = Convert.ToByte((255 / totalrank) * (int)rank);
  113. byte red = Convert.ToByte((255 - (255 / totalrank) * (int)rank));
  114. Debug.WriteLine("green = " + green);
  115. HudElem HUD = HUDs[cl.XUID];
  116. HUD.Color.GlowG = green;
  117. HUD.Color.GlowR = red;
  118. HUD.Color.GlowB = 0;
  119. HUD.Color.GlowA = 255;
  120. HUD.SetLabel("Upgrade " + Convert.ToInt32(rank) + "/5");
  121. ShowMessage(cl, "WEAPON UPGRADED!");
  122. }
  123.  
  124. static void MessageThread(object rHUD)
  125. {
  126. HudElem HUD = (HudElem)rHUD;
  127. while (HUD.Color.A != 250)
  128. {
  129. HUD.Color.A += 25;
  130. Thread.Sleep(100);
  131. }
  132. HUD.Color.A = 255;
  133. Thread.Sleep(3000);
  134. HUD.SetLabel("");
  135.  
  136. }
  137.  
  138. public static void RemoveClient(ServerClient cl)
  139. {
  140. Messages[cl.XUID].ShowToEnt = 255;
  141. HUDs[cl.XUID].ShowToEnt = 255;
  142. Icons[cl.XUID].ShowToEnt = 255;
  143. Logos[cl.XUID].ShowToEnt = 255;
  144. Taglines[cl.XUID].ShowToEnt = 255;
  145.  
  146. Messages.Remove(cl.XUID);
  147. HUDs.Remove(cl.XUID);
  148. Icons.Remove(cl.XUID);
  149. Logos.Remove(cl.XUID);
  150. Taglines.Remove(cl.XUID);
  151. }
  152.  
  153. public static void ShowMessage(ServerClient cl, string message)
  154. {
  155. HudElem HUD = Messages[cl.XUID];
  156. HUD.SetLabel(message);
  157. HUD.FontScale = 1;
  158. HUD.Color.A = 0;
  159. HUD.Color.R = 240;
  160. HUD.Color.G = 214;
  161. HUD.Color.B = 106;
  162.  
  163. ThreadPool.QueueUserWorkItem(new WaitCallback(MessageThread), HUD);
  164. }
  165. }
  166. }
[-] The following 2 users say Thank You to JariZ for this post:
  • OzonE, [HARD] Tony.
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  TUTORIAL CHEAT ENGINE for mw3 [HARD] Tony. 5 1,617 10-24-2013, 15:22
Last Post: Tomsen1410
  How to delete HUD elements on death? camxxcore 6 1,517 08-21-2013, 08:54
Last Post: Yamato
Question Tutorial addon! [HARD] Tony. 2 1,151 04-30-2013, 13:55
Last Post: [HARD] Tony.
  [TUTORIAL] Various Statements KrypTiK 2 941 01-07-2013, 21:00
Last Post: kokole
  Help Game Programming Tutorial Ich1994 8 1,691 01-01-2013, 21:21
Last Post: Ich1994
  [TUTORIAL] C# Introduction KrypTiK 4 1,180 12-30-2012, 10:06
Last Post: KrypTiK
  [TUTORIAL] Basic Syntax KrypTiK 0 764 12-29-2012, 20:33
Last Post: KrypTiK
  [TUTORIAL] Handling Errors in VB.NET KrypTiK 0 687 12-29-2012, 20:28
Last Post: KrypTiK
  [TUTORIAL] Getting to know your way around the IDE KrypTiK 0 702 12-29-2012, 20:23
Last Post: KrypTiK
  [TUTORIAL] Introduction Into VB.NET KrypTiK 0 748 12-29-2012, 20:15
Last Post: KrypTiK

Forum Jump:


Users browsing this thread: 1 Guest(s)